Merge pull request #3122 from consul/proposal-create-question

[Backport] Proposal create question
This commit is contained in:
Alberto
2018-12-19 19:55:24 +01:00
committed by GitHub
7 changed files with 56 additions and 38 deletions

View File

@@ -53,11 +53,12 @@ feature 'Admin poll questions' do
expect(page).to have_content(title)
end
scenario 'Create from successful proposal index' do
scenario 'Create from successful proposal' do
poll = create(:poll, name: 'Proposals')
proposal = create(:proposal, :successful)
visit proposals_path
visit admin_proposal_path(proposal)
click_link "Create question"
expect(page).to have_current_path(new_admin_question_path, ignore_query: true)
@@ -72,17 +73,6 @@ feature 'Admin poll questions' do
expect(page).to have_link(proposal.author.name, href: user_path(proposal.author))
end
scenario "Create from successful proposal show" do
poll = create(:poll, name: 'Proposals')
proposal = create(:proposal, :successful)
visit proposal_path(proposal)
click_link "Create question"
expect(page).to have_current_path(new_admin_question_path, ignore_query: true)
expect(page).to have_field('Question', with: proposal.title)
end
scenario 'Update' do
question1 = create(:poll_question)

View File

@@ -28,12 +28,32 @@ feature "Admin proposals" do
end
end
scenario "Show" do
create(:proposal, title: "Create a chaotic future", summary: "Chaos isn't controlled")
context "Show" do
visit admin_proposals_path
click_link "Create a chaotic future"
scenario "View proposal" do
create(:proposal, title: "Create a chaotic future", summary: "Chaos isn't controlled")
expect(page).to have_content "Chaos isn't controlled"
visit admin_proposals_path
click_link "Create a chaotic future"
expect(page).to have_content "Chaos isn't controlled"
expect(page).not_to have_content "This proposal has reached the required supports"
expect(page).not_to have_link "Create question"
end
scenario "Successful proposals show create question button" do
successful_proposals = create_successful_proposals
admin = create(:administrator)
login_as(admin.user)
visit admin_proposals_path
successful_proposals.each do |proposal|
visit admin_proposal_path(proposal)
expect(page).to have_content "This proposal has reached the required supports"
expect(page).to have_link "Create question"
end
end
end
end

View File

@@ -1789,8 +1789,11 @@ feature 'Successful proposals' do
end
end
scenario 'Successful proposals show create question button to admin users' do
scenario 'Successful proposals do not show create question button in index' do
successful_proposals = create_successful_proposals
admin = create(:administrator)
login_as(admin.user)
visit proposals_path
@@ -1799,17 +1802,20 @@ feature 'Successful proposals' do
expect(page).not_to have_link "Create question"
end
end
end
login_as(create(:administrator).user)
scenario 'Successful proposals do not show create question button in show' do
successful_proposals = create_successful_proposals
admin = create(:administrator)
visit proposals_path
login_as(admin.user)
successful_proposals.each do |proposal|
visit proposal_path(proposal)
within("#proposal_#{proposal.id}_votes") do
expect(page).to have_link "Create question"
expect(page).not_to have_link "Create question"
end
end
end
context "Skip user verification" do