2011-10-08 23:36:38 +02:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe "Issues" do
|
2011-10-26 15:46:25 +02:00
|
|
|
before do
|
2011-10-08 23:36:38 +02:00
|
|
|
login_as :user
|
|
|
|
end
|
|
|
|
|
|
|
|
describe "GET /keys" do
|
2011-10-26 15:46:25 +02:00
|
|
|
before do
|
2011-10-08 23:36:38 +02:00
|
|
|
@key = Factory :key, :user => @user
|
|
|
|
visit keys_path
|
|
|
|
end
|
|
|
|
|
|
|
|
subject { page }
|
|
|
|
|
|
|
|
it { should have_content(@key.title) }
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
describe "Destroy" do
|
2011-12-19 22:32:59 +01:00
|
|
|
before { visit key_path(@key) }
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should remove entry" do
|
2011-10-08 23:36:38 +02:00
|
|
|
expect {
|
2011-12-19 22:32:59 +01:00
|
|
|
click_link "Remove"
|
2011-10-08 23:36:38 +02:00
|
|
|
}.to change { @user.keys.count }.by(-1)
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
|
|
|
|
2012-01-29 23:43:14 +01:00
|
|
|
describe "New key" do
|
2011-10-26 15:46:25 +02:00
|
|
|
before do
|
2011-10-08 23:36:38 +02:00
|
|
|
visit keys_path
|
|
|
|
click_link "Add new"
|
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should open new key popup" do
|
2012-01-29 23:43:14 +01:00
|
|
|
page.should have_content("New key")
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
describe "fill in" do
|
2011-10-08 23:36:38 +02:00
|
|
|
before do
|
|
|
|
fill_in "key_title", :with => "laptop"
|
|
|
|
fill_in "key_key", :with => "publickey234="
|
|
|
|
end
|
|
|
|
|
|
|
|
it { expect { click_button "Save" }.to change {Key.count}.by(1) }
|
|
|
|
|
2011-10-26 15:46:25 +02:00
|
|
|
it "should add new key to table" do
|
2011-10-08 23:36:38 +02:00
|
|
|
click_button "Save"
|
|
|
|
|
2012-01-29 23:43:14 +01:00
|
|
|
page.should_not have_content("New key")
|
2011-10-08 23:36:38 +02:00
|
|
|
page.should have_content "laptop"
|
|
|
|
end
|
|
|
|
end
|
|
|
|
end
|
2011-12-19 22:32:59 +01:00
|
|
|
|
|
|
|
describe "Show page" do
|
|
|
|
before do
|
|
|
|
@key = Factory :key, :user => @user
|
|
|
|
visit key_path(@key)
|
|
|
|
end
|
|
|
|
|
|
|
|
it { page.should have_content @key.title }
|
|
|
|
it { page.should have_content @key.key[0..10] }
|
|
|
|
end
|
2011-10-08 23:36:38 +02:00
|
|
|
end
|