Initial commit
This commit is contained in:
4
spec/helpers/application_helper_spec.rb
Normal file
4
spec/helpers/application_helper_spec.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe ApplicationHelper, type: :helper do
|
||||
end
|
||||
171
spec/helpers/buttons_helper_spec.rb
Normal file
171
spec/helpers/buttons_helper_spec.rb
Normal file
@@ -0,0 +1,171 @@
|
||||
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+</, '<')
|
||||
<a class="dropdown-item" target="_blank" href="/rails/active_storage/blobs/signed_id/filename?disposition=inline">
|
||||
<i class="fa fa-file-excel-o"></i> Download EDL</a>
|
||||
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+</, '<')
|
||||
<a class="dropdown-item">
|
||||
<i class="fa fa-file-excel-o"></i> Download EDL</a>
|
||||
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+</, '<')
|
||||
<a class="dropdown-item" target="_blank" href="/rails/active_storage/blobs/signed_id/filename?disposition=inline">
|
||||
<i class="fa fa-file-excel-o"></i> Download Graphics Only EDL</a>
|
||||
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+</, '<')
|
||||
<a class="dropdown-item">
|
||||
<i class="fa fa-file-excel-o"></i> Download Graphics Only EDL</a>
|
||||
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+</, '<')
|
||||
<a class="dropdown-item" target="_blank" href="/rails/active_storage/blobs/signed_id/filename?disposition=inline">
|
||||
<i class="fa fa-file-excel-o"></i> Download Audio Only EDL</a>
|
||||
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+</, '<')
|
||||
<a class="dropdown-item">
|
||||
<i class="fa fa-file-excel-o"></i> Download Audio Only EDL</a>
|
||||
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
|
||||
23
spec/helpers/cards_helper_spec.rb
Normal file
23
spec/helpers/cards_helper_spec.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe CardsHelper, type: :helper do
|
||||
describe "#card_header" do
|
||||
it "includes a heading element" do
|
||||
header = helper.card_header(text: "Foo")
|
||||
|
||||
expect(header).to have_css "h1", text: "Foo"
|
||||
end
|
||||
|
||||
it "includes subtext when present" do
|
||||
header = helper.card_header(subtext: "Bar")
|
||||
|
||||
expect(header).to have_css "small", text: "Bar"
|
||||
end
|
||||
|
||||
it "includes close button when present" do
|
||||
header = helper.card_header(close_action_path: "/foo")
|
||||
|
||||
expect(header).to have_css "a[href='/foo']", text: "Close"
|
||||
end
|
||||
end
|
||||
end
|
||||
35
spec/helpers/dropzone_helper_spec.rb
Normal file
35
spec/helpers/dropzone_helper_spec.rb
Normal file
@@ -0,0 +1,35 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe DropzoneHelper, type: :helper do
|
||||
describe "#dropzone_accepted_files_for" do
|
||||
it "accepts image files for appearance releases" do
|
||||
releasable = build(:appearance_release)
|
||||
expect(helper.dropzone_accepted_files_for(releasable)).to eq("image/*")
|
||||
end
|
||||
|
||||
it "accepts image files for talent releases" do
|
||||
releasable = build(:talent_release)
|
||||
expect(helper.dropzone_accepted_files_for(releasable)).to eq("image/*")
|
||||
end
|
||||
|
||||
it "accepts image files for location releases" do
|
||||
releasable = build(:location_release)
|
||||
expect(helper.dropzone_accepted_files_for(releasable)).to eq("image/*")
|
||||
end
|
||||
|
||||
it "accepts image files for material releases" do
|
||||
releasable = build(:material_release)
|
||||
expect(helper.dropzone_accepted_files_for(releasable)).to eq("image/*")
|
||||
end
|
||||
|
||||
it "accepts audio files for music releases" do
|
||||
releasable = build(:music_release)
|
||||
expect(helper.dropzone_accepted_files_for(releasable)).to eq("audio/*")
|
||||
end
|
||||
|
||||
it "accepts any file for acquired media releases" do
|
||||
releasable = build(:acquired_media_release)
|
||||
expect(helper.dropzone_accepted_files_for(releasable)).to be_nil
|
||||
end
|
||||
end
|
||||
end
|
||||
47
spec/helpers/duration_helper_spec.rb
Normal file
47
spec/helpers/duration_helper_spec.rb
Normal file
@@ -0,0 +1,47 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe DurationHelper do
|
||||
describe '#convert_duration' do
|
||||
it 'returns the same value if the from and to are the same unit' do
|
||||
result = helper.convert_duration(60, from: :seconds, to: :seconds)
|
||||
|
||||
expect(result).to eq(60)
|
||||
end
|
||||
|
||||
it 'converts seconds into minutes' do
|
||||
result = helper.convert_duration(60, from: :seconds, to: :minutes)
|
||||
|
||||
expect(result).to eq(1)
|
||||
end
|
||||
|
||||
it 'converts seconds into hours' do
|
||||
result = helper.convert_duration(3600, from: :seconds, to: :hours)
|
||||
|
||||
expect(result).to eq(1)
|
||||
end
|
||||
|
||||
it 'converts minutes into seconds' do
|
||||
result = helper.convert_duration(1, from: :minutes, to: :seconds)
|
||||
|
||||
expect(result).to eq(60)
|
||||
end
|
||||
|
||||
it 'converts minutes into hours' do
|
||||
result = helper.convert_duration(60, from: :minutes, to: :hours)
|
||||
|
||||
expect(result).to eq(1)
|
||||
end
|
||||
|
||||
it 'converts hours into seconds' do
|
||||
result = helper.convert_duration(1, from: :hours, to: :seconds)
|
||||
|
||||
expect(result).to eq(3600)
|
||||
end
|
||||
|
||||
it 'converts hours into minutes' do
|
||||
result = helper.convert_duration(1, from: :hours, to: :minutes)
|
||||
|
||||
expect(result).to eq(60)
|
||||
end
|
||||
end
|
||||
end
|
||||
51
spec/helpers/images_helper_spec.rb
Normal file
51
spec/helpers/images_helper_spec.rb
Normal file
@@ -0,0 +1,51 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe ImagesHelper do
|
||||
describe "#thumbnail_variant" do
|
||||
it "calls variant with orient and size options" do
|
||||
attachment = double(:attachment)
|
||||
allow(attachment).to receive(:variant)
|
||||
|
||||
helper.thumbnail_variant(attachment)
|
||||
|
||||
expect(attachment).to have_received(:variant).with(
|
||||
gravity: "center",
|
||||
resize: "75x75>",
|
||||
extent: "75x75",
|
||||
background: "#fff",
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#medium_variant" do
|
||||
it "calls variant with orient and size options" do
|
||||
attachment = double(:attachment)
|
||||
allow(attachment).to receive(:variant)
|
||||
|
||||
helper.medium_variant(attachment)
|
||||
|
||||
expect(attachment).to have_received(:variant).with(
|
||||
gravity: "center",
|
||||
resize: "100x100>",
|
||||
extent: "100x100",
|
||||
background: "#fff",
|
||||
)
|
||||
end
|
||||
end
|
||||
|
||||
describe "#large_variant" do
|
||||
it "calls variant with orient and size options" do
|
||||
attachment = double(:attachment)
|
||||
allow(attachment).to receive(:variant)
|
||||
|
||||
helper.large_variant(attachment)
|
||||
|
||||
expect(attachment).to have_received(:variant).with(
|
||||
gravity: "center",
|
||||
resize: "150x150>",
|
||||
extent: "150x150",
|
||||
background: "#fff",
|
||||
)
|
||||
end
|
||||
end
|
||||
end
|
||||
16
spec/helpers/mail_helper_spec.rb
Normal file
16
spec/helpers/mail_helper_spec.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe MailHelper, type: :helper do
|
||||
describe "#mail_to_for_multiple_edls" do
|
||||
it "generates a mailto link with the project info" do
|
||||
project = build(:project, name: "Test Project", account: build(:account, name: "Test Account"))
|
||||
|
||||
link = CGI.unescape helper.mail_to_for_multiple_edls("test content", project)
|
||||
|
||||
expect(link).to match "test content"
|
||||
expect(link).to match "info@bigmedia.ai"
|
||||
expect(link).to match /Multiple Adobe Premiere EDLs needed for Test Account's Test Project project/
|
||||
expect(link).to match "INSTRUCTIONS"
|
||||
end
|
||||
end
|
||||
end
|
||||
21
spec/helpers/note_categories_helper_spec.rb
Normal file
21
spec/helpers/note_categories_helper_spec.rb
Normal file
@@ -0,0 +1,21 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe NoteCategoriesHelper do
|
||||
describe ".options_for_note_category_select" do
|
||||
it "returns human readable options for note categories" do
|
||||
|
||||
unreleased_appearance = instance_double("UnreleasedAppearance", note_category: "missing_location_release")
|
||||
|
||||
results = helper.options_for_note_category_select(unreleased_appearance)
|
||||
|
||||
expect(results).to match /<option value="missing_talent_release">Missing talent release<\/option>/
|
||||
expect(results).to match /<option value="missing_appearance_release">Missing appearance release<\/option>/
|
||||
expect(results).to match /<option selected="selected" value="missing_location_release">Missing location release<\/option>/
|
||||
expect(results).to match /<option value="missing_acquired_media_license">Missing acquired media license<\/option>/
|
||||
expect(results).to match /<option value="missing_materials_release">Missing materials release<\/option>/
|
||||
expect(results).to match /<option value="missing_music_license">Missing music license<\/option>/
|
||||
expect(results).to match /<option value="logo_may_require_blurring">Logo may require blurring<\/option>/
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
39
spec/helpers/notes_helper_spec.rb
Normal file
39
spec/helpers/notes_helper_spec.rb
Normal file
@@ -0,0 +1,39 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe NotesHelper, type: :helper do
|
||||
describe "#notes_preview" do
|
||||
it "shows the content, timestamp, and author of the first note" do
|
||||
note = build(:note,
|
||||
content: "Note content",
|
||||
created_at: 1.minute.ago,
|
||||
user: build(:user, email: "author@example.org"),
|
||||
email: "author@example.org"
|
||||
)
|
||||
|
||||
preview = helper.notes_preview([note])
|
||||
|
||||
expect(preview).to include("Note content")
|
||||
expect(preview).to include("1 minute ago")
|
||||
expect(preview).to include("author@example.org")
|
||||
end
|
||||
|
||||
context "when there are no notes" do
|
||||
it "returns nothing" do
|
||||
preview = helper.notes_preview([])
|
||||
|
||||
expect(preview).to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
context "when there is more than one note" do
|
||||
it "includes a link to an action that shows all notes" do
|
||||
releasable = build_stubbed(:appearance_release)
|
||||
notes = build_list(:note, 2, created_at: 1.minute.ago, notable: releasable)
|
||||
|
||||
preview = helper.notes_preview(notes)
|
||||
|
||||
expect(preview).to have_link("1 more note", href: url_for([releasable, :notes, locale: I18n.locale]))
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
32
spec/helpers/plans_helper_spec.rb
Normal file
32
spec/helpers/plans_helper_spec.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe PlansHelper, type: :helper do
|
||||
describe "#lock_icon_for" do
|
||||
it "returns an unlocked icon when account has access to the given product" do
|
||||
mesuite = build(:account, :mesuite)
|
||||
releaseme = build(:account, :releaseme)
|
||||
deliverme = build(:account, :deliverme)
|
||||
|
||||
expect(helper.lock_icon_for(mesuite, :releaseme)).to match "unlock"
|
||||
expect(helper.lock_icon_for(mesuite, :deliverme)).to match "unlock"
|
||||
expect(helper.lock_icon_for(releaseme, :releaseme)).to match "unlock"
|
||||
expect(helper.lock_icon_for(deliverme, :deliverme)).to match "unlock"
|
||||
end
|
||||
|
||||
it "returns a locked icon when the user does not have access to the given product" do
|
||||
no_releaseme = build(:account, :deliverme)
|
||||
no_deliverme = build(:account, :releaseme)
|
||||
|
||||
expect(helper.lock_icon_for(no_releaseme, :releaseme)).to match "lock"
|
||||
expect(helper.lock_icon_for(no_deliverme, :deliverme)).to match "lock"
|
||||
end
|
||||
|
||||
it "includes any passed in text" do
|
||||
releaseme = build(:account, :releaseme)
|
||||
|
||||
expect(helper.lock_icon_for(releaseme, :releaseme, text: "Test")).to match "Test"
|
||||
expect(helper.lock_icon_for(releaseme, :deliverme, text: "Test")).to match "Test"
|
||||
|
||||
end
|
||||
end
|
||||
end
|
||||
25
spec/helpers/project_client_helper_spec.rb
Normal file
25
spec/helpers/project_client_helper_spec.rb
Normal file
@@ -0,0 +1,25 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe ProjectClientHelper, type: :helper do
|
||||
describe "selected_project_client_value" do
|
||||
context "when project having predefined client" do
|
||||
let(:project) { create(:project, :nat_geo_client) }
|
||||
|
||||
subject { helper.selected_project_client_value(project) }
|
||||
|
||||
it "returns correct value" do
|
||||
expect(subject).to match "nat_geo"
|
||||
end
|
||||
end
|
||||
|
||||
context "when project having other client" do
|
||||
let(:project) { create(:project) }
|
||||
|
||||
subject { helper.selected_project_client_value(project) }
|
||||
|
||||
it "returns correct value" do
|
||||
expect(subject).to match "other"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
32
spec/helpers/release_types_helper_spec.rb
Normal file
32
spec/helpers/release_types_helper_spec.rb
Normal file
@@ -0,0 +1,32 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe ReleaseTypesHelper do
|
||||
describe ".options_for_release_type_select" do
|
||||
context "when no arguments" do
|
||||
it "returns options for all signable release types" do
|
||||
results = helper.options_for_release_type_select
|
||||
expect(results).to match /<option value="appearance">Appearance Release<\/option>/
|
||||
expect(results).to match /<option selected="selected" value="talent">Talent Release<\/option>/
|
||||
expect(results).to match /<option value="material">Material Release<\/option>/
|
||||
expect(results).to match /<option value="location">Location Release<\/option>/
|
||||
end
|
||||
end
|
||||
|
||||
context "when project given" do
|
||||
let(:project) do
|
||||
create(:project).tap do |project|
|
||||
project.settings(:features).attributes = {
|
||||
appearance_release: false,
|
||||
talent_release: true,
|
||||
}
|
||||
end
|
||||
end
|
||||
|
||||
it "returns filtered options for signable release types enabled in project" do
|
||||
results = helper.options_for_release_type_select(project)
|
||||
expect(results).not_to match /<option value="appearance">Appearance Release<\/option>/
|
||||
expect(results).to match /<option selected="selected" value="talent">Talent Release<\/option>/
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
77
spec/helpers/tags_helper_spec.rb
Normal file
77
spec/helpers/tags_helper_spec.rb
Normal file
@@ -0,0 +1,77 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe TagsHelper, type: :helper do
|
||||
describe "#button_to_bulk_tagging" do
|
||||
let(:project) { build_stubbed(:project) }
|
||||
|
||||
subject { helper.button_to_bulk_tagging(project) }
|
||||
|
||||
it "renders content" do
|
||||
expect(subject).to match("tag_all")
|
||||
expect(subject).to match(t("shared.tag_multiple_releases"))
|
||||
end
|
||||
|
||||
it "routes to the bulk tagging path" do
|
||||
expect(subject).to match(new_bulk_tagging_path)
|
||||
expect(subject).to match("method=\"get\"")
|
||||
end
|
||||
|
||||
it "includes project_id as a parameter" do
|
||||
expect(subject).to match("name=\"project_id\"")
|
||||
expect(subject).to match("value=\"#{project.id}\"")
|
||||
end
|
||||
|
||||
it "includes a data attribute for the selected releasable ids" do
|
||||
expect(subject).to match("data-releasable-ids")
|
||||
end
|
||||
|
||||
it "is disabled by default" do
|
||||
expect(subject).to match("data-remote=\"true\"")
|
||||
end
|
||||
|
||||
it "disables when clicked" do
|
||||
expect(subject).to match("data-disable-with")
|
||||
end
|
||||
end
|
||||
|
||||
describe "#tags_preview" do
|
||||
let(:appearance_release) { create(:appearance_release) }
|
||||
|
||||
it "shows the names of tags if there are two or fewer tags" do
|
||||
appearance_release.tags.build(name: "Actor")
|
||||
appearance_release.tags.build(name: "Fresh")
|
||||
|
||||
preview = helper.tags_preview(appearance_release, appearance_release.tags)
|
||||
|
||||
expect(preview).to have_link("Actor", href: link_to_manage_tags(appearance_release))
|
||||
expect(preview).to have_link("Fresh", href: link_to_manage_tags(appearance_release))
|
||||
expect(preview).not_to have_link("1 more tag")
|
||||
end
|
||||
|
||||
context "when there are no tags" do
|
||||
it "returns nothing" do
|
||||
preview = helper.tags_preview(appearance_release, [])
|
||||
|
||||
expect(preview).to be_blank
|
||||
end
|
||||
end
|
||||
|
||||
context "when there is more than two tag" do
|
||||
it "includes a link to an action that shows all tags" do
|
||||
appearance_release.tags.build(name: "Actor")
|
||||
appearance_release.tags.build(name: "Fresh")
|
||||
appearance_release.tags.build(name: "Debut")
|
||||
|
||||
preview = helper.tags_preview(appearance_release, appearance_release.tags)
|
||||
|
||||
expect(preview).to have_link("1 more tag", href: link_to_manage_tags(appearance_release))
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
def link_to_manage_tags(taggable)
|
||||
url_for([:new, taggable, :acts_as_taggable_on_tag, locale: I18n.locale])
|
||||
end
|
||||
end
|
||||
29
spec/helpers/wordmark_helper_spec.rb
Normal file
29
spec/helpers/wordmark_helper_spec.rb
Normal file
@@ -0,0 +1,29 @@
|
||||
require "rails_helper"
|
||||
|
||||
RSpec.describe WordmarkHelper, type: :helper do
|
||||
describe "#suite_wordmark" do
|
||||
it "generates the proper markup" do
|
||||
html = helper.suite_wordmark
|
||||
|
||||
expect(html).to match "Me"
|
||||
expect(html).to match "Suite"
|
||||
expect(html).to match "suite-wordmark"
|
||||
end
|
||||
end
|
||||
|
||||
describe "#product_workmark" do
|
||||
it "generates the proper markup" do
|
||||
html = helper.product_wordmark(:release_me)
|
||||
|
||||
expect(html).to match "Release"
|
||||
expect(html).to match "Me"
|
||||
expect(html).to match "product-wordmark release-me"
|
||||
end
|
||||
|
||||
it "adds extra css classes" do
|
||||
html = helper.product_wordmark(:release_me, class: "extra-css")
|
||||
|
||||
expect(html).to match "product-wordmark release-me extra-css"
|
||||
end
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user