diff options
author | Nihad Abbasov <narkoz.2008@gmail.com> | 2012-09-10 13:40:51 +0400 |
---|---|---|
committer | Nihad Abbasov <narkoz.2008@gmail.com> | 2012-09-10 13:40:51 +0400 |
commit | 7aeb92b8e4bb279346d9dcec7bbca1725cec8eb1 (patch) | |
tree | 94e66cdcb0a7172956ff1ecf56cba72d0609c086 | |
parent | d74f54736b8aabb3885648c44d7e253209b8e9e1 (diff) |
rewrite profile feature steps using spinach
-rw-r--r-- | features/profile/profile.feature | 4 | ||||
-rw-r--r-- | features/profile/ssh_keys.feature | 13 | ||||
-rw-r--r-- | features/steps/profile.rb | 57 | ||||
-rw-r--r-- | features/steps/profile_ssh_keys.rb | 50 |
4 files changed, 114 insertions, 10 deletions
diff --git a/features/profile/profile.feature b/features/profile/profile.feature index afda4b55081..f4b2f198f0a 100644 --- a/features/profile/profile.feature +++ b/features/profile/profile.feature @@ -1,6 +1,6 @@ Feature: Profile - Background: - Given I signin as a user + Background: + Given I sign in as a user Scenario: I look at my profile Given I visit profile page diff --git a/features/profile/ssh_keys.feature b/features/profile/ssh_keys.feature index c81503ed2ba..018d124e412 100644 --- a/features/profile/ssh_keys.feature +++ b/features/profile/ssh_keys.feature @@ -1,13 +1,10 @@ -Feature: SSH Keys - Background: - Given I signin as a user - And I have ssh keys: - | title | - | ssh-rsa Work | - | ssh-rsa Home | +Feature: Profile SSH Keys + Background: + Given I sign in as a user + And I have ssh key "ssh-rsa Work" And I visit profile keys page - Scenario: I should see SSH keys + Scenario: I should see ssh keys Then I should see my ssh keys Scenario: Add new ssh key diff --git a/features/steps/profile.rb b/features/steps/profile.rb new file mode 100644 index 00000000000..c7e6be3fdea --- /dev/null +++ b/features/steps/profile.rb @@ -0,0 +1,57 @@ +class Profile < Spinach::FeatureSteps + Given 'I visit profile page' do + visit profile_path + end + + Then 'I should see my profile info' do + page.should have_content "Profile" + page.should have_content @user.name + page.should have_content @user.email + end + + Then 'I change my contact info' do + fill_in "user_skype", :with => "testskype" + fill_in "user_linkedin", :with => "testlinkedin" + fill_in "user_twitter", :with => "testtwitter" + click_button "Save" + @user.reload + end + + And 'I should see new contact info' do + @user.skype.should == 'testskype' + @user.linkedin.should == 'testlinkedin' + @user.twitter.should == 'testtwitter' + end + + Given 'I visit profile password page' do + visit profile_password_path + end + + Then 'I change my password' do + fill_in "user_password", :with => "222333" + fill_in "user_password_confirmation", :with => "222333" + click_button "Save" + end + + And 'I should be redirected to sign in page' do + current_path.should == new_user_session_path + end + + Given 'I visit profile token page' do + visit profile_token_path + end + + Then 'I reset my token' do + @old_token = @user.private_token + click_button "Reset" + end + + And 'I should see new token' do + find("#token").value.should_not == @old_token + find("#token").value.should == @user.reload.private_token + end + + Given 'I sign in as a user' do + login_as :user + end +end diff --git a/features/steps/profile_ssh_keys.rb b/features/steps/profile_ssh_keys.rb new file mode 100644 index 00000000000..9360f66f766 --- /dev/null +++ b/features/steps/profile_ssh_keys.rb @@ -0,0 +1,50 @@ +class ProfileSshKeys < Spinach::FeatureSteps + Then 'I should see my ssh keys' do + @user.keys.each do |key| + page.should have_content(key.title) + end + end + + Given 'I click link "Add new"' do + click_link "Add new" + end + + And 'I submit new ssh key "Laptop"' do + fill_in "key_title", :with => "Laptop" + fill_in "key_key", :with => "ssh-rsa publickey234=" + click_button "Save" + end + + Then 'I should see new ssh key "Laptop"' do + key = Key.find_by_title("Laptop") + page.should have_content(key.title) + page.should have_content(key.key) + current_path.should == key_path(key) + end + + Given 'I click link "Work"' do + click_link "Work" + end + + And 'I click link "Remove"' do + click_link "Remove" + end + + Then 'I visit profile keys page' do + visit keys_path + end + + And 'I should not see "Work" ssh key' do + within "#keys-table" do + page.should_not have_content "Work" + end + end + + Given 'I sign in as a user' do + login_as :user + end + + And 'I have ssh key "ssh-rsa Work"' do + Factory :key, :user => @user, :title => "ssh-rsa Work", :key => "jfKLJDFKSFJSHFJssh-rsa Work" + end +end |