Merge remote-tracking branch 'origin/master' into tracking_user_verifications_and_others
Conflicts: app/assets/javascripts/application.js
This commit is contained in:
@@ -66,11 +66,6 @@ feature 'Admin spending proposals' do
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to have_link("Destroy the city")
|
||||
|
||||
select "District 9", from: "geozone_id"
|
||||
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to_not have_link("Destroy the city")
|
||||
|
||||
select "All city", from: "geozone_id"
|
||||
|
||||
expect(page).to have_link("Destroy the city")
|
||||
@@ -79,6 +74,28 @@ feature 'Admin spending proposals' do
|
||||
select "All zones", from: "geozone_id"
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to have_link("Destroy the city")
|
||||
|
||||
select "District 9", from: "geozone_id"
|
||||
|
||||
expect(page).to_not have_link("Destroy the city")
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
|
||||
click_link("Realocate visitors")
|
||||
click_link("Back")
|
||||
|
||||
expect(page).to_not have_link("Destroy the city")
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
|
||||
click_link("Realocate visitors")
|
||||
click_on("Edit classification")
|
||||
expect(page).to have_button("Update")
|
||||
click_on("Back")
|
||||
expect(page).to_not have_button("Update")
|
||||
click_on("Back")
|
||||
|
||||
expect(page).to_not have_link("Destroy the city")
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
|
||||
end
|
||||
|
||||
scenario "Filtering by admin", :js do
|
||||
@@ -94,13 +111,36 @@ feature 'Admin spending proposals' do
|
||||
|
||||
select "Admin 1", from: "administrator_id"
|
||||
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
expect(page).to have_content('There is 1 spending proposal')
|
||||
expect(page).to_not have_link("Destroy the city")
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
|
||||
select "All administrators", from: "administrator_id"
|
||||
|
||||
expect(page).to have_content('There are 2 spending proposals')
|
||||
expect(page).to have_link("Destroy the city")
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
|
||||
select "Admin 1", from: "administrator_id"
|
||||
expect(page).to have_content('There is 1 spending proposal')
|
||||
click_link("Realocate visitors")
|
||||
click_link("Back")
|
||||
|
||||
expect(page).to have_content('There is 1 spending proposal')
|
||||
expect(page).to_not have_link("Destroy the city")
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
|
||||
click_link("Realocate visitors")
|
||||
click_on("Edit classification")
|
||||
expect(page).to have_button("Update")
|
||||
click_on("Back")
|
||||
expect(page).to_not have_button("Update")
|
||||
click_on("Back")
|
||||
|
||||
expect(page).to have_content('There is 1 spending proposal')
|
||||
expect(page).to_not have_link("Destroy the city")
|
||||
expect(page).to have_link("Realocate visitors")
|
||||
|
||||
end
|
||||
|
||||
scenario "Current filter is properly highlighted" do
|
||||
@@ -183,10 +223,28 @@ feature 'Admin spending proposals' do
|
||||
|
||||
visit admin_spending_proposals_path(tag_name: 'Education')
|
||||
|
||||
expect(page).to_not have_content("More hospitals")
|
||||
expect(page).to have_css(".spending_proposal", count: 2)
|
||||
expect(page).to have_content("Educate the children")
|
||||
expect(page).to have_content("More schools")
|
||||
|
||||
click_link("Educate the children")
|
||||
click_link("Back")
|
||||
|
||||
expect(page).to_not have_content("More hospitals")
|
||||
expect(page).to have_content("Educate the children")
|
||||
expect(page).to have_content("More schools")
|
||||
|
||||
click_link("Educate the children")
|
||||
click_on("Edit classification")
|
||||
expect(page).to have_button("Update")
|
||||
click_on("Back")
|
||||
expect(page).to_not have_button("Update")
|
||||
click_on("Back")
|
||||
|
||||
expect(page).to_not have_content("More hospitals")
|
||||
expect(page).to have_content("Educate the children")
|
||||
expect(page).to have_content("More schools")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -20,9 +20,12 @@ feature 'Admin valuators' do
|
||||
click_button 'Search'
|
||||
|
||||
expect(page).to have_content @user.name
|
||||
click_link 'Add'
|
||||
fill_in 'valuator_description', with: 'environmental expert'
|
||||
click_button 'Add to valuators'
|
||||
|
||||
within("#valuators") do
|
||||
expect(page).to have_content @user.name
|
||||
expect(page).to have_content 'environmental expert'
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -163,4 +163,24 @@ feature 'Spending proposals' do
|
||||
expect(page).to have_content("You do not have permission to access this page")
|
||||
end
|
||||
|
||||
context "Destroy" do
|
||||
|
||||
scenario "User can destroy owned spending proposals" do
|
||||
user = create(:user, :level_two)
|
||||
spending_proposal = create(:spending_proposal, author: user)
|
||||
login_as(user)
|
||||
|
||||
visit user_path(user)
|
||||
within("#spending_proposal_#{spending_proposal.id}") do
|
||||
click_link "Delete"
|
||||
end
|
||||
|
||||
expect(page).to have_content("Spending proposal deleted succesfully.")
|
||||
|
||||
visit user_path(user)
|
||||
expect(page).not_to have_css("spending_proposal_list")
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
@@ -202,8 +202,8 @@ feature 'Users' do
|
||||
feature 'Spending proposals' do
|
||||
|
||||
background do
|
||||
@author = create(:user)
|
||||
create(:spending_proposal, author: @author, title: 'Build a school')
|
||||
@author = create(:user, :level_two)
|
||||
@spending_proposal = create(:spending_proposal, author: @author, title: 'Build a school')
|
||||
end
|
||||
|
||||
scenario 'is not shown if no user logged in' do
|
||||
@@ -240,6 +240,22 @@ feature 'Users' do
|
||||
expect(page).to have_content('Build a school')
|
||||
end
|
||||
|
||||
scenario 'delete button is shown if logged in user is author' do
|
||||
login_as(@author)
|
||||
visit user_path(@author)
|
||||
within("#spending_proposal_#{@spending_proposal.id}") do
|
||||
expect(page).to have_content('Delete')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'delete button is not shown if logged in user is admin' do
|
||||
login_as(create(:administrator).user)
|
||||
visit user_path(@author)
|
||||
within("#spending_proposal_#{@spending_proposal.id}") do
|
||||
expect(page).to_not have_content('Delete')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -288,6 +288,60 @@ feature 'Valuation spending proposals' do
|
||||
expect(find "#spending_proposal_feasible_nil").to be_checked
|
||||
end
|
||||
|
||||
scenario 'Feasibility selection makes proper fields visible', :js do
|
||||
feasible_true_fields = ['Price (€)','Cost during the first year (€)','Price explanation','Time scope']
|
||||
feasible_false_fields = ['Feasibility explanation']
|
||||
feasible_any_fields = ['Valuation finished','Internal comments']
|
||||
feasible_nil_fields = feasible_true_fields + feasible_false_fields + feasible_any_fields
|
||||
|
||||
visit edit_valuation_spending_proposal_path(@spending_proposal)
|
||||
|
||||
expect(find "#spending_proposal_feasible_nil").to be_checked
|
||||
|
||||
feasible_nil_fields.each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
choose 'spending_proposal_feasible_true'
|
||||
|
||||
feasible_false_fields.each do |field|
|
||||
expect(page).to_not have_content(field)
|
||||
end
|
||||
|
||||
(feasible_true_fields + feasible_any_fields).each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
choose 'spending_proposal_feasible_false'
|
||||
|
||||
feasible_true_fields.each do |field|
|
||||
expect(page).to_not have_content(field)
|
||||
end
|
||||
|
||||
(feasible_false_fields + feasible_any_fields).each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
click_button 'Save changes'
|
||||
|
||||
visit edit_valuation_spending_proposal_path(@spending_proposal)
|
||||
|
||||
expect(find "#spending_proposal_feasible_false").to be_checked
|
||||
feasible_true_fields.each do |field|
|
||||
expect(page).to_not have_content(field)
|
||||
end
|
||||
|
||||
(feasible_false_fields + feasible_any_fields).each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
|
||||
choose 'spending_proposal_feasible_nil'
|
||||
|
||||
feasible_nil_fields.each do |field|
|
||||
expect(page).to have_content(field)
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'Finish valuation' do
|
||||
visit valuation_spending_proposal_path(@spending_proposal)
|
||||
click_link 'Edit dossier'
|
||||
|
||||
@@ -31,9 +31,9 @@ describe UsersHelper do
|
||||
end
|
||||
|
||||
describe '#comment_commentable_title' do
|
||||
it "should return a link to the commentable" do
|
||||
it "should return a link to the comment" do
|
||||
comment = create(:comment)
|
||||
expect(comment_commentable_title(comment)).to eq link_to comment.commentable.title, comment.commentable
|
||||
expect(comment_commentable_title(comment)).to eq link_to comment.commentable.title, comment
|
||||
end
|
||||
|
||||
it "should return a hint if the commentable has been deleted" do
|
||||
|
||||
@@ -52,5 +52,7 @@ describe "Abilities::Administrator" do
|
||||
|
||||
it { should be_able_to(:manage, Annotation) }
|
||||
|
||||
it { should be_able_to(:manage, SpendingProposal) }
|
||||
it { should be_able_to(:read, SpendingProposal) }
|
||||
it { should be_able_to(:update, SpendingProposal) }
|
||||
it { should be_able_to(:valuate, SpendingProposal) }
|
||||
end
|
||||
|
||||
@@ -30,6 +30,7 @@ describe "Abilities::Common" do
|
||||
|
||||
it { should be_able_to(:index, SpendingProposal) }
|
||||
it { should_not be_able_to(:create, SpendingProposal) }
|
||||
it { should_not be_able_to(:destroy, SpendingProposal) }
|
||||
|
||||
it { should_not be_able_to(:comment_as_administrator, debate) }
|
||||
it { should_not be_able_to(:comment_as_moderator, debate) }
|
||||
@@ -83,20 +84,26 @@ describe "Abilities::Common" do
|
||||
end
|
||||
|
||||
describe "when level 2 verified" do
|
||||
let(:own_spending_proposal) { create(:spending_proposal, author: user) }
|
||||
before{ user.update(residence_verified_at: Time.now, confirmed_phone: "1") }
|
||||
|
||||
it { should be_able_to(:vote, Proposal) }
|
||||
it { should be_able_to(:vote_featured, Proposal) }
|
||||
|
||||
it { should be_able_to(:create, SpendingProposal) }
|
||||
it { should_not be_able_to(:destroy, create(:spending_proposal)) }
|
||||
it { should be_able_to(:destroy, own_spending_proposal) }
|
||||
end
|
||||
|
||||
describe "when level 3 verified" do
|
||||
let(:own_spending_proposal) { create(:spending_proposal, author: user) }
|
||||
before{ user.update(verified_at: Time.now) }
|
||||
|
||||
it { should be_able_to(:vote, Proposal) }
|
||||
it { should be_able_to(:vote_featured, Proposal) }
|
||||
|
||||
it { should be_able_to(:create, SpendingProposal) }
|
||||
it { should_not be_able_to(:destroy, create(:spending_proposal)) }
|
||||
it { should be_able_to(:destroy, own_spending_proposal) }
|
||||
end
|
||||
end
|
||||
|
||||
@@ -6,5 +6,7 @@ describe "Abilities::Valuator" do
|
||||
let(:user) { valuator.user }
|
||||
let(:valuator) { create(:valuator) }
|
||||
|
||||
it { should be_able_to(:manage, SpendingProposal) }
|
||||
it { should be_able_to(:read, SpendingProposal) }
|
||||
it { should be_able_to(:update, SpendingProposal) }
|
||||
it { should be_able_to(:valuate, SpendingProposal) }
|
||||
end
|
||||
|
||||
18
spec/models/valuator_spec.rb
Normal file
18
spec/models/valuator_spec.rb
Normal file
@@ -0,0 +1,18 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe Valuator do
|
||||
|
||||
describe "#description_or_email" do
|
||||
it "should return description if present" do
|
||||
valuator = create(:valuator, description: "Urbanism manager")
|
||||
|
||||
expect(valuator.description_or_email).to eq("Urbanism manager")
|
||||
end
|
||||
|
||||
it "should return email if not description present" do
|
||||
valuator = create(:valuator)
|
||||
|
||||
expect(valuator.description_or_email).to eq(valuator.email)
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user