diff --git a/features/issues/copy_with_watchers.feature b/features/issues/copy_with_watchers.feature index 0ba218edef..cb22e8e3fc 100644 --- a/features/issues/copy_with_watchers.feature +++ b/features/issues/copy_with_watchers.feature @@ -23,26 +23,26 @@ Feature: Copying an issue should copy the watchers | name | is_default | | New | true | And the user "lrrr" has 1 issue with the following: - | subject | Improve sex drive | - | description | Acquire human horn | - And the issue "Improve sex drive" is watched by: + | subject | Improve drive | + | description | Acquire horn | + And the issue "Improve drive" is watched by: | lrrr | | ndnd | Scenario: Watchers shouldn't be copied when the user doesn't have the permission to Given I am logged in as "ndnd" - When I go to the copy page for the issue "Improve sex drive" + When I go to the copy page for the issue "Improve drive" Then I should not see "Watchers" - When I fill in "issue_subject" with "Improve sex drive even more" - When I click on "Create" + When I fill in "issue_subject" with "Improve drive even more" + When I click on the first button matching "Create" Then I should not see "Watchers" - And the issue "Improve sex drive even more" should have 0 watchers + And the issue "Improve drive even more" should have 0 watchers Scenario: Watchers should be copied when the user has the permission to Given I am logged in as "lrrr" - When I go to the copy page for the issue "Improve sex drive" + When I go to the copy page for the issue "Improve drive" Then I should see "Watchers" within "p#watchers_form" - When I fill in "issue_subject" with "Improve sex drive even more" - When I click on "Create" + When I fill in "issue_subject" with "Improve drive even more" + When I click on the first button matching "Create" Then I should see "Watchers (2)" - And the issue "Improve sex drive even more" should have 2 watchers + And the issue "Improve drive even more" should have 2 watchers diff --git a/features/step_definitions/general_steps.rb b/features/step_definitions/general_steps.rb index 3b3dfa5f55..1c16994e99 100644 --- a/features/step_definitions/general_steps.rb +++ b/features/step_definitions/general_steps.rb @@ -59,21 +59,10 @@ Given /^I am already logged in as "(.+?)"$/ do |login| end end -def login_user(username, password = "admin") - steps %Q{ - Given I am on the logout page - When I go to the login page - And I fill in "#{username}" for "username" - And I fill in "#{password}" for "password" - And I press "Login" - Then I should be logged in as "#{username}" - } -end - Given /^(?:|I )am logged in as "([^\"]*)"$/ do |username| - FactoryGirl.create(:admin) unless User.find_by_login("admin") - FactoryGirl.create(:anonymous) unless AnonymousUser.count > 0 - login_user(username) + FactoryGirl.create :admin unless User.where(:login => 'admin').any? + FactoryGirl.create :anonymous unless AnonymousUser.count > 0 + login(username, 'admin') end Given /^there is 1 [pP]roject with(?: the following)?:$/ do |table| @@ -410,7 +399,7 @@ end When /^(?:|I )login as (.+)? with password (.+)?$/ do |username, password| username = username.gsub("\"", "") password = password.gsub("\"", "") - login_user(username, password) + login(username, password) end Then /^I should be logged in as "([^\"]*)"?$/ do |username| diff --git a/features/step_definitions/web_steps.rb b/features/step_definitions/web_steps.rb index 003bcffeaf..58fa7c871a 100644 --- a/features/step_definitions/web_steps.rb +++ b/features/step_definitions/web_steps.rb @@ -350,6 +350,11 @@ Given /^I (accept|dismiss) the alert dialog$/ do |method| end end +# that's capybara's old behaviour: clicking the first button that matches +When /^(?:|I )click on the first button matching "([^"]*)"$/ do |button| + first(:button, button).click +end + def find_lowest_containing_element text, selector elements = [] diff --git a/features/step_definitions/wiki_steps.rb b/features/step_definitions/wiki_steps.rb index 9788226dcd..a316e103e9 100644 --- a/features/step_definitions/wiki_steps.rb +++ b/features/step_definitions/wiki_steps.rb @@ -1,3 +1,7 @@ +Given /^there are no wiki menu items$/ do + WikiMenuItem.destroy_all +end + Given /^the project "(.*?)" has (?:1|a) wiki menu item with the following:$/ do |project_name, table| item = FactoryGirl.build(:wiki_menu_item) send_table_to_object(item, table) @@ -18,13 +22,13 @@ Given /^the project "(.*?)" has a child wiki page of "(.*?)" with the following: wikipage.save! end -Then /^the table of contents wiki menu item within the "(.*?)" menu item should be selected$/ do |parent_item_name| +Then /^the table of contents wiki menu item inside the "(.*?)" menu item should be selected$/ do |parent_item_name| parent_item = WikiMenuItem.find_by_title(parent_item_name) page.should have_css(".#{parent_item.item_class}-toc.selected") end -Then /^the child page wiki menu item within the "(.*?)" menu item should be selected$/ do |parent_item_name| +Then /^the child page wiki menu item inside the "(.*?)" menu item should be selected$/ do |parent_item_name| parent_item = WikiMenuItem.find_by_title(parent_item_name) page.should have_css(".#{parent_item.item_class}-new-page.selected") diff --git a/features/wiki/breadcrumb.feature b/features/wiki/breadcrumb.feature index d6771fd853..3f102f59e1 100644 --- a/features/wiki/breadcrumb.feature +++ b/features/wiki/breadcrumb.feature @@ -1,6 +1,7 @@ Feature: Wiki menu items Background: - Given there is 1 project with the following: + Given there are no wiki menu items + And there is 1 project with the following: | name | Awesome Project | | identifier | awesome-project | And there is a role "member" diff --git a/features/wiki/wiki_index.feature b/features/wiki/wiki_index.feature index b14d0f2ba8..1f943f1025 100644 --- a/features/wiki/wiki_index.feature +++ b/features/wiki/wiki_index.feature @@ -1,7 +1,8 @@ Feature: Viewing the wiki index page Background: - Given there is 1 user with the following: + Given there are no wiki menu items + And there is 1 user with the following: | login | bob | And there is a role "member" And the role "member" may have the following rights: @@ -25,7 +26,7 @@ Feature: Viewing the wiki index page | index_page | true | When I go to the wiki index page below the "ParentWikiPage" page of the project called "project1" Then I should see "Index by title" within "#content" - And the table of contents wiki menu item within the "ParentWikiPage" menu item should be selected + And the table of contents wiki menu item inside the "ParentWikiPage" menu item should be selected Scenario: Visiting the wiki index page with a related page that has the index page option disabled on it's menu item should show the page and select no menu item Given the project "project1" has 1 wiki page with the following: diff --git a/features/wiki/wiki_new_child.feature b/features/wiki/wiki_new_child.feature index 7db666ba45..939d623975 100644 --- a/features/wiki/wiki_new_child.feature +++ b/features/wiki/wiki_new_child.feature @@ -1,7 +1,8 @@ Feature: Viewing the wiki new child page Background: - Given there is 1 user with the following: + Given there are no wiki menu items + And there is 1 user with the following: | login | bob | And there is a role "member" And the role "member" may have the following rights: @@ -21,7 +22,7 @@ Feature: Viewing the wiki new child page | new_wiki_page | true | When I go to the wiki new child page below the "ParentWikiPage" page of the project called "project1" Then I should see "Create new child page" within "#content" - And the child page wiki menu item within the "ParentWikiPage" menu item should be selected + And the child page wiki menu item inside the "ParentWikiPage" menu item should be selected Scenario: Visiting the wiki new child page with a related page that has the new child page option disabled on it's menu item should show the page and select no menu item Given the project "project1" has 1 wiki page with the following: