Add missing system specs for poll question answer videos
Minor change for replace @video.answer_id to @video.answer.
This commit is contained in:
@@ -25,8 +25,7 @@ class Admin::Poll::Questions::Answers::VideosController < Admin::Poll::BaseContr
|
|||||||
|
|
||||||
def update
|
def update
|
||||||
if @video.update(video_params)
|
if @video.update(video_params)
|
||||||
redirect_to admin_answer_videos_path(@video.answer_id),
|
redirect_to admin_answer_videos_path(@video.answer), notice: t("flash.actions.save_changes.notice")
|
||||||
notice: t("flash.actions.save_changes.notice")
|
|
||||||
else
|
else
|
||||||
render :edit
|
render :edit
|
||||||
end
|
end
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
<%= back_link_to admin_question_path(@answer.question_id) %>
|
<%= back_link_to admin_question_path(@answer.question) %>
|
||||||
|
|
||||||
<div class="clear"></div>
|
<div class="clear"></div>
|
||||||
|
|
||||||
|
|||||||
@@ -1,26 +1,53 @@
|
|||||||
require "rails_helper"
|
require "rails_helper"
|
||||||
|
|
||||||
describe "Videos", :admin do
|
describe "Videos", :admin do
|
||||||
scenario "Create" do
|
let!(:question) { create(:poll_question) }
|
||||||
question = create(:poll_question)
|
let!(:answer) { create(:poll_question_answer, question: question) }
|
||||||
answer = create(:poll_question_answer, question: question)
|
let(:title) { "'Magical' by Junko Ohashi" }
|
||||||
video_title = "'Magical' by Junko Ohashi"
|
let(:url) { "https://www.youtube.com/watch?v=-JMf43st-1A" }
|
||||||
video_url = "https://www.youtube.com/watch?v=-JMf43st-1A"
|
|
||||||
|
|
||||||
|
scenario "Create" do
|
||||||
visit admin_question_path(question)
|
visit admin_question_path(question)
|
||||||
|
|
||||||
within("#poll_question_answer_#{answer.id}") do
|
within("#poll_question_answer_#{answer.id}") do
|
||||||
click_link "Video list"
|
click_link "Video list"
|
||||||
end
|
end
|
||||||
|
|
||||||
click_link "Add video"
|
click_link "Add video"
|
||||||
|
|
||||||
fill_in "poll_question_answer_video_title", with: video_title
|
fill_in "Title", with: title
|
||||||
fill_in "poll_question_answer_video_url", with: video_url
|
fill_in "External video", with: url
|
||||||
|
|
||||||
click_button "Save"
|
click_button "Save"
|
||||||
|
|
||||||
expect(page).to have_content(video_title)
|
expect(page).to have_content title
|
||||||
expect(page).to have_content(video_url)
|
expect(page).to have_content url
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Update" do
|
||||||
|
video = create(:poll_answer_video, answer: answer)
|
||||||
|
|
||||||
|
visit edit_admin_video_path(video)
|
||||||
|
|
||||||
|
fill_in "Title", with: title
|
||||||
|
fill_in "External video", with: url
|
||||||
|
|
||||||
|
click_button "Save"
|
||||||
|
|
||||||
|
expect(page).to have_content title
|
||||||
|
expect(page).to have_content url
|
||||||
|
end
|
||||||
|
|
||||||
|
scenario "Destroy" do
|
||||||
|
video = create(:poll_answer_video, answer: answer)
|
||||||
|
|
||||||
|
visit admin_answer_videos_path(answer)
|
||||||
|
|
||||||
|
within("#poll_question_answer_video_#{video.id}") do
|
||||||
|
accept_confirm("Are you sure? This action will delete \"#{video.title}\" and can't be undone.") do
|
||||||
|
click_button "Delete"
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
expect(page).to have_content "Answer video deleted successfully."
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|||||||
Reference in New Issue
Block a user