require "rails_helper" RSpec.describe ButtonsHelper do describe ".link_to_edl_file_download" do before :each do helper.instance_variable_set(:@virtual_path, "video_analyses.show") end context "when video has edl_file" do let(:edl_file) { double(:edl_file, signed_id: "signed_id", filename: "filename", attached?: true) } let(:video) { instance_double(Video, edl_file: edl_file) } it "returns HTML anchor tag with link to EDL file download" do expect(helper.link_to_edl_file_download(video)).to eq <<-HTML.gsub(/\n/, '').gsub(/\s+ Download EDL HTML end end context "when video does not have edl_file" do let(:edl_file) { double(:edl_file, attached?: false) } let(:video) { instance_double(Video, edl_file: edl_file) } it "returns disabled HTML anchor tag" do expect(helper.link_to_edl_file_download(video)).to eq <<-HTML.gsub(/\n/, '').gsub(/\s+ Download EDL HTML end end end describe ".link_to_graphics_only_edl_file_download" do before :each do helper.instance_variable_set(:@virtual_path, "video_analyses.show") end context "when video has graphics_only_edl_file" do let(:graphics_only_edl_file) { double(:graphics_only_edl_file, signed_id: "signed_id", filename: "filename", attached?: true) } let(:video) { instance_double(Video, graphics_only_edl_file: graphics_only_edl_file) } it "returns HTML anchor tag with link to EDL file download" do expect(helper.link_to_graphics_only_edl_file_download(video)).to eq <<-HTML.gsub(/\n/, '').gsub(/\s+ Download Graphics Only EDL HTML end end context "when video does not have graphics_only_edl_file" do let(:graphics_only_edl_file) { double(:graphics_only_edl_file, attached?: false) } let(:video) { instance_double(Video, graphics_only_edl_file: graphics_only_edl_file) } it "returns disabled HTML anchor tag" do expect(helper.link_to_graphics_only_edl_file_download(video)).to eq <<-HTML.gsub(/\n/, '').gsub(/\s+ Download Graphics Only EDL HTML end end end describe ".link_to_audio_only_edl_file_download" do before :each do helper.instance_variable_set(:@virtual_path, "video_analyses.show") end context "when video has audio_only_edl_file" do let(:audio_only_edl_file) { double(:audio_only_edl_file, signed_id: "signed_id", filename: "filename", attached?: true) } let(:video) { instance_double(Video, audio_only_edl_file: audio_only_edl_file) } it "returns HTML anchor tag with link to EDL file download" do expect(helper.link_to_audio_only_edl_file_download(video)).to eq <<-HTML.gsub(/\n/, '').gsub(/\s+ Download Audio Only EDL HTML end end context "when video does not have audio_only_edl_file" do let(:audio_only_edl_file) { double(:audio_only_edl_file, attached?: false) } let(:video) { instance_double(Video, audio_only_edl_file: audio_only_edl_file) } it "returns disabled HTML anchor tag" do expect(helper.link_to_audio_only_edl_file_download(video)).to eq <<-HTML.gsub(/\n/, '').gsub(/\s+ Download Audio Only EDL HTML end end end describe "#button_to_release_report" do context "when reports have not been published" do let(:video) { build(:video) } before :each do helper.instance_variable_set(:@virtual_path, "videos.video") end it "returns html for disabled release report button" do html = helper.button_to_release_report(video, content: "button content", disabled: true) expect(html).to match "Generating..." end end context "for a Discovery client" do let(:video) { build(:video, id: 45, project: build(:project, :discovery_client)) } it "returns html for Discovery reports" do html = helper.button_to_release_report(video, content: "button content") expect(html).to match "Download Discovery Documents" expect(html).to match "Production Elements Log" expect(html).to match "en/videos/45/video_reports.xlsx\\?type=discovery" expect(html).to match "GFX Cue List" expect(html).to match "en/videos/45/graphic_reports.xlsx\\?type=discovery" expect(html).to match "BiG Music Cue Sheet" expect(html).to match "en/videos/45/audio_reports.xlsx\\?type=big" expect(html).to match "Music Cue Sheet" expect(html).to match "en/videos/45/audio_reports.xlsx\\?type=discovery" expect(html).to match "Issues and Concerns Report" expect(html).to match "en/videos/45/issues_and_concerns_reports.xlsx" end end context "for a Nat Geo client" do let(:video) { build(:video, id: 45, project: build(:project, :nat_geo_client)) } it "returns html for Net Geo reports" do html = helper.button_to_release_report(video, content: "button content") expect(html).to match "Download Nat Geo Documents" expect(html).to match "Legal Binder Log" expect(html).to match "en/videos/45/video_reports.xlsx\\?type=nat_geo" expect(html).to match "Text Graphics Log" expect(html).to match "en/videos/45/graphic_reports.xlsx\\?type=nat_geo" expect(html).to match "BiG Music Cue Sheet" expect(html).to match "en/videos/45/audio_reports.xlsx\\?type=big" expect(html).to match "Music Cue Sheet" expect(html).to match "en/videos/45/audio_reports.xlsx\\?type=nat_geo" expect(html).to match "Original Music Log" expect(html).to match "en/videos/45/audio_reports.xlsx\\?type=nat_geo-original" expect(html).to match "Issues and Concerns Report" expect(html).to match "en/videos/45/issues_and_concerns_reports.xlsx" end end context "for any other client" do let(:video) { build(:video, id: 45, project: build(:project, client_name: "Other")) } it "returns html for Discovery reports" do html = helper.button_to_release_report(video, content: "button content") expect(html).to match "Download Discovery Documents" expect(html).to match "Production Elements Log" expect(html).to match "en/videos/45/video_reports.xlsx\\?type=discovery" expect(html).to match "GFX Cue List" expect(html).to match "en/videos/45/graphic_reports.xlsx\\?type=discovery" expect(html).to match "BiG Music Cue Sheet" expect(html).to match "en/videos/45/audio_reports.xlsx\\?type=big" expect(html).to match "Music Cue Sheet" expect(html).to match "en/videos/45/audio_reports.xlsx\\?type=discovery" expect(html).to match "Issues and Concerns Report" expect(html).to match "en/videos/45/issues_and_concerns_reports.xlsx" end end end end