diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb index 4489cd226..ce2a6d46a 100644 --- a/app/views/polls/show.html.erb +++ b/app/views/polls/show.html.erb @@ -126,6 +126,22 @@ <% end %> <% end %> + + <% if answer.videos.present? %> + + <% end %> <% end %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 77579a7ea..7b3766471 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -497,6 +497,7 @@ en: read_more: "Read more about %{answer}" read_less: "Read less about %{answer}" participate_in_other_polls: Participate in other polls + videos: "External video" poll_questions: create_question: "Create question" default_valid_answers: "Yes, No" diff --git a/config/locales/es/general.yml b/config/locales/es/general.yml index 11e5e252a..0d2d11a52 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -497,6 +497,7 @@ es: read_more: "Leer más sobre %{answer}" read_less: "Leer menos sobre %{answer}" participate_in_other_polls: Participar en otras votaciones + videos: "Vídeo externo" poll_questions: create_question: "Crear pregunta para votación" default_valid_answers: "Sí, No" diff --git a/spec/factories.rb b/spec/factories.rb index ed1d24fd6..ecc53794b 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -512,6 +512,12 @@ FactoryGirl.define do sequence(:description) { |n| "Answer description #{n}" } end + factory :poll_answer_video, class: 'Poll::Question::Answer::Video' do + association :answer, factory: :poll_question_answer + title "Sample video title" + url "https://youtu.be/nhuNb0XtRhQ" + end + factory :poll_booth, class: 'Poll::Booth' do sequence(:name) { |n| "Booth #{n}" } sequence(:location) { |n| "Street #{n}" } diff --git a/spec/features/polls/answers_spec.rb b/spec/features/polls/answers_spec.rb index 32b5732a0..88b7e28aa 100644 --- a/spec/features/polls/answers_spec.rb +++ b/spec/features/polls/answers_spec.rb @@ -41,6 +41,31 @@ feature 'Answers' do expect(page).to have_content "Adding more trees, creating a play area..." end + + scenario 'Add video to answer' do + question = create(:poll_question) + answer1 = create(:poll_question_answer, question: question) + answer2 = create(:poll_question_answer, question: question) + + visit admin_question_path(question) + + within("#poll_question_answer_#{answer1.id}") do + click_link "Video list" + end + + click_link "Add video" + + fill_in "poll_question_answer_video_title", with: "Awesome project video" + fill_in "poll_question_answer_video_url", with: "https://www.youtube.com/watch?v=123" + + click_button "Save" + + within("#poll_question_answer_video_#{answer1.id}") do + expect(page).to have_content "Awesome project video" + expect(page).to have_content "https://www.youtube.com/watch?v=123" + end + end + pending "Update" pending "Destroy" diff --git a/spec/features/polls/polls_spec.rb b/spec/features/polls/polls_spec.rb index 90deca711..e36720038 100644 --- a/spec/features/polls/polls_spec.rb +++ b/spec/features/polls/polls_spec.rb @@ -65,6 +65,16 @@ feature 'Polls' do let(:geozone) { create(:geozone) } let(:poll) { create(:poll, summary: "Summary", description: "Description") } + scenario 'Show answers with videos' do + question = create(:poll_question, poll: poll) + answer = create(:poll_question_answer, question: question, title: 'Chewbacca') + video = create(:poll_answer_video, answer: answer, title: "Awesome project video", url: "https://www.youtube.com/watch?v=123") + + visit poll_path(poll) + + expect(page).to have_link("Awesome project video", href: "https://www.youtube.com/watch?v=123") + end + scenario 'Lists questions from proposals as well as regular ones' do normal_question = create(:poll_question, poll: poll) proposal_question = create(:poll_question, poll: poll, proposal: create(:proposal))