From ba9814cd85ac324ace35040bfff6da053a7e5181 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 9 Oct 2017 13:01:39 +0200 Subject: [PATCH 1/5] shows videos on polls answers --- app/views/polls/show.html.erb | 16 ++++++++++++++++ config/locales/en/general.yml | 1 + config/locales/es/general.yml | 1 + 3 files changed, 18 insertions(+) diff --git a/app/views/polls/show.html.erb b/app/views/polls/show.html.erb index 19daf5e35..b7877aa51 100644 --- a/app/views/polls/show.html.erb +++ b/app/views/polls/show.html.erb @@ -125,6 +125,22 @@ <% end %> <% end %> + + <% if answer.videos.present? %> + + <% end %> <% end %> diff --git a/config/locales/en/general.yml b/config/locales/en/general.yml index 413a6abf8..6c3356b6d 100644 --- a/config/locales/en/general.yml +++ b/config/locales/en/general.yml @@ -495,6 +495,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 b8747406b..5f756bbdd 100644 --- a/config/locales/es/general.yml +++ b/config/locales/es/general.yml @@ -495,6 +495,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" From c9a3bcc65a7539ba6fbb0477a04e7d367923b4ab Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 16 Oct 2017 13:14:15 +0200 Subject: [PATCH 2/5] adds admin polls answer video specs --- spec/features/polls/answers_spec.rb | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) diff --git a/spec/features/polls/answers_spec.rb b/spec/features/polls/answers_spec.rb index f7dfd4d38..54890610e 100644 --- a/spec/features/polls/answers_spec.rb +++ b/spec/features/polls/answers_spec.rb @@ -39,6 +39,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" From 279adaa00d19f108366025c96cda857bc390e842 Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 16 Oct 2017 13:14:44 +0200 Subject: [PATCH 3/5] starts with polls show answers with video specs --- spec/features/polls/polls_spec.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/spec/features/polls/polls_spec.rb b/spec/features/polls/polls_spec.rb index 9fdb07255..96787bc9e 100644 --- a/spec/features/polls/polls_spec.rb +++ b/spec/features/polls/polls_spec.rb @@ -65,6 +65,19 @@ 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) + answer1 = create(:poll_question_answer, question: question, title: 'Chewbacca') + answer2 = create(:poll_question_answer, question: question, title: 'Han Solo', + video_title: "Awesome project video", + video_url: "https://www.youtube.com/watch?v=123") + + + visit poll_path(poll) + + + 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)) From c2dcad79b3243eefc56deca7cfe0a152cd36b966 Mon Sep 17 00:00:00 2001 From: rgarcia Date: Mon, 16 Oct 2017 17:14:40 +0200 Subject: [PATCH 4/5] adds video spec --- spec/factories.rb | 6 ++++++ spec/features/polls/polls_spec.rb | 9 +++------ 2 files changed, 9 insertions(+), 6 deletions(-) diff --git a/spec/factories.rb b/spec/factories.rb index a28471efc..cf3b8f88a 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -507,6 +507,12 @@ FactoryGirl.define do sequence(:description) { |n| "Question description #{n}" } end + factory :poll_answer_video, class: 'Poll::Question::Answer::Video' do + association :answer, factory: :poll_question_answer + title "Sample video title" + url "http://sample-video-url.org" + end + factory :poll_booth, class: 'Poll::Booth' do sequence(:name) { |n| "Booth #{n}" } sequence(:location) { |n| "Street #{n}" } diff --git a/spec/features/polls/polls_spec.rb b/spec/features/polls/polls_spec.rb index 96787bc9e..2793fafdf 100644 --- a/spec/features/polls/polls_spec.rb +++ b/spec/features/polls/polls_spec.rb @@ -67,15 +67,12 @@ feature 'Polls' do scenario 'Show answers with videos' do question = create(:poll_question, poll: poll) - answer1 = create(:poll_question_answer, question: question, title: 'Chewbacca') - answer2 = create(:poll_question_answer, question: question, title: 'Han Solo', - video_title: "Awesome project video", - video_url: "https://www.youtube.com/watch?v=123") - + 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 From 1812c0330e9e5eb84cd856c8d15abfa29b49862e Mon Sep 17 00:00:00 2001 From: decabeza Date: Mon, 16 Oct 2017 18:37:00 +0200 Subject: [PATCH 5/5] replaces video url on poll answer factories --- spec/factories.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/factories.rb b/spec/factories.rb index cf3b8f88a..db24002ae 100644 --- a/spec/factories.rb +++ b/spec/factories.rb @@ -510,7 +510,7 @@ FactoryGirl.define do factory :poll_answer_video, class: 'Poll::Question::Answer::Video' do association :answer, factory: :poll_question_answer title "Sample video title" - url "http://sample-video-url.org" + url "https://youtu.be/nhuNb0XtRhQ" end factory :poll_booth, class: 'Poll::Booth' do