diff --git a/.rubocop.yml b/.rubocop.yml index acc47b92e..e0429c99f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -20,6 +20,9 @@ Bundler/OrderedGems: Enabled: true ConsiderPunctuation: true +Capybara/ClickLinkOrButtonStyle: + Enabled: true + Capybara/CurrentPathExpectation: Enabled: true diff --git a/spec/shared/system/mappable.rb b/spec/shared/system/mappable.rb index 51a3c4305..d687d5768 100644 --- a/spec/shared/system/mappable.rb +++ b/spec/shared/system/mappable.rb @@ -197,7 +197,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, visit send(mappable_edit_path, id: mappable.id) find(".map-location").click - click_on("Save changes") + click_button "Save changes" mappable.reload expect(page).to have_css(".map-location") @@ -210,7 +210,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, visit send(mappable_edit_path, id: mappable.id) fill_in "#{mappable_factory_name.camelize} title", with: "New title" - click_on("Save changes") + click_button "Save changes" mappable.reload expect(page).to have_css(".map-location") @@ -223,7 +223,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, visit send(mappable_edit_path, id: mappable.id) click_button "Remove map marker" - click_on "Save changes" + click_button "Save changes" expect(page).not_to have_css(".map-location") end @@ -234,7 +234,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, visit send(mappable_edit_path, id: mappable.id) fill_in "#{mappable_factory_name.camelize} title", with: "New title" - click_on("Save changes") + click_button "Save changes" expect(page).not_to have_css(".map-location") end @@ -244,7 +244,7 @@ shared_examples "mappable" do |mappable_factory_name, mappable_association_name, visit send(mappable_edit_path, id: mappable.id) click_button "Remove map marker" - click_on "Save changes" + click_button "Save changes" expect(page).not_to have_content "Map location can't be blank" end diff --git a/spec/shared/system/nested_documentable.rb b/spec/shared/system/nested_documentable.rb index 441330b57..c45e6c053 100644 --- a/spec/shared/system/nested_documentable.rb +++ b/spec/shared/system/nested_documentable.rb @@ -161,7 +161,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na visit send(path, arguments) click_link "Add new document" - click_on submit_button + click_button submit_button within "#nested-documents .document-fields" do expect(page).to have_content("can't be blank", count: 2) @@ -184,7 +184,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na visit send(path, arguments) send(fill_resource_method_name) if fill_resource_method_name - click_on submit_button + click_button submit_button expect(page).to have_content documentable_success_notice end @@ -196,7 +196,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na send(fill_resource_method_name) if fill_resource_method_name documentable_attach_new_file(file_fixture("empty.pdf")) - click_on submit_button + click_button submit_button expect(page).to have_content documentable_success_notice end @@ -208,7 +208,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na send(fill_resource_method_name) if fill_resource_method_name documentable_attach_new_file(file_fixture("empty.pdf")) - click_on submit_button + click_button submit_button expect(page).to have_content documentable_success_notice @@ -233,7 +233,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na documentable_attach_new_file(file_fixture("#{filename}.pdf")) end - click_on submit_button + click_button submit_button expect(page).to have_content documentable_success_notice @@ -266,7 +266,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na visit send(path, arguments) last_document = all("#nested-documents .document-fields").last within last_document do - click_on "Remove document" + click_link "Remove document" end expect(page).to have_link id: "new_document_link" @@ -276,7 +276,7 @@ shared_examples "nested documentable" do |login_as_name, documentable_factory_na create(:document, documentable: documentable) do_login_for user_to_login, management: management visit send(path, arguments) - click_on "Remove document" + click_link "Remove document" expect(page).not_to have_css ".document-fields" end diff --git a/spec/shared/system/nested_imageable.rb b/spec/shared/system/nested_imageable.rb index 52be887d2..d75404e8a 100644 --- a/spec/shared/system/nested_imageable.rb +++ b/spec/shared/system/nested_imageable.rb @@ -28,7 +28,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p do_login_for user, management: management visit send(path, arguments) - click_on "Add image" + click_link "Add image" expect(page).not_to have_css "#new_image_link" end @@ -117,7 +117,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p visit send(path, arguments) click_link "Add image" - click_on submit_button + click_button submit_button within "#nested-image .image-fields" do expect(page).to have_content("can't be blank", count: 2) @@ -131,7 +131,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p imageable_attach_new_file(file_fixture("clippy.jpg")) within_fieldset("Descriptive image") { fill_in "Title", with: "" } - click_on submit_button + click_button submit_button expect(page).to have_content "can't be blank" expect(page).to have_css "img[src$='clippy.jpg']" @@ -156,7 +156,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p visit send(path, arguments) send(fill_resource_method_name) if fill_resource_method_name - click_on submit_button + click_button submit_button expect(page).to have_content imageable_success_notice end @@ -169,7 +169,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p expect(page).to have_css ".loading-bar.complete" - click_on submit_button + click_button submit_button expect(page).to have_content imageable_success_notice end @@ -183,7 +183,7 @@ shared_examples "nested imageable" do |imageable_factory_name, path, imageable_p expect(page).to have_css ".loading-bar.complete" - click_on submit_button + click_button submit_button expect(page).to have_content imageable_success_notice diff --git a/spec/support/common_actions/documents.rb b/spec/support/common_actions/documents.rb index e7752ad84..b0936646d 100644 --- a/spec/support/common_actions/documents.rb +++ b/spec/support/common_actions/documents.rb @@ -1,7 +1,7 @@ module Documents def documentable_redirected_to_resource_show_or_navigate_to find("a", text: "Not now, go to my proposal") - click_on "Not now, go to my proposal" + click_link "Not now, go to my proposal" rescue nil end diff --git a/spec/support/common_actions/images.rb b/spec/support/common_actions/images.rb index 1c7a248e1..33a3d5aa3 100644 --- a/spec/support/common_actions/images.rb +++ b/spec/support/common_actions/images.rb @@ -4,7 +4,7 @@ module Images when "Budget" visit edit_admin_budget_path(Budget.last) when "Proposal" - click_on "Not now, go to my proposal" rescue Capybara::ElementNotFound + click_link "Not now, go to my proposal" rescue Capybara::ElementNotFound end end diff --git a/spec/system/admin/budget_phases_spec.rb b/spec/system/admin/budget_phases_spec.rb index 42faabae8..5ccbce3d3 100644 --- a/spec/system/admin/budget_phases_spec.rb +++ b/spec/system/admin/budget_phases_spec.rb @@ -53,7 +53,7 @@ describe "Admin budget phases" do imageable_attach_new_file(file_fixture("clippy.jpg")) - click_on "Save changes" + click_button "Save changes" expect(page).to have_content "Changes saved" end diff --git a/spec/system/admin/emails/newsletters_spec.rb b/spec/system/admin/emails/newsletters_spec.rb index ed1ebdbee..ed5dd7d08 100644 --- a/spec/system/admin/emails/newsletters_spec.rb +++ b/spec/system/admin/emails/newsletters_spec.rb @@ -104,7 +104,7 @@ describe "Admin newsletter emails", :admin do confirmation = "Are you sure? This action will delete \"#{newsletter.subject}\" and can't be undone." within("#newsletter_#{newsletter.id}") do - accept_confirm(confirmation) { click_link_or_button "Delete" } + accept_confirm(confirmation) { click_button "Delete" } end expect(page).to have_content "Newsletter deleted successfully" diff --git a/spec/system/admin/legislation/questions_spec.rb b/spec/system/admin/legislation/questions_spec.rb index 0fbe2a9ab..ed39d2f55 100644 --- a/spec/system/admin/legislation/questions_spec.rb +++ b/spec/system/admin/legislation/questions_spec.rb @@ -143,7 +143,7 @@ describe "Admin legislation questions", :admin do scenario "Add translation for question option" do visit edit_question_url - click_on "Add option" + click_link "Add option" find("#nested_question_options input").set("Option 1") @@ -166,7 +166,7 @@ describe "Admin legislation questions", :admin do select "Español", from: :select_language - click_on "Add option" + click_link "Add option" find("#nested_question_options input").set("Opción 1") diff --git a/spec/system/admin/local_census_records_spec.rb b/spec/system/admin/local_census_records_spec.rb index d88083705..93bb19096 100644 --- a/spec/system/admin/local_census_records_spec.rb +++ b/spec/system/admin/local_census_records_spec.rb @@ -61,7 +61,7 @@ describe "Admin local census records", :admin do visit admin_local_census_records_path fill_in :search, with: "X66777888" - click_on "Search" + click_button "Search" expect(page).to have_content "X66777888" expect(page).not_to have_content local_census_record.document_number @@ -73,7 +73,7 @@ describe "Admin local census records", :admin do scenario "Should show validation errors" do visit new_admin_local_census_record_path - click_on "Save" + click_button "Save" expect(page).to have_content "4 errors prevented this Local Census Record from being saved." expect(page).to have_content "can't be blank", count: 4 @@ -88,7 +88,7 @@ describe "Admin local census records", :admin do select "July", from: :local_census_record_date_of_birth_2i select "7", from: :local_census_record_date_of_birth_3i fill_in :local_census_record_postal_code, with: "07003" - click_on "Save" + click_button "Save" expect(page).to have_content "New local census record created successfully!" expect(page).to have_content "DNI" @@ -105,7 +105,7 @@ describe "Admin local census records", :admin do visit edit_admin_local_census_record_path(local_census_record) fill_in :local_census_record_document_number, with: "" - click_on "Save" + click_button "Save" expect(page).to have_content "1 error prevented this Local Census Record from being saved." expect(page).to have_content "can't be blank", count: 1 @@ -120,7 +120,7 @@ describe "Admin local census records", :admin do select "August", from: :local_census_record_date_of_birth_2i select "8", from: :local_census_record_date_of_birth_3i fill_in :local_census_record_postal_code, with: "07007" - click_on "Save" + click_button "Save" expect(page).to have_content "Local census record updated successfully!" expect(page).to have_content "Passport" @@ -142,7 +142,7 @@ describe "Admin local census records", :admin do confirmation = "Are you sure? This action will delete " \ "\"#{local_census_record.title}\" and can't be undone." - accept_confirm(confirmation) { click_on "Delete" } + accept_confirm(confirmation) { click_button "Delete" } expect(page).to have_content "Local census record removed successfully!" expect(page).not_to have_content deleted_document_number diff --git a/spec/system/admin/organizations_spec.rb b/spec/system/admin/organizations_spec.rb index 6020ccd5a..36e88364a 100644 --- a/spec/system/admin/organizations_spec.rb +++ b/spec/system/admin/organizations_spec.rb @@ -107,7 +107,7 @@ describe "Admin::Organizations" do visit admin_organizations_path - click_on "Verified" + click_link "Verified" within("#organization_#{organization.id}") do expect(page).to have_content "Verified" @@ -119,7 +119,7 @@ describe "Admin::Organizations" do expect(page).to have_current_path(admin_organizations_path, ignore_query: true) expect(page).not_to have_content organization.name - click_on "Rejected" + click_link "Rejected" within "tr", text: organization.name do expect(page).to have_content "Rejected" @@ -130,7 +130,7 @@ describe "Admin::Organizations" do organization = create(:organization, :rejected) visit admin_organizations_path - click_on "Rejected" + click_link "Rejected" within("#organization_#{organization.id}") do expect(page).to have_button "Verify" @@ -140,7 +140,7 @@ describe "Admin::Organizations" do end expect(page).to have_current_path(admin_organizations_path, ignore_query: true) expect(page).not_to have_content organization.name - click_on("Verified") + click_link "Verified" within "tr", text: organization.name do expect(page).to have_content "Verified" diff --git a/spec/system/admin/settings_spec.rb b/spec/system/admin/settings_spec.rb index f5da37d3e..8639a1820 100644 --- a/spec/system/admin/settings_spec.rb +++ b/spec/system/admin/settings_spec.rb @@ -78,7 +78,7 @@ describe "Admin settings", :admin do click_link "Map configuration" within "#map-form" do - click_on "Update" + click_button "Update" end expect(page).to have_content "Map configuration updated successfully" @@ -100,7 +100,7 @@ describe "Admin settings", :admin do click_link "Map configuration" find("#admin-map").click within "#map-form" do - click_on "Update" + click_button "Update" end expect(find("#latitude", visible: :hidden).value).not_to eq "51.48" diff --git a/spec/system/admin/system_emails_spec.rb b/spec/system/admin/system_emails_spec.rb index a2786207b..c2cf3e26c 100644 --- a/spec/system/admin/system_emails_spec.rb +++ b/spec/system/admin/system_emails_spec.rb @@ -328,7 +328,7 @@ describe "System Emails" do visit admin_system_email_preview_pending_path("proposal_notification_digest") within("#proposal_notification_#{proposal_notification1.id}") do - click_on "Moderate notification send" + click_link "Moderate notification send" end expect(page).not_to have_content("Proposal A Title") diff --git a/spec/system/admin/tags_spec.rb b/spec/system/admin/tags_spec.rb index 2868a2726..5406757db 100644 --- a/spec/system/admin/tags_spec.rb +++ b/spec/system/admin/tags_spec.rb @@ -40,7 +40,7 @@ describe "Admin tags", :admin do within("#tag_#{tag2.id}") do accept_confirm("Are you sure? This action will delete \"Bad tag\" and can't be undone.") do - click_link_or_button "Delete" + click_button "Delete" end end @@ -60,7 +60,7 @@ describe "Admin tags", :admin do within("#tag_#{tag2.id}") do accept_confirm("Are you sure? This action will delete \"Bad tag\" and can't be undone.") do - click_link_or_button "Delete" + click_button "Delete" end end diff --git a/spec/system/home_spec.rb b/spec/system/home_spec.rb index 8e12ba1a8..3234d9178 100644 --- a/spec/system/home_spec.rb +++ b/spec/system/home_spec.rb @@ -92,7 +92,7 @@ describe "Home" do visit root_path within("#section_recommended") do - click_on debate.title + click_link debate.title end expect(page).to have_current_path(debate_path(debate)) diff --git a/spec/system/moderation/budget_investments_spec.rb b/spec/system/moderation/budget_investments_spec.rb index d4d7aa0e1..a029c10e4 100644 --- a/spec/system/moderation/budget_investments_spec.rb +++ b/spec/system/moderation/budget_investments_spec.rb @@ -109,11 +109,11 @@ describe "Moderate budget investments" do visit moderation_budget_investments_path - within(".js-check") { click_on "All" } + within(".js-check") { click_link "All" } expect(all("input[type=checkbox]")).to all(be_checked) - within(".js-check") { click_on "None" } + within(".js-check") { click_link "None" } all("input[type=checkbox]").each do |checkbox| expect(checkbox).not_to be_checked diff --git a/spec/system/moderation/comments_spec.rb b/spec/system/moderation/comments_spec.rb index 0c980b247..ebadfdd18 100644 --- a/spec/system/moderation/comments_spec.rb +++ b/spec/system/moderation/comments_spec.rb @@ -129,11 +129,11 @@ describe "Moderate comments" do visit moderation_comments_path - within(".js-check") { click_on "All" } + within(".js-check") { click_link "All" } expect(all("input[type=checkbox]")).to all(be_checked) - within(".js-check") { click_on "None" } + within(".js-check") { click_link "None" } all("input[type=checkbox]").each do |checkbox| expect(checkbox).not_to be_checked diff --git a/spec/system/moderation/debates_spec.rb b/spec/system/moderation/debates_spec.rb index ba64470dd..ba1bb6d1e 100644 --- a/spec/system/moderation/debates_spec.rb +++ b/spec/system/moderation/debates_spec.rb @@ -98,11 +98,11 @@ describe "Moderate debates" do visit moderation_debates_path - within(".js-check") { click_on "All" } + within(".js-check") { click_link "All" } expect(all("input[type=checkbox]")).to all(be_checked) - within(".js-check") { click_on "None" } + within(".js-check") { click_link "None" } all("input[type=checkbox]").each do |checkbox| expect(checkbox).not_to be_checked diff --git a/spec/system/moderation/proposal_notifications_spec.rb b/spec/system/moderation/proposal_notifications_spec.rb index f609991d0..8aa490dbe 100644 --- a/spec/system/moderation/proposal_notifications_spec.rb +++ b/spec/system/moderation/proposal_notifications_spec.rb @@ -109,11 +109,11 @@ describe "Moderate proposal notifications" do visit moderation_proposal_notifications_path - within(".js-check") { click_on "All" } + within(".js-check") { click_link "All" } expect(all("input[type=checkbox]")).to all(be_checked) - within(".js-check") { click_on "None" } + within(".js-check") { click_link "None" } all("input[type=checkbox]").each do |checkbox| expect(checkbox).not_to be_checked diff --git a/spec/system/moderation/proposals_spec.rb b/spec/system/moderation/proposals_spec.rb index 8be434b17..e5c7861dc 100644 --- a/spec/system/moderation/proposals_spec.rb +++ b/spec/system/moderation/proposals_spec.rb @@ -97,11 +97,11 @@ describe "Moderate proposals" do visit moderation_proposals_path - within(".js-check") { click_on "All" } + within(".js-check") { click_link "All" } expect(all("input[type=checkbox]")).to all(be_checked) - within(".js-check") { click_on "None" } + within(".js-check") { click_link "None" } all("input[type=checkbox]").each do |checkbox| expect(checkbox).not_to be_checked diff --git a/spec/system/sdg_management_spec.rb b/spec/system/sdg_management_spec.rb index 7b7e6bfef..da14d7418 100644 --- a/spec/system/sdg_management_spec.rb +++ b/spec/system/sdg_management_spec.rb @@ -32,8 +32,8 @@ describe "SDGManagement" do login_as(user) visit root_path - click_on "Menu" - click_on "SDG content" + click_link "Menu" + click_link "SDG content" expect(page).to have_current_path(sdg_management_root_path) expect(page).to have_css ".sdg-content-menu"