Improve readability in some system specs
We're improving the readability of the ones we're about to modify. Using human texts makes tests easier to read and guarantees we're testing from the user's point of view. For instance, if we write `fill_in banner_target_url`, the test will pass even if the field has no label associated to it. However, `fill_in "Link"` makes sure there's a field with an associated label.
This commit is contained in:
@@ -17,9 +17,10 @@ module Emails
|
||||
end
|
||||
|
||||
def fill_in_newsletter_form(options = {})
|
||||
fill_in "newsletter_subject", with: (options[:subject] || "This is a different subject")
|
||||
select (options[:segment_recipient] || "All users"), from: "newsletter_segment_recipient"
|
||||
fill_in "newsletter_from", with: (options[:from] || "no-reply@consul.dev")
|
||||
fill_in "newsletter_body", with: (options[:body] || "This is a different body")
|
||||
select (options[:segment_recipient] || "All users"), from: "Recipients"
|
||||
fill_in "Subject", with: (options[:subject] || "This is a different subject")
|
||||
fill_in "E-mail address that will appear as sending the newsletter",
|
||||
with: (options[:from] || "no-reply@consul.dev")
|
||||
fill_in "Email content", with: (options[:body] || "This is a different body")
|
||||
end
|
||||
end
|
||||
|
||||
@@ -69,8 +69,6 @@ describe "Admin banners magement", :admin do
|
||||
end
|
||||
|
||||
scenario "Publish a banner" do
|
||||
section = WebSection.find_by(name: "proposals")
|
||||
|
||||
visit admin_root_path
|
||||
|
||||
within("#side_menu") do
|
||||
@@ -81,12 +79,12 @@ describe "Admin banners magement", :admin do
|
||||
|
||||
fill_in "Title", with: "Such banner"
|
||||
fill_in "Description", with: "many text wow link"
|
||||
fill_in "banner_target_url", with: "https://www.url.com"
|
||||
fill_in "post_started_at", with: Date.current - 7.days
|
||||
fill_in "post_ended_at", with: Date.current + 7.days
|
||||
fill_in "banner_background_color", with: "#850000"
|
||||
fill_in "banner_font_color", with: "#ffb2b2"
|
||||
check section.name.titleize
|
||||
fill_in "Link", with: "https://www.url.com"
|
||||
fill_in "Post started at", with: Date.current - 7.days
|
||||
fill_in "Post ended at", with: Date.current + 7.days
|
||||
fill_in "Background color", with: "#850000"
|
||||
fill_in "Font color", with: "#ffb2b2"
|
||||
within_fieldset("Sections where it will appear") { check "Proposals" }
|
||||
|
||||
click_button "Save changes"
|
||||
|
||||
|
||||
@@ -47,8 +47,8 @@ describe "Admin dashboard actions", :admin do
|
||||
end
|
||||
|
||||
scenario "Creates a new action" do
|
||||
fill_in "dashboard_action_title", with: action.title
|
||||
fill_in "dashboard_action_description", with: action.description
|
||||
fill_in "Title", with: action.title
|
||||
fill_in "Description", with: action.description
|
||||
|
||||
click_button "Save"
|
||||
|
||||
|
||||
@@ -40,7 +40,7 @@ describe "Admin settings", :admin do
|
||||
scenario "When `Map settings` tab content is shown map should be initialized" do
|
||||
visit admin_settings_path
|
||||
|
||||
find("#map-tab").click
|
||||
click_link "Map configuration"
|
||||
|
||||
expect(page).to have_css("#admin-map.leaflet-container")
|
||||
end
|
||||
@@ -51,7 +51,7 @@ describe "Admin settings", :admin do
|
||||
Setting["feature.map"] = false
|
||||
|
||||
visit admin_settings_path
|
||||
find("#map-tab").click
|
||||
click_link "Map configuration"
|
||||
|
||||
expect(page).to have_content "To show the map to users you must enable " \
|
||||
'"Proposals and budget investments geolocation" ' \
|
||||
@@ -63,7 +63,7 @@ describe "Admin settings", :admin do
|
||||
Setting["feature.map"] = true
|
||||
|
||||
visit admin_settings_path
|
||||
find("#map-tab").click
|
||||
click_link "Map configuration"
|
||||
|
||||
expect(page).to have_css("#admin-map")
|
||||
expect(page).not_to have_content "To show the map to users you must enable " \
|
||||
@@ -96,7 +96,7 @@ describe "Admin settings", :admin do
|
||||
Setting["feature.map"] = true
|
||||
|
||||
visit admin_settings_path
|
||||
find("#map-tab").click
|
||||
click_link "Map configuration"
|
||||
find("#admin-map").click
|
||||
within "#map-form" do
|
||||
click_on "Update"
|
||||
@@ -211,7 +211,7 @@ describe "Admin settings", :admin do
|
||||
map_setting = Setting.create!(key: "map.whatever")
|
||||
|
||||
visit admin_settings_path
|
||||
find("#map-tab").click
|
||||
click_link "Map configuration"
|
||||
|
||||
within("#edit_setting_#{map_setting.id}") do
|
||||
fill_in "setting_#{map_setting.id}", with: "New value"
|
||||
|
||||
@@ -373,9 +373,9 @@ describe "Emails" do
|
||||
login_as(valuator.user)
|
||||
visit edit_valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
choose "budget_investment_feasibility_unfeasible"
|
||||
fill_in "budget_investment_unfeasibility_explanation", with: "This is not legal as stated in Article 34.9"
|
||||
find_field("budget_investment[valuation_finished]").click
|
||||
within_fieldset("Feasibility") { choose "Unfeasible" }
|
||||
fill_in "Feasibility explanation", with: "This is not legal as stated in Article 34.9"
|
||||
check "Valuation finished"
|
||||
click_button "Save changes"
|
||||
|
||||
expect(page).to have_content "Dossier updated"
|
||||
|
||||
@@ -415,10 +415,14 @@ describe "Valuation budget investments" do
|
||||
login_as(admin.user)
|
||||
visit edit_valuation_budget_budget_investment_path(budget, investment)
|
||||
|
||||
expect(page).to have_selector("input[id='budget_investment_feasibility_undecided']")
|
||||
expect(page).to have_selector("textarea[id='budget_investment_unfeasibility_explanation']")
|
||||
expect(page).to have_selector("input[name='budget_investment[valuation_finished]']")
|
||||
expect(page).to have_button("Save changes")
|
||||
within_fieldset "Feasibility" do
|
||||
expect(page).to have_field "Undefined", type: :radio
|
||||
expect(page).to have_field "Feasible", type: :radio
|
||||
end
|
||||
|
||||
expect(page).to have_field "Feasibility explanation", type: :textarea
|
||||
expect(page).to have_field "Valuation finished", type: :checkbox
|
||||
expect(page).to have_button "Save changes"
|
||||
end
|
||||
|
||||
scenario "Valuators that are not admins cannot reopen or modify a finished valuation" do
|
||||
|
||||
Reference in New Issue
Block a user