Replaces spending proposals by budget investments in user/show
This commit is contained in:
@@ -8,7 +8,8 @@ feature 'Users' do
|
||||
@user = create(:user)
|
||||
1.times {create(:debate, author: @user)}
|
||||
2.times {create(:proposal, author: @user)}
|
||||
3.times {create(:comment, user: @user)}
|
||||
3.times {create(:budget_investment, author: @user)}
|
||||
4.times {create(:comment, user: @user)}
|
||||
|
||||
visit user_path(@user)
|
||||
end
|
||||
@@ -16,7 +17,8 @@ feature 'Users' do
|
||||
scenario 'shows user public activity' do
|
||||
expect(page).to have_content('1 Debate')
|
||||
expect(page).to have_content('2 Proposals')
|
||||
expect(page).to have_content('3 Comments')
|
||||
expect(page).to have_content('3 Investments')
|
||||
expect(page).to have_content('4 Comments')
|
||||
end
|
||||
|
||||
scenario 'shows only items where user has activity' do
|
||||
@@ -24,7 +26,8 @@ feature 'Users' do
|
||||
|
||||
expect(page).to_not have_content('0 Proposals')
|
||||
expect(page).to have_content('1 Debate')
|
||||
expect(page).to have_content('3 Comments')
|
||||
expect(page).to have_content('3 Investments')
|
||||
expect(page).to have_content('4 Comments')
|
||||
end
|
||||
|
||||
scenario 'default filter is proposals' do
|
||||
@@ -48,11 +51,20 @@ feature 'Users' do
|
||||
expect(page).to have_content(@user.debates.first.title)
|
||||
end
|
||||
|
||||
scenario 'shows comments by default if user has no proposals nor debates' do
|
||||
scenario 'shows investments by default if user has no proposals nor debates' do
|
||||
@user.proposals.destroy_all
|
||||
@user.debates.destroy_all
|
||||
visit user_path(@user)
|
||||
|
||||
expect(page).to have_content(@user.budget_investments.first.title)
|
||||
end
|
||||
|
||||
scenario 'shows comments by default if user has no proposals nor debates nor investments' do
|
||||
@user.proposals.destroy_all
|
||||
@user.debates.destroy_all
|
||||
@user.budget_investments.destroy_all
|
||||
visit user_path(@user)
|
||||
|
||||
@user.comments.each do |comment|
|
||||
expect(page).to have_content(comment.body)
|
||||
end
|
||||
@@ -73,7 +85,7 @@ feature 'Users' do
|
||||
expect(page).to_not have_content(comment.body)
|
||||
end
|
||||
|
||||
click_link '3 Comments'
|
||||
click_link '4 Comments'
|
||||
|
||||
@user.comments.each do |comment|
|
||||
expect(page).to have_content(comment.body)
|
||||
@@ -199,64 +211,6 @@ feature 'Users' do
|
||||
|
||||
end
|
||||
|
||||
feature 'Spending proposals' do
|
||||
|
||||
background do
|
||||
@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
|
||||
visit user_path(@author)
|
||||
expect(page).to_not have_content('Build a school')
|
||||
end
|
||||
|
||||
scenario 'is not shown if no user logged in (filtered url)' do
|
||||
visit user_path(@author, filter: 'spending_proposals')
|
||||
expect(page).to_not have_content('Build a school')
|
||||
end
|
||||
|
||||
scenario 'is not shown if logged in user is a regular user' do
|
||||
login_as(create(:user))
|
||||
visit user_path(@author)
|
||||
expect(page).to_not have_content('Build a school')
|
||||
end
|
||||
|
||||
scenario 'is not shown if logged in user is moderator' do
|
||||
login_as(create(:moderator).user)
|
||||
visit user_path(@author)
|
||||
expect(page).to_not have_content('Build a school')
|
||||
end
|
||||
|
||||
scenario 'is shown if logged in user is admin' do
|
||||
login_as(create(:administrator).user)
|
||||
visit user_path(@author)
|
||||
expect(page).to have_content('Build a school')
|
||||
end
|
||||
|
||||
scenario 'is shown if logged in user is author' do
|
||||
login_as(@author)
|
||||
visit user_path(@author)
|
||||
expect(page).to have_content('Build a school')
|
||||
end
|
||||
|
||||
scenario 'delete button is not 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_not have_content('Delete')
|
||||
end
|
||||
end
|
||||
|
||||
scenario 'delete button is 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 have_content('Delete')
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
feature 'Special comments' do
|
||||
@@ -283,4 +237,4 @@ feature 'Users' do
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
||||
Reference in New Issue
Block a user