From f8339f3b02d6b3905ccfd54c084fef64c3142d33 Mon Sep 17 00:00:00 2001 From: johnnymo87 Date: Thu, 24 Apr 2014 17:22:17 +0100 Subject: [PATCH 01/14] developing a new system for calling paths --- features/admin/admin_new_charity.feature | 2 +- features/cookie-policy.feature | 4 +- features/sign_in_sign_up/sign_up.feature | 6 +-- .../sign_up_link_to_org.feature | 4 +- .../step_definitions/authentication_steps.rb | 12 ++--- features/step_definitions/navigation_steps.rb | 53 ++++++++++--------- spec/requests/organizations_spec.rb | 6 +++ 7 files changed, 48 insertions(+), 39 deletions(-) diff --git a/features/admin/admin_new_charity.feature b/features/admin/admin_new_charity.feature index 082b15b10..ac9e27feb 100644 --- a/features/admin/admin_new_charity.feature +++ b/features/admin/admin_new_charity.feature @@ -16,7 +16,7 @@ Feature: Admin creating charity Scenario: Unsuccessfully attempt to create charity without being signed-in # should this be checking for absence of link to the new org page? - Given I am on the new charity page + Given I am on the new organisation page Then I should be on the sign in page # beta version only allows admin to create new organization, currently diff --git a/features/cookie-policy.feature b/features/cookie-policy.feature index 05845dd5b..2c43a2915 100644 --- a/features/cookie-policy.feature +++ b/features/cookie-policy.feature @@ -5,7 +5,9 @@ Feature: Approve cookies Tracker story ID: https://www.pivotaltracker.com/story/show/56438038 Background: - Given I am on the password reset page + Given I visit the password reset page with params: + | key | value | + | reset password token | 18217tiegi1qwea | Then I should see an approve cookie policy message Scenario: User approving the cookies diff --git a/features/sign_in_sign_up/sign_up.feature b/features/sign_in_sign_up/sign_up.feature index 150c3fc67..c48885095 100644 --- a/features/sign_in_sign_up/sign_up.feature +++ b/features/sign_in_sign_up/sign_up.feature @@ -13,21 +13,21 @@ Background: And cookies are approved @email Scenario: Sign up for an existing user - Given I am on the sign up page + Given I visit sign up page And I sign up as "existent-user1@example.com" with password "pppppppp" and password confirmation "pppppppp" Then I should see "Email has already been taken" And I should not receive an email @email Scenario: Sign up for an non-existent user with non-matching password confirmation - Given I am on the sign up page + Given I visit sign up page And I sign up as "existent-user2@example.com" with password "pppppppp" and password confirmation "aaaaaaaa" Then I should see "Password doesn't match confirmation" And I should not receive an email @email Scenario: Sign up for a non-existent user - Given I am on the sign up page + Given I visit sign up page And I sign up as "non-existent-user@example.com" with password "pppppppp" and password confirmation "pppppppp" Then I should be on the home page And I should see "A message with a confirmation link has been sent to your email address. Please open the link to activate your account." diff --git a/features/sign_in_sign_up/sign_up_link_to_org.feature b/features/sign_in_sign_up/sign_up_link_to_org.feature index 5ce43b15e..3f41bd44a 100644 --- a/features/sign_in_sign_up/sign_up_link_to_org.feature +++ b/features/sign_in_sign_up/sign_up_link_to_org.feature @@ -11,14 +11,14 @@ Feature: If new user's email matches an org's email, the new user with have edit And cookies are approved Scenario: Sign up and CANNOT edit - Given I am on the sign up page + Given I visit sign up page And I sign up as "tester@friendly.org" with password "12345678" and password confirmation "12345678" And I sign in as "tester@friendly.org" with password "12345678" via email confirmation And I am on the charity page for "Friendly" Then I should not see an edit button for "Friendly" charity Scenario: Sign up and can edit - Given I am on the sign up page + Given I visit sign up page And I sign up as "info@friendly.org" with password "12345678" and password confirmation "12345678" And I sign in as "info@friendly.org" with password "12345678" via email confirmation And I am on the charity page for "Friendly" diff --git a/features/step_definitions/authentication_steps.rb b/features/step_definitions/authentication_steps.rb index f11519d58..3fe11730a 100644 --- a/features/step_definitions/authentication_steps.rb +++ b/features/step_definitions/authentication_steps.rb @@ -29,7 +29,7 @@ And /^I am signed in as the admin using password "(.*?)"$/ do |password| admin = User.find_by_admin(true) steps %Q{ - Given I am on the sign in page + Given I visit the sign in page And I sign in as "#{admin.email}" with password "#{password}" } end @@ -37,7 +37,7 @@ And /^I am not signed in as the admin using password "(.*?)"$/ do |password| admin = User.find_by_admin(false) steps %Q{ - Given I am on the sign in page + Given I visit the sign in page And I sign in as "#{admin.email}" with password "#{password}" } end @@ -66,7 +66,7 @@ Then /^I should not be signed in as any user$/ do steps %Q{ - Given I am on the new charity page + Given I visit the new organisation page Then I should not see "Signed in as" } end @@ -81,8 +81,8 @@ click_link_or_button "Sign in" end -Given /^I am on the sign up page$/ do - step "I am on the home page" +Given /^I visit the sign up page$/ do + step "I visit the home page" expect(page).to have_field('signup_email') expect(page).to have_field('signup_password') expect(page).to have_button('signup') @@ -96,7 +96,7 @@ user = User.find_by_email("#{email}") user.confirm! steps %Q{ - Given I am on the home page + Given I visit the home page And I sign in as "#{email}" with password "#{password}" } end diff --git a/features/step_definitions/navigation_steps.rb b/features/step_definitions/navigation_steps.rb index 50379d7d9..c4aea6b39 100644 --- a/features/step_definitions/navigation_steps.rb +++ b/features/step_definitions/navigation_steps.rb @@ -1,6 +1,3 @@ -Given /^I am on the home page$/ do - visit "/" -end And /^I select the "(.*?)" category$/ do |category| select(category, :from => "category[id]") end @@ -9,26 +6,34 @@ visit path end -def paths +def paths(location, params = {}) { - 'home' => root_path, - 'sign up' => new_user_registration_path, - 'sign in' => new_user_session_path, - 'organisations index' => organizations_path, - 'contributors' => contributors_path, - 'password reset' => edit_user_password_path, - 'invitation' => accept_user_invitation_path, - 'organisations without users' => organizations_report_path, - 'all users' => users_report_path, - 'invited users' => invited_users_report_path, - 'volunteer opportunities' => volunteer_ops_path - } -end - -Then /^I visit the (.*) page$/ do |location| - location = location.downcase - raise "No matching path found for #{location}" if paths[location].nil? - visit paths[location] + 'home' => root_path(params), + 'sign up' => new_user_registration_path(params), + 'sign in' => new_user_session_path(params), + 'organisations index' => organizations_path(params), + 'contributors' => contributors_path(params), + 'password reset' => edit_user_password_path(params), + 'invitation' => accept_user_invitation_path(params), + 'organisations without users' => organizations_report_path(params), + 'all users' => users_report_path(params), + 'invited users' => invited_users_report_path(params), + 'volunteer opportunities' => volunteer_ops_path(params), + 'new organisation' => new_organization_path(params) + }[location] +end + +Then /^I visit the (.*) page?$/ do |location| + location.downcase! + raise "No matching path found for #{location}" if paths(location).nil? + visit paths(location) +end + +Then /^I visit the (.*) page with params:$/ do |location, table| + params = Hash[table.rows] + location.downcase! + raise "No matching path found for #{location}" if paths(location).nil? + visit paths(location, params) end Then /^I visit the (.*) page for organization "(.*?)"$/ do |location, organization| @@ -121,10 +126,6 @@ def paths } end -Given /^I am on the new charity page$/ do - visit new_organization_path -end - Then /^I should be on the new charity page$/ do current_path.should == new_organization_path end diff --git a/spec/requests/organizations_spec.rb b/spec/requests/organizations_spec.rb index 81e81cfa1..ae84c540e 100644 --- a/spec/requests/organizations_spec.rb +++ b/spec/requests/organizations_spec.rb @@ -5,5 +5,11 @@ it "works! (now write some real specs)" do get organizations_path end + + it 'test' do + get edit_user_password_path + debugger + puts 'hi' + end end end From cefe6a3e6aa3f4f943993f5d17f8a75666413673 Mon Sep 17 00:00:00 2001 From: johnnymo87 Date: Thu, 24 Apr 2014 18:37:12 +0100 Subject: [PATCH 02/14] matcher for edit|show page for given object with given name --- features/admin/admin_new_charity.feature | 2 +- .../individual_charity_pages/charity_page.feature | 7 +------ .../individual_charity_pages/donation_info.feature | 8 +------- .../edit_own_charity_profile.feature | 14 +++++++------- .../this-is-my-org.feature | 6 +++--- .../sign_in_sign_up/sign_up_link_to_org.feature | 4 ++-- features/step_definitions/authentication_steps.rb | 6 +----- features/step_definitions/navigation_steps.rb | 8 +++++++- .../create_volunteer_opportunities.feature | 2 +- spec/requests/organizations_spec.rb | 6 ------ 10 files changed, 24 insertions(+), 39 deletions(-) diff --git a/features/admin/admin_new_charity.feature b/features/admin/admin_new_charity.feature index ac9e27feb..d965f0131 100644 --- a/features/admin/admin_new_charity.feature +++ b/features/admin/admin_new_charity.feature @@ -36,7 +36,7 @@ Feature: Admin creating charity Scenario: Successfully create charity while being signed-in as admin from arbitrary page Given I am signed in as a admin - Given I am on the charity page for "Friendly Clone" + Given I visit the show page for the organization named "Friendly Clone" And I follow "New Organisation" And I fill in the new charity page validly And I press "Create Organisation" diff --git a/features/individual_charity_pages/charity_page.feature b/features/individual_charity_pages/charity_page.feature index ab8fd60cf..e531e7a8b 100644 --- a/features/individual_charity_pages/charity_page.feature +++ b/features/individual_charity_pages/charity_page.feature @@ -9,26 +9,22 @@ Feature: Web page owned by each charity | name | description | address | postcode | telephone | website | email | | Friendly | Bereavement Counselling | 34 pinner road | HA1 4HZ | 020800000 | http://friendly.org | admin@friendly.xx | | Friendly Clone | Quite Friendly! | 30 pinner road | | 020800010 | | | - Given the following users are registered: | email | password | organization | confirmed_at | | registered_user-1@example.com | pppppppp | Friendly | 2007-01-01 10:00:00 | | registered_user-2@example.com | pppppppp | | 2007-01-01 10:00:00 | + And I visit the show page for the organization named "Friendly" Scenario: be able to view link to charity site on individual charity page - Given I am on the charity page for "Friendly" Then I should see the external website link for "Friendly" charity Scenario: display charity title in a visible way - Given I am on the charity page for "Friendly" Then I should see "Friendly" < tagged > with "h3" Scenario: show organization e-mail as link - Given I am on the charity page for "Friendly" Then I should see a mail-link to "admin@friendly.xx" Scenario Outline: show labels if field is present - Given I am on the charity page for "Friendly" Then I should see "