- <%= link_to proposal_ballots_path do %>
+ <%= link_to polls_path do %>
<%= t("proposal_ballots.featured_title") %>
diff --git a/config/locales/admin.en.yml b/config/locales/admin.en.yml
index e7e30e140..0ee20cac4 100755
--- a/config/locales/admin.en.yml
+++ b/config/locales/admin.en.yml
@@ -186,7 +186,8 @@ en:
new:
title: "Create Question"
show:
- proposal: Proposal
+ proposal: Original proposal
+ author: Author
title: Title
valid_answers: Valid answers
summary: Summary
diff --git a/config/locales/admin.es.yml b/config/locales/admin.es.yml
index 22086889e..70b7249bf 100644
--- a/config/locales/admin.es.yml
+++ b/config/locales/admin.es.yml
@@ -186,7 +186,8 @@ es:
new:
title: "Crear pregunta ciudadana"
show:
- proposal: Propuesta Ciudadana
+ proposal: Propuesta ciudadana original
+ author: Autor
title: Título
valid_answers: Respuestas válidas
summary: Resumen
diff --git a/config/locales/en.yml b/config/locales/en.yml
index 74f267bc3..a5a8870c2 100755
--- a/config/locales/en.yml
+++ b/config/locales/en.yml
@@ -385,7 +385,7 @@ en:
cant_answer_incoming: "This poll has not yet started."
cant_answer_expired: "This poll has finished."
cant_answer_wrong_geozone: "The following questions are not available in your geozone."
- questions:
+ poll_questions:
create_question: "Create question"
default_valid_answers: "Yes, No"
index:
diff --git a/config/locales/es.yml b/config/locales/es.yml
index c8ac24ed2..73fe5361a 100755
--- a/config/locales/es.yml
+++ b/config/locales/es.yml
@@ -375,8 +375,8 @@ es:
update:
form:
submit_button: Guardar cambios
- questions:
- create_enquiry: "Crear votación"
+ poll_questions:
+ create_question: "Crear votación"
default_valid_answers: "Sí, No"
index:
filters:
diff --git a/spec/factories.rb b/spec/factories.rb
index 78c6241d5..a69cde439 100644
--- a/spec/factories.rb
+++ b/spec/factories.rb
@@ -181,6 +181,10 @@ FactoryGirl.define do
4.times { create(:vote, votable: debate) }
end
end
+
+ trait :successful do
+ cached_votes_up { Proposal.votes_needed_for_success + 100 }
+ end
end
factory :spending_proposal do
@@ -280,6 +284,15 @@ FactoryGirl.define do
end
end
+ factory :poll_question, class: 'Poll::Question' do
+ poll
+ association :author, factory: :user
+ sequence(:title) { |n| "Question title #{n}" }
+ sequence(:summary) { |n| "Question summary #{n}" }
+ sequence(:description) { |n| "Question description #{n}" }
+ valid_answers { Faker::Lorem.words(3).join(', ') }
+ end
+
factory :poll_officer, class: 'Poll::Officer' do
user
end
@@ -309,16 +322,6 @@ FactoryGirl.define do
end
end
- factory :poll_question, class: 'Poll::Question' do
- poll
- association :author, factory: :user
- sequence(:title) { |n| "Question title #{n}" }
- sequence(:summary) { |n| "Question summary #{n}" }
- sequence(:description) { |n| "Question description #{n}" }
- sequence(:question) { |n| "Question question #{n}" }
- valid_answers { Faker::Lorem.words(3).join(', ') }
- end
-
factory :poll_partial_result, class: 'Poll::PartialResult' do
association :question, factory: :poll_question
association :author, factory: :user
diff --git a/spec/features/admin/poll/questions_spec.rb b/spec/features/admin/poll/questions_spec.rb
index bab4e1a0e..0fa57003e 100644
--- a/spec/features/admin/poll/questions_spec.rb
+++ b/spec/features/admin/poll/questions_spec.rb
@@ -1,52 +1,33 @@
require 'rails_helper'
feature 'Admin enquiries' do
- background { login_as(create(:administrator).user) }
+
+ background do
+ login_as(create(:administrator).user)
+ end
scenario 'Index' do
- e1 = create(:enquiry)
- e2 = create(:enquiry)
+ question1 = create(:poll_question)
+ question2 = create(:poll_question)
- visit admin_enquiries_path
+ visit admin_questions_path
- expect(page).to have_content(e1.title)
- expect(page).to have_content(e2.title)
+ expect(page).to have_content(question1.title)
+ expect(page).to have_content(question2.title)
end
- scenario 'Destroy' do
- e1 = create(:enquiry)
- e2 = create(:enquiry)
+ scenario 'Show' do
+ geozone = create(:geozone)
+ question = create(:poll_question, geozone_ids: geozone.id)
- visit admin_enquiries_path
+ visit admin_question_path(question)
- within("#enquiry_#{e1.id}") do
- click_link "Delete"
- end
-
- expect(page).to_not have_content(e1.title)
- expect(page).to have_content(e2.title)
- end
-
- scenario 'Update' do
- e1 = create(:enquiry)
- visit admin_enquiries_path
- within("#enquiry_#{e1.id}") do
- click_link "Edit"
- end
-
- old_title = e1.title
- new_title = "Potatoes are great and everyone should have one"
- fill_in 'enquiry_title', with: new_title
-
- click_button 'Save'
-
- expect(page).to have_content "Changes saved"
- expect(page).to have_content new_title
-
- visit admin_enquiries_path
-
- expect(page).to have_content(new_title)
- expect(page).to_not have_content(old_title)
+ expect(page).to have_content(question.title)
+ expect(page).to have_content(question.description)
+ expect(page).to have_content(question.summary)
+ expect(page).to have_content(question.author.name)
+ expect(page).to have_content(question.valid_answers.join(", "))
+ expect(page).to have_content(geozone.name)
end
scenario 'Create' do
@@ -56,53 +37,80 @@ feature 'Admin enquiries' do
During the battle, Rebel spies managed to steal secret plans to the Empire's ultimate weapon, the DEATH STAR, an armored space station with enough power to destroy an entire planet.
Pursued by the Empire's sinister agents, Princess Leia races home aboard her starship, custodian of the stolen plans that can save her people and restore freedom to the galaxy....
}
- question = "Aren't you a little short for a stormtrooper?"
- visit admin_enquiries_path
- click_link "Create enquiry"
+ visit admin_questions_path
+ click_link "Create question"
- fill_in 'enquiry_title', with: title
- fill_in 'enquiry_summary', with: summary
- fill_in 'enquiry_description', with: description
- fill_in 'enquiry_question', with: question
+ fill_in 'poll_question_title', with: title
+ fill_in 'poll_question_summary', with: summary
+ fill_in 'poll_question_description', with: description
click_button 'Save'
expect(page).to have_content(title)
expect(page).to have_content(description)
expect(page).to have_content(summary)
- expect(page).to have_content(question)
end
- scenario 'Create from successful proposal' do
+ scenario 'Create from successful proposal', :focus do
geozones = create_list(:geozone, 3)
- p = create(:proposal, :successful)
+ proposal = create(:proposal, :successful)
visit proposals_path
- click_link "Create enquiry"
+ click_link "Create question"
- expect(current_path).to eq(new_admin_enquiry_path)
- expect(page).to have_field('enquiry_title', with: p.title)
- expect(page).to have_field('enquiry_summary', with: p.summary)
- expect(page).to have_field('enquiry_description', with: p.description)
- expect(page).to have_field('enquiry_question', with: p.question)
- expect(page).to have_field('enquiry_valid_answers', with: "Yes, No")
-
- geozones.each do |g|
- expect(page).to have_checked_field("enquiry_geozone_ids_#{g.id}")
- end
+ expect(current_path).to eq(new_admin_question_path)
+ expect(page).to have_field('poll_question_title', with: proposal.title)
+ expect(page).to have_field('poll_question_summary', with: proposal.summary)
+ expect(page).to have_field('poll_question_description', with: proposal.description)
+ expect(page).to have_field('poll_question_valid_answers', with: "Yes, No")
click_button 'Save'
- expect(page).to have_content(p.title)
- expect(page).to have_content(p.summary)
- expect(page).to have_content(p.description)
- expect(page).to have_content(p.question)
- expect(page).to have_link('Original proposal', href: proposal_path(p))
- expect(page).to have_link(p.author.name, href: user_path(p.author))
- geozones.each do |g|
- expect(page).to have_content(g.name)
- end
+ expect(page).to have_content(proposal.title)
+ expect(page).to have_content(proposal.summary)
+ expect(page).to have_content(proposal.description)
+ expect(page).to have_link(proposal.title, href: proposal_path(proposal))
+ expect(page).to have_link(proposal.author.name, href: user_path(proposal.author))
end
+ scenario 'Update' do
+ question1 = create(:poll_question)
+
+ visit admin_questions_path
+ within("#poll_question_#{question1.id}") do
+ click_link "Edit"
+ end
+
+ old_title = question1.title
+ new_title = "Potatoes are great and everyone should have one"
+ fill_in 'poll_question_title', with: new_title
+
+ click_button 'Save'
+
+ expect(page).to have_content "Changes saved"
+ expect(page).to have_content new_title
+
+ visit admin_questions_path
+
+ expect(page).to have_content(new_title)
+ expect(page).to_not have_content(old_title)
+ end
+
+ scenario 'Destroy' do
+ question1 = create(:poll_question)
+ question2 = create(:poll_question)
+
+ visit admin_questions_path
+
+ within("#poll_question_#{question1.id}") do
+ click_link "Delete"
+ end
+
+ expect(page).to_not have_content(question1.title)
+ expect(page).to have_content(question2.title)
+ end
+
+ pending "Mark all city by default when creating a poll question from a successful proposal"
+
end
\ No newline at end of file