Fixed failing tests

This commit is contained in:
Juan Salvador Pérez García
2018-06-12 19:56:29 +02:00
parent b7c3cc3e08
commit a05e5c003f
9 changed files with 108 additions and 87 deletions

View File

@@ -128,7 +128,7 @@
<div class="sidebar-divider"></div> <div class="sidebar-divider"></div>
<h2><%= t("proposals.show.author") %></h2> <h2><%= t("proposals.show.author") %></h2>
<div class="show-actions-menu"> <div class="show-actions-menu">
<%= link_to proposal_dashboard_index_path(@proposal), class: 'button hollow expanded' do %> <%= link_to proposal_dashboard_index_path(@proposal), class: 'button hollow expanded', id: "proposal-dashboard-#{@proposal.id}" do %>
<span class="icon-edit"></span> <span class="icon-edit"></span>
<%= t("proposals.show.dashboard_proposal_link") %> <%= t("proposals.show.dashboard_proposal_link") %>
<% end %> <% end %>

View File

@@ -7,7 +7,7 @@
<%= simple_format text_with_links(@proposal.retired_explanation), {}, sanitize: false %> <%= simple_format text_with_links(@proposal.retired_explanation), {}, sanitize: false %>
</div> </div>
<% end %> <% end %>
d
<% if feature?(:allow_attached_documents) %> <% if feature?(:allow_attached_documents) %>
<%= render 'documents/documents', <%= render 'documents/documents',
documents: @proposal.documents, documents: @proposal.documents,

View File

@@ -75,7 +75,7 @@ feature 'Admin proposal dasboard actions' do
it 'deletes the action', js: true do it 'deletes the action', js: true do
page.accept_confirm do page.accept_confirm do
click_button 'Delete' click_link 'Delete'
end end
expect(page).not_to have_content(action.title) expect(page).not_to have_content(action.title)

View File

@@ -1082,6 +1082,7 @@ feature 'Budget Investments' do
it_behaves_like "followable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" } it_behaves_like "followable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" }
it_behaves_like "imageable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" } it_behaves_like "imageable", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" }
it_behaves_like "imageable destroy", "budget_investment", "budget_investment_path", { "budget_id": "budget_id", "id": "id" }
it_behaves_like "nested imageable", it_behaves_like "nested imageable",
"budget_investment", "budget_investment",

View File

@@ -2,26 +2,28 @@ require 'rails_helper'
feature 'Proposal Notifications' do feature 'Proposal Notifications' do
scenario "Send a notification" do scenario 'Send a notification' do
author = create(:user) author = create(:user)
proposal = create(:proposal, author: author) proposal = create(:proposal, author: author)
login_as(author) login_as(author)
visit root_path visit root_path
click_link "My activity" click_link 'My activity'
within("#proposal_#{proposal.id}") do within("#proposal_#{proposal.id}") do
click_link "Send notification" click_link 'Dashboard'
end end
fill_in 'proposal_notification_title', with: "Thank you for supporting my proposal" click_link 'Send notification'
fill_in 'proposal_notification_body', with: "Please share it with others so we can make it happen!"
fill_in 'proposal_notification_title', with: 'Thank you for supporting my proposal'
fill_in 'proposal_notification_body', with: 'Please share it with others so we can make it happen!'
click_button "Send message" click_button "Send message"
expect(page).to have_content "Your message has been sent correctly." expect(page).to have_content 'Your message has been sent correctly.'
expect(page).to have_content "Thank you for supporting my proposal" expect(page).to have_content 'Thank you for supporting my proposal'
expect(page).to have_content "Please share it with others so we can make it happen!" expect(page).to have_content 'Please share it with others so we can make it happen!'
end end
scenario "Send a notification (Active voter)" do scenario "Send a notification (Active voter)" do
@@ -167,20 +169,10 @@ feature 'Proposal Notifications' do
proposal = create(:proposal, author: author) proposal = create(:proposal, author: author)
login_as(author) login_as(author)
visit user_path(author) visit proposal_dashboard_index_path(proposal)
within("#proposal_#{proposal.id}") do
expect(page).to have_link "Send notification" expect(page).to have_link "Send notification"
end end
login_as(user)
visit user_path(author)
within("#proposal_#{proposal.id}") do
expect(page).not_to have_link "Send message"
end
end
scenario "Accessing form directly" do scenario "Accessing form directly" do
user = create(:user) user = create(:user)
author = create(:user) author = create(:user)

View File

@@ -206,7 +206,7 @@ feature 'Proposals' do
expect(page).to have_css "meta[property='og:title'][content=\"#{proposal.title}\"]", visible: false expect(page).to have_css "meta[property='og:title'][content=\"#{proposal.title}\"]", visible: false
end end
scenario 'Create' do scenario 'Create and publish' do
author = create(:user) author = create(:user)
login_as(author) login_as(author)
@@ -225,8 +225,10 @@ feature 'Proposals' do
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
expect(page).to have_content 'Help refugees' expect(page).to have_content 'Help refugees'
expect(page).not_to have_content 'You can also see more information about improving your campaign'
click_link 'No, I want to publish the proposal'
expect(page).to have_content 'Improve your campaign and get more support'
click_link 'Not now, go to my proposal' click_link 'Not now, go to my proposal'
expect(page).to have_content 'Help refugees' expect(page).to have_content 'Help refugees'
@@ -260,8 +262,9 @@ feature 'Proposals' do
click_button 'Create proposal' click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
expect(page).to have_content 'Improve your campaign and get more supports' click_link 'No, I want to publish the proposal'
expect(page).to have_content 'Improve your campaign and get more supports'
click_link 'Not now, go to my proposal' click_link 'Not now, go to my proposal'
expect(page).to have_content 'Help refugees' expect(page).to have_content 'Help refugees'
@@ -329,7 +332,7 @@ feature 'Proposals' do
click_button 'Create proposal' click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
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') expect(Proposal.last.responsible_name).to eq('Isabel Garcia')
@@ -351,7 +354,7 @@ feature 'Proposals' do
click_button 'Create proposal' click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
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(author.document_number) expect(Proposal.last.responsible_name).to eq(author.document_number)
@@ -383,7 +386,7 @@ feature 'Proposals' do
click_button 'Create proposal' click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
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(page).to have_content 'Testing an attack' expect(page).to have_content 'Testing an attack'
@@ -407,7 +410,7 @@ feature 'Proposals' do
click_button 'Create proposal' click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
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(page).to have_content 'Testing auto link' expect(page).to have_content 'Testing auto link'
@@ -430,7 +433,7 @@ feature 'Proposals' do
click_button 'Create proposal' click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
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(page).to have_content 'Testing auto link' expect(page).to have_content 'Testing auto link'
@@ -438,6 +441,7 @@ feature 'Proposals' do
expect(page).not_to have_link('click me') expect(page).not_to have_link('click me')
expect(page.html).not_to include "<script>alert('hey')</script>" expect(page.html).not_to include "<script>alert('hey')</script>"
click_link 'Dashboard'
click_link 'Edit' click_link 'Edit'
expect(page).to have_current_path(edit_proposal_path(Proposal.last)) expect(page).to have_current_path(edit_proposal_path(Proposal.last))
@@ -465,7 +469,7 @@ feature 'Proposals' do
click_button 'Create proposal' click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
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 "#geozone" do within "#geozone" do
@@ -494,7 +498,7 @@ feature 'Proposals' do
click_button 'Create proposal' click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
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 "#geozone" do within "#geozone" do
@@ -511,8 +515,10 @@ feature 'Proposals' do
visit user_path(proposal.author) visit user_path(proposal.author)
within("#proposal_#{proposal.id}") do within("#proposal_#{proposal.id}") do
click_link 'Retire' click_link 'Dashboard'
end end
click_link 'Retire'
expect(page).to have_current_path(retire_form_proposal_path(proposal)) expect(page).to have_current_path(retire_form_proposal_path(proposal))
select 'Duplicated', from: 'proposal_retired_reason' select 'Duplicated', from: 'proposal_retired_reason'

View File

@@ -80,7 +80,7 @@ feature 'Tags' do
click_button 'Create proposal' click_button 'Create proposal'
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
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(page).to have_content 'Economía' expect(page).to have_content 'Economía'
@@ -110,6 +110,7 @@ feature 'Tags' do
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
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 within "#tags_proposal_#{Proposal.last.id}" do
@@ -155,6 +156,7 @@ feature 'Tags' do
expect(page).to have_content 'Proposal created successfully.' expect(page).to have_content 'Proposal created successfully.'
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(page).to have_content 'user_id1' expect(page).to have_content 'user_id1'

View File

@@ -37,58 +37,6 @@ shared_examples "imageable" do |imageable_factory_name, imageable_path, imageabl
end end
end end
context "Destroy" do
background do
create(:image, imageable: imageable, user: imageable.author)
end
scenario "Administrators cannot destroy imageables they have not authored" do
login_as(administrator)
visit send(imageable_path, imageable_arguments)
expect(page).not_to have_link "Remove image"
end
scenario "Users cannot destroy imageables they have not authored" do
login_as(create(:user))
visit send(imageable_path, imageable_arguments)
expect(page).not_to have_link "Remove image"
end
scenario "Should show success notice after successful deletion" do
login_as imageable.author
visit send(imageable_path, imageable_arguments)
click_on "Remove image"
expect(page).to have_content "Image was deleted successfully."
end
scenario "Should not show image after successful deletion" do
login_as imageable.author
visit send(imageable_path, imageable_arguments)
click_on "Remove image"
expect(page).not_to have_selector "figure img"
end
scenario "Should redirect to imageable path after successful deletion" do
login_as imageable.author
visit send(imageable_path, imageable_arguments)
click_on "Remove image"
within "##{dom_id(imageable)}" do
expect(page).to have_selector "h1", text: imageable.title
end
end
end
end end
def attach_image(path, success = true) def attach_image(path, success = true)

View File

@@ -0,0 +1,72 @@
shared_examples "imageable destroy" do |imageable_factory_name, imageable_path, imageable_path_arguments|
include ActionView::Helpers
include ImagesHelper
include ImageablesHelper
let!(:administrator) { create(:user) }
let!(:user) { create(:user) }
let!(:imageable_arguments) { {} }
let!(:imageables_arguments) { {} }
let!(:imageable) { create(imageable_factory_name, author: user) }
let!(:imageable_dom_name) { imageable_factory_name.parameterize }
before do
create(:administrator, user: administrator)
imageable_path_arguments.each do |argument_name, path_to_value|
imageable_arguments.merge!("#{argument_name}": imageable.send(path_to_value))
end
end
context "Destroy" do
background do
create(:image, imageable: imageable, user: imageable.author)
end
scenario "Administrators cannot destroy imageables they have not authored" do
login_as(administrator)
visit send(imageable_path, imageable_arguments)
expect(page).not_to have_link "Remove image"
end
scenario "Users cannot destroy imageables they have not authored" do
login_as(create(:user))
visit send(imageable_path, imageable_arguments)
expect(page).not_to have_link "Remove image"
end
scenario "Should show success notice after successful deletion" do
login_as imageable.author
visit send(imageable_path, imageable_arguments)
click_on "Remove image"
expect(page).to have_content "Image was deleted successfully."
end
scenario "Should not show image after successful deletion" do
login_as imageable.author
visit send(imageable_path, imageable_arguments)
click_on "Remove image"
expect(page).not_to have_selector "figure img"
end
scenario "Should redirect to imageable path after successful deletion" do
login_as imageable.author
visit send(imageable_path, imageable_arguments)
click_on "Remove image"
within "##{dom_id(imageable)}" do
expect(page).to have_selector "h1", text: imageable.title
end
end
end
end