Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
d6a8c51
commit e63b9fe
Showing
8 changed files
with
75 additions
and
128 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,105 +1,55 @@ | ||
# TODO | ||
Then /^I (should|should not) see the batch action "([^"]*)"$/ do |maybe, title| | ||
%{Then I #{maybe} see the batch action :#{title.gsub(' ','').gsub(" Selected", "").underscore} "#{title}"} | ||
end | ||
|
||
Then /^I (should|should not) be asked to confirm "([^"]*)" for "([^"]*)"$/ do |maybe, confirmation, title| | ||
within "#batch_actions_popover" do | ||
unless maybe == "should not" | ||
link = page.find "a.batch_action", :text => title | ||
link["data-confirm"].should match( confirmation ) | ||
else | ||
page.should_not have_css("a.batch_action", :text => title) | ||
end | ||
end | ||
selector = "#batch_actions_popover a.batch_action:contains('#{title}')" | ||
selector << "[data-confirm='#{confirmation}']" if maybe == 'should' | ||
page.send maybe.sub(' ', '_'), have_css(selector) | ||
end | ||
|
||
Then /^I (should|should not) see the batch action :([^\s]*) "([^"]*)"$/ do |maybe, sym, title| | ||
within "#batch_actions_selector" do | ||
unless maybe == "should not" | ||
link = page.find "a.batch_action", :text => title | ||
link["data-action"].should match( sym ) | ||
link[:href].should match( "#" ) | ||
else | ||
page.should_not have_css("a.batch_action", :text => title) | ||
end | ||
end | ||
selector = "#batch_actions_selector a.batch_action:contains('#{title}')" | ||
selector << "[href='#'][data-action='#{sym}']" if maybe == 'should' | ||
page.send maybe.sub(' ', '_'), have_css(selector) | ||
end | ||
|
||
Then /^the (\d+)(?:st|nd|rd|th) batch action should be "([^"]*)"$/ do |index, title| | ||
within "#batch_actions_selector" do | ||
page.all( "a.batch_action" )[index.to_i - 1].text.should match( title ) | ||
end | ||
page.all("#batch_actions_selector a.batch_action")[index.to_i - 1].text.should match title | ||
end | ||
|
||
When /^I check the (\d+)(?:st|nd|rd|th) record$/ do |index| | ||
page.all( "table.index_table input[type=checkbox]" )[index.to_i].set( true ) | ||
end | ||
|
||
When /^I uncheck the (\d+)(?:st|nd|rd|th) record$/ do |index| | ||
page.all( "table.index_table input[type='checkbox']" )[index.to_i].set( false ) | ||
page.all("table.index_table input[type=checkbox]")[index.to_i].set true | ||
end | ||
|
||
When /^I toggle the collection selection$/ do | ||
toggle_box = page.find( "#collection_selection_toggle_all" ) | ||
toggle_box.click | ||
end | ||
|
||
Then /^I should see (\d+) record(?:s)? selected$/ do |count| | ||
within "table.index_table" do | ||
unless count.to_i == 0 | ||
page.should have_xpath(".//input[@type='checkbox' and @checked='checked']", :count => count) | ||
else | ||
page.should have_no_xpath(".//input[@type='checkbox' and @checked='checked']") | ||
end | ||
end | ||
page.find("#collection_selection_toggle_all").click | ||
end | ||
|
||
Then /^I should see that the batch action button is disabled$/ do | ||
page.should have_css("#batch_actions_selector .dropdown_menu_button.disabled") | ||
end | ||
|
||
Then /^I (should|should not) see the batch action button$/ do |maybe| | ||
if maybe == "should not" | ||
page.should_not have_css("div.table_tools #batch_actions_selector .dropdown_menu_button") | ||
else | ||
page.should have_css("div.table_tools #batch_actions_selector .dropdown_menu_button") | ||
end | ||
page.should have_css "#batch_actions_selector .dropdown_menu_button.disabled" | ||
end | ||
|
||
Then "I should not see the batch actions selector" do | ||
page.should_not have_css("div.table_tools #batch_actions_selector") | ||
Then /^I (should|should not) see the batch action (button|selector)$/ do |maybe, type| | ||
selector = "div.table_tools #batch_actions_selector" | ||
selector << ' .dropdown_menu_button' if maybe == 'should' && type == 'button' | ||
page.send maybe.sub(' ', '_'), have_css(selector) | ||
end | ||
|
||
Then /^I should see the batch action popover exists$/ do | ||
page.should have_css("#batch_actions_selector") | ||
page.should have_css "#batch_actions_selector" | ||
end | ||
|
||
Given /^I submit the batch action form with "([^"]*)"$/ do |action| | ||
page.find(:css, "#batch_action").set(action) | ||
|
||
within("#main_content") do | ||
@params = page.all("input").reduce({}) do |acc, input| | ||
param_key = input['name'] | ||
param_value = input['value'] | ||
|
||
if param_key == 'collection_selection[]' | ||
# the collection_selection should be sent as an array containing only IDs of checked rows | ||
acc[param_key] ||= Array.new | ||
acc[param_key] << param_value if input.checked? | ||
else | ||
# other inputs, just send the value normally | ||
acc.store(param_key, param_value) | ||
end | ||
acc | ||
page.find("#batch_action").set action | ||
form = page.find "#collection_selection" | ||
params = page.all("#main_content input").each_with_object({}) do |input, obj| | ||
key, value = input['name'], input['value'] | ||
if key == 'collection_selection[]' | ||
(obj[key] ||= []).push value if input.checked? | ||
else | ||
obj[key] = value | ||
end | ||
end | ||
|
||
form = page.find("#collection_selection") | ||
|
||
page.driver.submit(form['method'].to_sym, form['action'], @params) | ||
page.driver.submit form['method'], form['action'], params | ||
end | ||
|
||
Then /^I should not see checkboxes in the table$/ do | ||
page.should_not have_css( ".paginated_collection table input[type=checkbox]" ) | ||
page.should_not have_css ".paginated_collection table input[type=checkbox]" | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
e63b9fe
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
FYI for anyone that's running into failing tests as of this commit, you need to remove the old rails test app so it can be recreated: