Test data introduced from the user's point of view
Users don't care about database content; they care about what they see on the screen. Writing tests this way we also avoid potencial database inconsistencies due to accessing the database after starting the browser.
This commit is contained in:
@@ -186,7 +186,7 @@ describe "Admin collaborative legislation", :admin do
|
|||||||
|
|
||||||
expect(page).to have_content "An example legislation process"
|
expect(page).to have_content "An example legislation process"
|
||||||
expect(page).not_to have_content "Summary of the process"
|
expect(page).not_to have_content "Summary of the process"
|
||||||
expect(page).to have_css("img[alt='#{Legislation::Process.last.title}']")
|
expect(page).to have_css("img[alt='An example legislation process']")
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Default colors are present" do
|
scenario "Default colors are present" do
|
||||||
|
|||||||
@@ -2,16 +2,19 @@ require "rails_helper"
|
|||||||
|
|
||||||
describe "Admin Active polls", :admin do
|
describe "Admin Active polls", :admin do
|
||||||
scenario "Add" do
|
scenario "Add" do
|
||||||
expect(ActivePoll.first).to be nil
|
|
||||||
|
|
||||||
visit admin_polls_path
|
visit admin_polls_path
|
||||||
click_link "Polls description"
|
click_link "Polls description"
|
||||||
|
|
||||||
|
expect(page).to have_ckeditor "Description", with: ""
|
||||||
|
|
||||||
fill_in_ckeditor "Description", with: "Active polls description"
|
fill_in_ckeditor "Description", with: "Active polls description"
|
||||||
click_button "Save"
|
click_button "Save"
|
||||||
|
|
||||||
expect(page).to have_content "Polls description updated successfully."
|
expect(page).to have_content "Polls description updated successfully."
|
||||||
expect(ActivePoll.first.description).to eq "<p>Active polls description</p>\r\n"
|
|
||||||
|
click_link "Polls description"
|
||||||
|
|
||||||
|
expect(page).to have_ckeditor "Description", with: "Active polls description"
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Edit" do
|
scenario "Edit" do
|
||||||
|
|||||||
@@ -82,7 +82,10 @@ describe "Admin tags", :admin do
|
|||||||
click_button "Create topic"
|
click_button "Create topic"
|
||||||
end
|
end
|
||||||
|
|
||||||
expect(Tag.category.where(name: "wow_category")).to exist
|
within "tbody" do
|
||||||
|
expect(page).to have_content "Existence"
|
||||||
|
expect(page).to have_content "wow_category"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ describe "Cards", :admin do
|
|||||||
expect(page).to have_content "Card description"
|
expect(page).to have_content "Card description"
|
||||||
expect(page).to have_content "Link text"
|
expect(page).to have_content "Link text"
|
||||||
expect(page).to have_content "consul.dev"
|
expect(page).to have_content "consul.dev"
|
||||||
expect(page).to have_link "Show image", href: Widget::Card.last.image_url(:large)
|
expect(page).to have_link "Show image", title: "clippy.jpg"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -359,13 +359,12 @@ describe "Emails" do
|
|||||||
expect(page).to have_content "Investment created successfully"
|
expect(page).to have_content "Investment created successfully"
|
||||||
|
|
||||||
email = open_last_email
|
email = open_last_email
|
||||||
investment = Budget::Investment.last
|
|
||||||
|
|
||||||
expect(email).to have_subject("Thank you for creating an investment!")
|
expect(email).to have_subject("Thank you for creating an investment!")
|
||||||
expect(email).to deliver_to(investment.author.email)
|
expect(email).to deliver_to(author.email)
|
||||||
expect(email).to have_body_text(author.name)
|
expect(email).to have_body_text(author.name)
|
||||||
expect(email).to have_body_text(investment.title)
|
expect(email).to have_body_text("Build a hospital")
|
||||||
expect(email).to have_body_text(investment.budget.name)
|
expect(email).to have_body_text(budget.name)
|
||||||
expect(email).to have_body_text(budget_path(budget))
|
expect(email).to have_body_text(budget_path(budget))
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -383,12 +382,11 @@ describe "Emails" do
|
|||||||
click_button "Save changes"
|
click_button "Save changes"
|
||||||
|
|
||||||
expect(page).to have_content "Dossier updated"
|
expect(page).to have_content "Dossier updated"
|
||||||
investment.reload
|
|
||||||
|
|
||||||
email = open_last_email
|
email = open_last_email
|
||||||
expect(email).to have_subject("Your investment project '#{investment.code}' has been marked as unfeasible")
|
expect(email).to have_subject("Your investment project '#{investment.code}' has been marked as unfeasible")
|
||||||
expect(email).to deliver_to(investment.author.email)
|
expect(email).to deliver_to(investment.author.email)
|
||||||
expect(email).to have_body_text(investment.unfeasibility_explanation)
|
expect(email).to have_body_text "This is not legal as stated in Article 34.9"
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Selected investment" do
|
scenario "Selected investment" do
|
||||||
|
|||||||
@@ -152,7 +152,7 @@ describe "Legislation Proposals" do
|
|||||||
|
|
||||||
expect(page).to have_content "Legislation proposal with image"
|
expect(page).to have_content "Legislation proposal with image"
|
||||||
expect(page).to have_content "Including an image on a legislation proposal"
|
expect(page).to have_content "Including an image on a legislation proposal"
|
||||||
expect(page).to have_css("img[alt='#{Legislation::Proposal.last.image.title}']")
|
expect(page).to have_css "img[alt='clippy.jpg']"
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Show votes score on index and show" do
|
scenario "Show votes score on index and show" do
|
||||||
|
|||||||
@@ -99,12 +99,11 @@ describe "Managed User" do
|
|||||||
expect(page).to have_content "We have sent an email"
|
expect(page).to have_content "We have sent an email"
|
||||||
expect(page).not_to have_content "Autogenerated password is"
|
expect(page).not_to have_content "Autogenerated password is"
|
||||||
|
|
||||||
user = User.last
|
|
||||||
within(".account-info") do
|
within(".account-info") do
|
||||||
expect(page).to have_content "Identified as"
|
expect(page).to have_content "Identified as"
|
||||||
expect(page).to have_content user.username.to_s
|
expect(page).to have_content "pepe"
|
||||||
expect(page).to have_content user.email.to_s
|
expect(page).to have_content "pepe@gmail.com"
|
||||||
expect(page).to have_content user.document_number.to_s
|
expect(page).to have_content "12345678Z"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
@@ -127,11 +126,10 @@ describe "Managed User" do
|
|||||||
expect(page).not_to have_content "We have sent an email"
|
expect(page).not_to have_content "We have sent an email"
|
||||||
expect(page).to have_content "Autogenerated password is"
|
expect(page).to have_content "Autogenerated password is"
|
||||||
|
|
||||||
user = User.last
|
|
||||||
within(".account-info") do
|
within(".account-info") do
|
||||||
expect(page).to have_content "Identified as"
|
expect(page).to have_content "Identified as"
|
||||||
expect(page).to have_content user.username.to_s
|
expect(page).to have_content "peppa"
|
||||||
expect(page).to have_content user.document_number.to_s
|
expect(page).to have_content "12345678Z"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -446,7 +446,12 @@ describe "Proposals" do
|
|||||||
click_link "No, I want to publish the proposal"
|
click_link "No, I want to publish the proposal"
|
||||||
click_link "Not now, go to my proposal"
|
click_link "Not now, go to my proposal"
|
||||||
|
|
||||||
expect(Proposal.last.responsible_name).to eq("Isabel Garcia")
|
click_link "Dashboard"
|
||||||
|
click_link "Edit my proposal"
|
||||||
|
|
||||||
|
within_window(window_opened_by { click_link "Edit proposal" }) do
|
||||||
|
expect(page).to have_field "Full name of the person submitting the proposal", with: "Isabel Garcia"
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
scenario "Responsible name field is not shown for verified users" do
|
scenario "Responsible name field is not shown for verified users" do
|
||||||
|
|||||||
@@ -102,7 +102,9 @@ describe "Tags" do
|
|||||||
click_link "No, I want to publish the proposal"
|
click_link "No, I want to publish the proposal"
|
||||||
click_link "Not now, go to my proposal"
|
click_link "Not now, go to my proposal"
|
||||||
|
|
||||||
within "#tags_proposal_#{Proposal.last.id}" do
|
expect(page).to have_css "h1", exact_text: "Help refugees"
|
||||||
|
|
||||||
|
within ".tags" do
|
||||||
expect(page).to have_content "Education"
|
expect(page).to have_content "Education"
|
||||||
expect(page).not_to have_content "Health"
|
expect(page).not_to have_content "Health"
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user