Add trait to simplify image creation in specs
This commit is contained in:
@@ -171,6 +171,10 @@ FactoryBot.define do
|
||||
trait :with_milestone_tags do
|
||||
after(:create) { |investment| investment.milestone_tags << create(:tag, :milestone) }
|
||||
end
|
||||
|
||||
trait :with_image do
|
||||
after(:create) { |investment| create(:image, imageable: investment) }
|
||||
end
|
||||
end
|
||||
|
||||
factory :budget_phase, class: "Budget::Phase" do
|
||||
|
||||
@@ -11,6 +11,10 @@ FactoryBot.define do
|
||||
description { "Milestone description" }
|
||||
publication_date { Date.current }
|
||||
|
||||
trait :with_image do
|
||||
after(:create) { |milestone| create(:image, imageable: milestone) }
|
||||
end
|
||||
|
||||
factory :milestone_with_description do
|
||||
status { nil }
|
||||
end
|
||||
|
||||
@@ -38,6 +38,10 @@ FactoryBot.define do
|
||||
trait :for_budget do
|
||||
association :budget
|
||||
end
|
||||
|
||||
trait :with_image do
|
||||
after(:create) { |poll| create(:image, imageable: poll) }
|
||||
end
|
||||
end
|
||||
|
||||
factory :poll_question, class: "Poll::Question" do
|
||||
|
||||
@@ -74,6 +74,10 @@ FactoryBot.define do
|
||||
after(:create) { |proposal| proposal.milestone_tags << create(:tag, :milestone) }
|
||||
end
|
||||
|
||||
trait :with_image do
|
||||
after(:create) { |proposal| create(:image, imageable: proposal) }
|
||||
end
|
||||
|
||||
factory :retired_proposal, traits: [:retired]
|
||||
end
|
||||
|
||||
|
||||
@@ -1011,12 +1011,12 @@ describe "Admin budget investments" do
|
||||
|
||||
scenario "Show image and documents on investment details" do
|
||||
budget_investment = create(:budget_investment,
|
||||
:with_image,
|
||||
:unfeasible,
|
||||
unfeasibility_explanation: "It is impossible",
|
||||
price: 1234,
|
||||
price_first_year: 1000,
|
||||
administrator: administrator)
|
||||
create(:image, imageable: budget_investment)
|
||||
document = create(:document, documentable: budget_investment)
|
||||
|
||||
visit admin_budget_budget_investments_path(budget_investment.budget)
|
||||
|
||||
@@ -85,8 +85,7 @@ describe "Admin polls" do
|
||||
end
|
||||
|
||||
scenario "Edit" do
|
||||
poll = create(:poll)
|
||||
create(:image, imageable: poll)
|
||||
poll = create(:poll, :with_image)
|
||||
|
||||
visit admin_poll_path(poll)
|
||||
click_link "Edit poll"
|
||||
|
||||
@@ -79,8 +79,7 @@ describe "Executions" do
|
||||
context "Images" do
|
||||
|
||||
scenario "renders milestone image if available" do
|
||||
milestone1 = create(:milestone, milestoneable: investment1)
|
||||
create(:image, imageable: milestone1)
|
||||
milestone1 = create(:milestone, :with_image, milestoneable: investment1)
|
||||
|
||||
visit budget_path(budget)
|
||||
|
||||
|
||||
@@ -127,8 +127,7 @@ describe "Budget Investments" do
|
||||
|
||||
scenario "Index should show investment descriptive image only when is defined" do
|
||||
investment = create(:budget_investment, heading: heading)
|
||||
investment_with_image = create(:budget_investment, heading: heading)
|
||||
image = create(:image, imageable: investment_with_image)
|
||||
investment_with_image = create(:budget_investment, :with_image, heading: heading)
|
||||
|
||||
visit budget_investments_path(budget, heading_id: heading.id)
|
||||
|
||||
|
||||
@@ -25,10 +25,7 @@ describe "Polls" do
|
||||
visit polls_path
|
||||
expect(page).to have_content("There are no open votings")
|
||||
|
||||
polls = create_list(:poll, 3)
|
||||
create(:image, imageable: polls[0])
|
||||
create(:image, imageable: polls[1])
|
||||
create(:image, imageable: polls[2])
|
||||
polls = create_list(:poll, 3, :with_image)
|
||||
|
||||
visit polls_path
|
||||
|
||||
|
||||
@@ -114,8 +114,7 @@ describe "Proposals" do
|
||||
|
||||
scenario "Index should show proposal descriptive image only when is defined" do
|
||||
proposal = create(:proposal)
|
||||
proposal_with_image = create(:proposal)
|
||||
image = create(:image, imageable: proposal_with_image)
|
||||
proposal_with_image = create(:proposal, :with_image)
|
||||
|
||||
visit proposals_path
|
||||
|
||||
|
||||
@@ -7,8 +7,7 @@ shared_examples "admin_milestoneable" do |factory_name, path_name|
|
||||
|
||||
context "Index" do
|
||||
scenario "Displaying milestones" do
|
||||
milestone = create(:milestone, milestoneable: milestoneable)
|
||||
create(:image, imageable: milestone)
|
||||
milestone = create(:milestone, :with_image, milestoneable: milestoneable)
|
||||
document = create(:document, documentable: milestone)
|
||||
|
||||
visit path
|
||||
@@ -85,8 +84,7 @@ shared_examples "admin_milestoneable" do |factory_name, path_name|
|
||||
|
||||
context "Edit" do
|
||||
scenario "Change title, description and document names" do
|
||||
milestone = create(:milestone, milestoneable: milestoneable)
|
||||
create(:image, imageable: milestone)
|
||||
milestone = create(:milestone, :with_image, milestoneable: milestoneable)
|
||||
document = create(:document, documentable: milestone)
|
||||
|
||||
visit path
|
||||
|
||||
Reference in New Issue
Block a user