Add missing system specs for poll question answer videos

Minor change for replace @video.answer_id to @video.answer.
This commit is contained in:
taitus
2022-09-09 12:54:03 +02:00
parent 3d1a9501aa
commit 1ec793863b
3 changed files with 39 additions and 13 deletions

View File

@@ -25,8 +25,7 @@ class Admin::Poll::Questions::Answers::VideosController < Admin::Poll::BaseContr
def update
if @video.update(video_params)
redirect_to admin_answer_videos_path(@video.answer_id),
notice: t("flash.actions.save_changes.notice")
redirect_to admin_answer_videos_path(@video.answer), notice: t("flash.actions.save_changes.notice")
else
render :edit
end

View File

@@ -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>

View File

@@ -1,26 +1,53 @@
require "rails_helper"
describe "Videos", :admin do
scenario "Create" do
question = create(:poll_question)
answer = create(:poll_question_answer, question: question)
video_title = "'Magical' by Junko Ohashi"
video_url = "https://www.youtube.com/watch?v=-JMf43st-1A"
let!(:question) { create(:poll_question) }
let!(:answer) { create(:poll_question_answer, question: question) }
let(:title) { "'Magical' by Junko Ohashi" }
let(:url) { "https://www.youtube.com/watch?v=-JMf43st-1A" }
scenario "Create" do
visit admin_question_path(question)
within("#poll_question_answer_#{answer.id}") do
click_link "Video list"
end
click_link "Add video"
fill_in "poll_question_answer_video_title", with: video_title
fill_in "poll_question_answer_video_url", with: video_url
fill_in "Title", with: title
fill_in "External video", with: url
click_button "Save"
expect(page).to have_content(video_title)
expect(page).to have_content(video_url)
expect(page).to have_content title
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