Compare commits

...

11 Commits

Author SHA1 Message Date
Bilal
76940714b0 fix buttons position 2020-09-07 13:34:18 +03:00
Bilal
08a07c2a22 fix specs 2020-09-07 13:19:46 +03:00
Bilal
25fa534760 improve Download button for Talent releases 2020-09-07 13:07:27 +03:00
Bilal
c32e8f5109 improve Download button for Music releases 2020-09-07 13:03:01 +03:00
Bilal
f7c5bb7b0f improve Download button for Misc releases 2020-09-07 13:00:38 +03:00
Bilal
7d93d89e8e improve Download button for Medical releases 2020-09-07 12:54:00 +03:00
Bilal
4128d96941 improve Download button for Material releases 2020-09-07 12:47:31 +03:00
Bilal
1cf18e8f85 fix search match specs for generating contracts 2020-09-07 12:41:55 +03:00
Bilal
3694817fef improve Download button for Location releases 2020-09-07 12:15:09 +03:00
Bilal
a77cf9344c improve Download button for Acq.Media releases 2020-09-07 12:04:34 +03:00
Senad Uka
e5ac3e9345 Upstream sync 2020-09-06 21:42:50 +02:00
38 changed files with 403 additions and 82 deletions

View File

@@ -0,0 +1,20 @@
$(document).on("click", "#download_releases", function(event) {
event.preventDefault();
const releasable_ids = JSON.parse($("#selected_releases_form").attr('data-releasable-ids'));
const total_entries = $('#total_entries').val();
const input_ids = $('<input>').attr({ type: 'hidden', name: 'release_ids', value: JSON.stringify(releasable_ids) });
const search_query = $('<input>').attr({ type: 'hidden', name: 'search_query', value: $("form input[type='search']").val() });
const type_filter = $('<input>').attr({ type: 'hidden', name: 'type_filter', value: $('#type_filter_value').val() });
const download_count = releasable_ids.length > 0 ? releasable_ids.length : total_entries;
$(this).parent().append(input_ids);
$(this).parent().append(search_query);
$(this).parent().append(type_filter);
if (confirm(`${download_count} release(s) will be downloaded. Is this correct?`)){
Rails.fire($(this).parent()[0], 'submit');
}
});

View File

@@ -1,8 +1,4 @@
$(document).on("click", "[data-behavior=play_recording]", function() { $(document).on("click", "[data-behavior=play_recording]", function() {
if ($(this).hasClass('active')){
return false;
}
$("#broadcast_video").data('videoType', 'recording'); $("#broadcast_video").data('videoType', 'recording');
var playback_url = $(this).attr("data-playback-url") var playback_url = $(this).attr("data-playback-url")
@@ -16,13 +12,6 @@ $(document).on("click", "[data-behavior=play_recording]", function() {
height: '100%', height: '100%',
autoPlay: true autoPlay: true
}); });
$(".dropdown-menu").children().removeClass('active');
$(".dropdown-menu").children().children('i').remove();
$(this).siblings().removeClass('active');
$(this).siblings().children("i").remove();
$(this).addClass('active');
$(this).prepend('<i class="fa fa-check">&nbsp;</i>');
}); });
$(document).on("click", "[data-behavior=play_stream]", function() { $("#broadcast_video").data('videoType', 'stream'); }); $(document).on("click", "[data-behavior=play_stream]", function() { $("#broadcast_video").data('videoType', 'stream'); });

View File

@@ -45,13 +45,14 @@ class Api::ReleasesController < Api::ApiController
if model_name == "acquired_media_release" if model_name == "acquired_media_release"
mapping = { mapping = {
"#{model_name.camelize}": SerializableAcquiredMediaRelease, "#{model_name.camelize}": SerializableAcquiredMediaRelease,
FileInfo: SerializableFileInfo FileInfo: SerializableFileInfo,
"ActiveStorage::Attachment".to_sym => ActiveStorage::SerializableAttachment,
} }
render jsonapi: release, render jsonapi: release,
status: status, status: status,
class: mapping, class: mapping,
include: [:file_infos] include: [:files, :file_infos]
else else
mapping = { mapping = {
"#{model_name.camelize}": show_serializable, "#{model_name.camelize}": show_serializable,

View File

@@ -7,28 +7,41 @@ class ContractDownloadsController < ApplicationController
def create def create
authorize policy_scope(Download).create authorize policy_scope(Download).create
fetch_releases
download = @project.downloads.create!(release_type: params[:release_type]) download = @project.downloads.create!(release_type: release_type)
other_downloads_in_progress = @project.downloads.unfinished_desc_order.offset(1) other_downloads_in_progress = @project.downloads.unfinished_desc_order.offset(1)
if other_downloads_in_progress.any? if other_downloads_in_progress.any?
in_progress_downloads_details = render_to_string "_other_pending_downloads", locals: { downloads: other_downloads_in_progress, release_type: params[:release_type] }, :layout => false in_progress_downloads_details = render_to_string "_other_pending_downloads", locals: { downloads: other_downloads_in_progress, release_type: release_type }, :layout => false
ProjectsChannel.broadcast_download_generation_update(download, in_progress_downloads_details) ProjectsChannel.broadcast_download_generation_update(download, in_progress_downloads_details)
else else
ProjectsChannel.broadcast_download_generation_update(download, I18n.t("contract_downloads.download.pending", release_type: params[:release_type].titleize)) ProjectsChannel.broadcast_download_generation_update(download, I18n.t("contract_downloads.download.pending", release_type: release_type.titleize))
end end
GenerateContractsZipJob.perform_later(@project, download, params[:release_type], @releases.ids) GenerateContractsZipJob.perform_later(@project, download, release_type, release_ids, search_query, type_filter)
end end
private private
def fetch_releases def release_type
@releases = policy_scope(@project.public_send(releases)) params[:release_type]
end end
def releases def search_query
params[:release_type].constantize.model_name.plural params[:search_query]
end
def type_filter
params[:type_filter]
end
def release_ids
JSON.parse(params[:release_ids])
rescue StandardError
[]
end
def release_name(release_type)
release_type.constantize.model_name.plural
end end
end end

View File

@@ -4,4 +4,16 @@ class PagesController < ApplicationController
skip_after_action :verify_authorized skip_after_action :verify_authorized
skip_after_action :verify_policy_scoped skip_after_action :verify_policy_scoped
skip_before_action :require_login skip_before_action :require_login
layout :layout_for_page
private
def layout_for_page
case params[:id]
when 'nanocosmos_player'
false
else
end
end
end end

View File

@@ -17,6 +17,7 @@ module TagsHelper
disable_with: disabled_content, disable_with: disabled_content,
}, },
form: { form: {
id: "selected_releases_form",
data: { data: {
releasable_ids: [], releasable_ids: [],
}, },

View File

@@ -7,13 +7,14 @@ class GenerateContractsZipJob < ApplicationJob
@project = job.arguments.first @project = job.arguments.first
@download = job.arguments.second @download = job.arguments.second
@release_type = job.arguments.third @release_type = job.arguments.third
@folder_name = "#{@project.name.parameterize}_#{get_release_name(@release_type).gsub('_', '-')}" @release_ids = job.arguments.fourth
@search_query = job.arguments.fifth
@type_filter = job.arguments[5]
@folder_name = "#{@project.name.parameterize}_#{release_name.gsub('_', '-')}"
@download.update!(name: @folder_name, status: :pending) @download.update!(name: @folder_name, status: :pending)
end end
def perform(project, download, release_type, release_ids) def perform(project, download, release_type, release_ids, search_query, type_filter)
releases = project.public_send(get_release_name(release_type)).where(id: release_ids)
::ReleaseContractCollectionService.new(releases, @folder_name).build do |dir, files| ::ReleaseContractCollectionService.new(releases, @folder_name).build do |dir, files|
zipfile_name = "#{dir}/#{@folder_name}.zip" zipfile_name = "#{dir}/#{@folder_name}.zip"
Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile| Zip::File.open(zipfile_name, Zip::File::CREATE) do |zipfile|
@@ -61,7 +62,32 @@ class GenerateContractsZipJob < ApplicationJob
end end
end end
def get_release_name(release_type) def release_name
release_type.constantize.model_name.plural @release_type.constantize.model_name.plural
end
def all_releases
@project.public_send(release_name)
end
def releases
if @release_ids.any?
return all_releases.where(id: @release_ids)
end
results = all_releases
if all_releases.respond_to?(:complete, :incomplete)
results = case @type_filter
when 'complete'
all_releases.complete
when 'incomplete'
all_releases.incomplete
else
all_releases
end
end
results = results.search(@search_query) if @search_query.present?
results
end end
end end

View File

@@ -12,10 +12,10 @@ class BroadcastRecordingPolicy < ApplicationPolicy
end end
def edit? def edit?
destroy? true
end end
def update? def update?
edit? true
end end
end end

View File

@@ -17,4 +17,14 @@ class SerializableAcquiredMediaRelease < JSONAPI::Serializable::Resource
{ count: @object.file_infos.size } { count: @object.file_infos.size }
end end
end end
has_many :files do
data do
@object.files
end
meta do
{ count: @object.files.size }
end
end
end end

View File

@@ -1,5 +1,9 @@
class SerializableUser < JSONAPI::Serializable::Resource class SerializableUser < JSONAPI::Serializable::Resource
type "user" type "user"
attributes :email attributes :email, :full_name
attribute :company_name do
@object.primary_account.name
end
end end

View File

@@ -24,7 +24,7 @@ class ReleaseContractCollectionService
end end
files = Dir.entries("#{dir}/").select { |f| !File.directory? f } files = Dir.entries("#{dir}/").select { |f| !File.directory? f }
raise StandardError.new "Contracts or Contract Templates not found." unless files.any? # raise StandardError.new "Contracts or Contract Templates not found." unless files.any?
yield(dir, files) yield(dir, files)
} }
end end

View File

@@ -1,8 +1,11 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<input id="total_entries" type=hidden value=<%= @acquired_media_releases.total_entries %> />
<div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3"> <div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3">
<% if policy(AcquiredMediaRelease).new? %> <% if policy(AcquiredMediaRelease).new? %>
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :acquired_media_release], class: "btn btn-primary mr-2 mb-2" %> <div class="mr-auto">
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :acquired_media_release], class: "btn btn-primary mr-2 mb-2" %>
</div>
<% end %> <% end %>
<% if @acquired_media_releases.any? && policy(AcquiredMediaRelease).tag_multiple? %> <% if @acquired_media_releases.any? && policy(AcquiredMediaRelease).tag_multiple? %>
@@ -10,7 +13,7 @@
<% end %> <% end %>
<% if @acquired_media_releases.any? && policy(AcquiredMediaRelease).download_multiple? %> <% if @acquired_media_releases.any? && policy(AcquiredMediaRelease).download_multiple? %>
<%= link_to "Download All", [@project, :contract_downloads, release_type: @acquired_media_releases.name], method: :post, remote: true, class: "btn btn-light border ml-auto mr-2 mb-2", data: { <%= button_to "Download", [@project, :contract_downloads, release_type: @acquired_media_releases.name], id: "download_releases", method: :post, remote: true, class: "btn btn-light border mr-2 mb-2", data: {
disable_with: "Please wait..." } %> disable_with: "Please wait..." } %>
<% end %> <% end %>

View File

@@ -1,3 +1,5 @@
$("#acquired_media_releases").html("<%= j render(@acquired_media_releases) %>"); $("#acquired_media_releases").html("<%= j render(@acquired_media_releases) %>");
$("form input[type='search']").val("<%= params[:query] %>"); $("form input[type='search']").val("<%= params[:query] %>");
$("#acquired_media_releases_pagination").html("<%= j will_paginate(@acquired_media_releases) %>"); $("#acquired_media_releases_pagination").html("<%= j will_paginate(@acquired_media_releases) %>");
$("#selected_releases_form").attr('data-releasable-ids', JSON.stringify([]));
$("#total_entries").val(<%= @acquired_media_releases.total_entries %>);

View File

@@ -1,5 +1,6 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<input id="total_entries" type=hidden value=<%= @appearance_releases.total_entries %> />
<div id="upload-progress-container" class="mb-1"></div> <div id="upload-progress-container" class="mb-1"></div>
<div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-2"> <div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-2">
<% if policy(AppearanceRelease).new? %> <% if policy(AppearanceRelease).new? %>
@@ -16,7 +17,7 @@
<% end %> <% end %>
<% if @appearance_releases.any? && policy(AppearanceRelease).download_multiple? %> <% if @appearance_releases.any? && policy(AppearanceRelease).download_multiple? %>
<%= link_to "Download All", [@project, :contract_downloads, release_type: @appearance_releases.name], method: :post, remote: true, class: "btn btn-light border mr-2 mb-2", data: { disable_with: "Please wait..." } %> <%= button_to "Download", [@project, :contract_downloads, release_type: @appearance_releases.name], id: "download_releases", method: :post, remote: true, class: "btn btn-light border mr-2 mb-2", data: { disable_with: "Please wait..." } %>
<% end %> <% end %>
</div> </div>
</div> </div>

View File

@@ -3,3 +3,5 @@ $("form input[type='search']").val("<%= params[:query] %>");
$("#type_filter_actions").html("<%= j render 'type_filter_actions' %>"); $("#type_filter_actions").html("<%= j render 'type_filter_actions' %>");
$("#appearance_releases_pagination").html("<%= j will_paginate(@appearance_releases) %>"); $("#appearance_releases_pagination").html("<%= j will_paginate(@appearance_releases) %>");
$('#type_filter_value').val("<%= params[:type_filter] %>"); $('#type_filter_value').val("<%= params[:type_filter] %>");
$("#selected_releases_form").attr('data-releasable-ids', JSON.stringify([]));
$("#total_entries").val(<%= @appearance_releases.total_entries %>);

View File

@@ -3,12 +3,12 @@
<% recordings.each do |recording| %> <% recordings.each do |recording| %>
<div class="list-group-item list-group-item-action"> <div class="list-group-item list-group-item-action">
<div class="d-flex align-items-start"> <div class="d-flex align-items-start">
<% if (controller.class.module_parent.to_s != "Public" && policy(BroadcastRecording).update?) %> <% if policy(BroadcastRecording).update? %>
<%= link_to fa_icon("#{recording.starred ? 'star' : 'star-o'} fw"), [broadcast.project, broadcast, recording, :broadcast_recording_starrings], method: :post, class: "text-warning mr-3", remote: true %> <%= link_to fa_icon("#{recording.starred ? 'star' : 'star-o'} fw"), [broadcast.project, broadcast, recording, :broadcast_recording_starrings], method: :post, class: "text-warning mr-3", remote: true %>
<% end %> <% end %>
<%= image_tag(recording.thumbnail_url, class: 'img-thumbnail img-fluid max-w-75') %> <%= image_tag(recording.thumbnail_url, class: 'img-thumbnail img-fluid max-w-75', data: { behavior: "play_recording", playback_url: recording.playback_url, id: dom_id(recording) }) %>
<div class="ml-auto"> <div class="ml-auto">
<% if (controller.class.module_parent.to_s != "Public" && policy(BroadcastRecording).edit?) %> <% if policy(BroadcastRecording).edit? %>
<%= link_to fa_icon('edit'), [:edit, broadcast.project, broadcast, recording], remote: true %> <%= link_to fa_icon('edit'), [:edit, broadcast.project, broadcast, recording], remote: true %>
<% end %> <% end %>
<%= link_to(fa_icon('download'), recording.download_url, target: "_blank") %> <%= link_to(fa_icon('download'), recording.download_url, target: "_blank") %>

View File

@@ -9,4 +9,4 @@
</div> </div>
</div> </div>
</div> </div>
<hr/>

View File

@@ -22,11 +22,16 @@
<div class="d-flex justify-content-start align-items-center flex-row p-3 mb-5 bg-dark"> <div class="d-flex justify-content-start align-items-center flex-row p-3 mb-5 bg-dark">
<%= product_wordmark(:direct_me, class: 'navbar-brand text-white') %> <%= product_wordmark(:direct_me, class: 'navbar-brand text-white') %>
<div class="ml-4 dropdown"> <div class="ml-4 dropdown">
<%= link_to "#", class: "btn btn-light dropdown-toggle text-white bg-black border-0 override-dropdown-show-state", role: "button", id: "dropdownMenuLink", data: { toggle: "dropdown" }, aria: { haspopup: "true", expanded: "false" } do %> <% if @multi_view_broadcasts.present? %>
<i class="fa fa-video-camera text-primary" aria-hidden="true"></i><span class="ml-2" id="selected_stream"><%= @broadcast.name %></span> <%= link_to "#", class: "btn btn-light dropdown-toggle text-white bg-black border-0 override-dropdown-show-state", role: "button", id: "dropdownMenuLink", data: { toggle: "dropdown" }, aria: { haspopup: "true", expanded: "false" } do %>
<i class="fa fa-video-camera text-primary" aria-hidden="true"></i><span class="ml-2" id="selected_stream"><%= @broadcast.name %></span>
<% end %>
<% else %>
<%= link_to "javascript:void(0);", class: "btn btn-light text-white bg-black border-0 override-dropdown-show-state", role: "button", id: "dropdownMenuLink", aria: { haspopup: "true", expanded: "false" } do %>
<i class="fa fa-video-camera text-primary" aria-hidden="true"></i><span class="ml-2" id="selected_stream"><%= @broadcast.name %></span>
<% end %>
<% end %> <% end %>
<div class="dropdown-menu bg-black" aria-labelledby="dropdownMenuLink"> <div class="dropdown-menu bg-black" aria-labelledby="dropdownMenuLink">
<h5 class="dropdown-header">Live Streams</h5>
<%= link_to fa_icon("check", text: @broadcast.name.titleize), "#", data: { behavior: "play_stream"}, class: "dropdown-item active" %> <%= link_to fa_icon("check", text: @broadcast.name.titleize), "#", data: { behavior: "play_stream"}, class: "dropdown-item active" %>
<% @multi_view_broadcasts.each do |broadcast| %> <% @multi_view_broadcasts.each do |broadcast| %>
<% if broadcast.id != @broadcast.id %> <% if broadcast.id != @broadcast.id %>
@@ -120,6 +125,21 @@
<div id="live_take"> <div id="live_take">
<%= render partial: 'broadcasts/live_take', locals: { broadcast: @broadcast } %> <%= render partial: 'broadcasts/live_take', locals: { broadcast: @broadcast } %>
</div> </div>
<% if params[:director_mode] %>
<% if controller.class.module_parent.to_s == "Public" %>
<%= link_to "Play #{@broadcast.name.titleize}", url_for(params.permit!.merge(director_mode: true, token: @broadcast.token)), data: { behavior: "play_stream"}, class: "mt-2 btn btn-primary" %>
<% else %>
<%= link_to "Play #{@broadcast.name.titleize}", url_for(params.permit!.merge(director_mode: true, id: @broadcast.id)), data: { behavior: "play_stream"}, class: "mt-2 btn btn-primary" %>
<% end %>
<hr/>
<% else %>
<% if controller.class.module_parent.to_s == "Public" %>
<%= link_to "Play #{@broadcast.name.titleize}", url_for(params.permit!.merge(token: @broadcast.token).except(:director_mode)), data: { behavior: "play_stream"}, class: "mt-2 btn btn-primary" %>
<% else %>
<%= link_to "Play #{@broadcast.name.titleize}", url_for(params.permit!.merge(id: @broadcast.id).except(:director_mode)), data: { behavior: "play_stream"}, class: "mt-2 btn btn-primary" %>
<% end %>
<hr/>
<% end %>
<div id="broadcast_recordings"> <div id="broadcast_recordings">
<%= render partial: 'broadcasts/broadcast_recordings', locals: { recordings: @recordings, broadcast: @broadcast } %> <%= render partial: 'broadcasts/broadcast_recordings', locals: { recordings: @recordings, broadcast: @broadcast } %>
</div> </div>

View File

@@ -1,8 +1,11 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<input id="total_entries" type=hidden value=<%= @location_releases.total_entries %> />
<div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3"> <div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3">
<% if policy(LocationRelease).new? %> <% if policy(LocationRelease).new? %>
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :location_release], class: "btn btn-primary mr-2 mb-2" %> <div class="mr-auto">
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :location_release], class: "btn btn-primary mr-2 mb-2" %>
</div>
<% end %> <% end %>
<% if @location_releases.any? && policy(LocationRelease).tag_multiple? %> <% if @location_releases.any? && policy(LocationRelease).tag_multiple? %>
@@ -10,7 +13,7 @@
<% end %> <% end %>
<% if @location_releases.any? && policy(LocationRelease).download_multiple? %> <% if @location_releases.any? && policy(LocationRelease).download_multiple? %>
<%= link_to "Download All", [@project, :contract_downloads, release_type: @location_releases.name], method: :post, remote: true, class: "btn btn-light border ml-auto mr-2 mb-2", data: { <%= button_to "Download", [@project, :contract_downloads, release_type: @location_releases.name], id: "download_releases", method: :post, remote: true, class: "btn btn-light border mr-2 mb-2", data: {
disable_with: "Please wait..." } %> disable_with: "Please wait..." } %>
<% end %> <% end %>

View File

@@ -1,3 +1,5 @@
$("#location_releases").html("<%= j render(@location_releases) %>"); $("#location_releases").html("<%= j render(@location_releases) %>");
$("form input[type='search']").val("<%= params[:query] %>"); $("form input[type='search']").val("<%= params[:query] %>");
$("#location_releases_pagination").html("<%= j will_paginate(@location_releases) %>"); $("#location_releases_pagination").html("<%= j will_paginate(@location_releases) %>");
$("#selected_releases_form").attr('data-releasable-ids', JSON.stringify([]));
$("#total_entries").val(<%= @location_releases.total_entries %>);

View File

@@ -1,8 +1,11 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<input id="total_entries" type=hidden value=<%= @material_releases.total_entries %> />
<div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3"> <div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3">
<% if policy(MaterialRelease).new? %> <% if policy(MaterialRelease).new? %>
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :material_release], class: "btn btn-primary mr-2 mb-2" %> <div class="mr-auto">
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :material_release], class: "btn btn-primary mr-2 mb-2" %>
</div>
<% end %> <% end %>
<% if @material_releases.any? && policy(MaterialRelease).tag_multiple? %> <% if @material_releases.any? && policy(MaterialRelease).tag_multiple? %>
@@ -10,7 +13,7 @@
<% end %> <% end %>
<% if @material_releases.any? && policy(MaterialRelease).download_multiple? %> <% if @material_releases.any? && policy(MaterialRelease).download_multiple? %>
<%= link_to "Download All", [@project, :contract_downloads, release_type: @material_releases.name], method: :post, remote: true, class: "btn btn-light border ml-auto mr-2 mb-2", data: { <%= button_to "Download", [@project, :contract_downloads, release_type: @material_releases.name], id: "download_releases", method: :post, remote: true, class: "btn btn-light border mr-2 mb-2", data: {
disable_with: "Please wait..." } %> disable_with: "Please wait..." } %>
<% end %> <% end %>

View File

@@ -1,3 +1,5 @@
$("#material_releases").html("<%= j render(@material_releases) %>"); $("#material_releases").html("<%= j render(@material_releases) %>");
$("form input[type='search']").val("<%= params[:query] %>"); $("form input[type='search']").val("<%= params[:query] %>");
$("#material_releases_pagination").html("<%= j will_paginate(@material_releases) %>"); $("#material_releases_pagination").html("<%= j will_paginate(@material_releases) %>");
$("#selected_releases_form").attr('data-releasable-ids', JSON.stringify([]));
$("#total_entries").val(<%= @material_releases.total_entries %>);

View File

@@ -1,12 +1,15 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<input id="total_entries" type=hidden value=<%= @medical_releases.total_entries %> />
<div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3"> <div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3">
<% if @medical_releases.any? && policy(MedicalRelease).tag_multiple? %> <% if @medical_releases.any? && policy(MedicalRelease).tag_multiple? %>
<%= button_to_bulk_tagging(@project) %> <div class="ml-auto">
<%= button_to_bulk_tagging(@project) %>
</div>
<% end %> <% end %>
<% if @medical_releases.any? && policy(MedicalRelease).download_multiple? %> <% if @medical_releases.any? && policy(MedicalRelease).download_multiple? %>
<%= link_to "Download All", [@project, :contract_downloads, release_type: @medical_releases.name], method: :post, remote: true, class: "btn btn-light border ml-auto mr-2 mb-2", data: { <%= button_to "Download", [@project, :contract_downloads, release_type: @medical_releases.name], id: "download_releases", method: :post, remote: true, class: "btn btn-light border mr-2 mb-2", data: {
disable_with: "Please wait..." } %> disable_with: "Please wait..." } %>
<% end %> <% end %>

View File

@@ -1,3 +1,5 @@
$("#medical_releases").html("<%= j render(@medical_releases) %>"); $("#medical_releases").html("<%= j render(@medical_releases) %>");
$("form input[type='search']").val("<%= params[:query] %>"); $("form input[type='search']").val("<%= params[:query] %>");
$("#medical_releases_pagination").html("<%= j will_paginate(@medical_releases) %>"); $("#medical_releases_pagination").html("<%= j will_paginate(@medical_releases) %>");
$("#selected_releases_form").attr('data-releasable-ids', JSON.stringify([]));
$("#total_entries").val(<%= @medical_releases.total_entries %>);

View File

@@ -1,12 +1,15 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<input id="total_entries" type=hidden value=<%= @misc_releases.total_entries %> />
<div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3"> <div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3">
<% if @misc_releases.any? && policy(MiscRelease).tag_multiple? %> <% if @misc_releases.any? && policy(MiscRelease).tag_multiple? %>
<%= button_to_bulk_tagging(@project) %> <div class="ml-auto">
<%= button_to_bulk_tagging(@project) %>
</div>
<% end %> <% end %>
<% if @misc_releases.any? && policy(MiscRelease).download_multiple? %> <% if @misc_releases.any? && policy(MiscRelease).download_multiple? %>
<%= link_to "Download All", [@project, :contract_downloads, release_type: @misc_releases.name], method: :post, remote: true, class: "btn btn-light border ml-auto mr-2 mb-2", data: { <%= button_to "Download", [@project, :contract_downloads, release_type: @misc_releases.name], id: "download_releases", method: :post, remote: true, class: "btn btn-light border mr-2 mb-2", data: {
disable_with: "Please wait..." } %> disable_with: "Please wait..." } %>
<% end %> <% end %>

View File

@@ -1,3 +1,5 @@
$("#misc_releases").html("<%= j render(@misc_releases) %>"); $("#misc_releases").html("<%= j render(@misc_releases) %>");
$("form input[type='search']").val("<%= params[:query] %>"); $("form input[type='search']").val("<%= params[:query] %>");
$("#misc_releases_pagination").html("<%= j will_paginate(@misc_releases) %>"); $("#misc_releases_pagination").html("<%= j will_paginate(@misc_releases) %>");
$("#selected_releases_form").attr('data-releasable-ids', JSON.stringify([]));
$("#total_entries").val(<%= @misc_releases.total_entries %>);

View File

@@ -1,8 +1,11 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<input id="total_entries" type=hidden value=<%= @music_releases.total_entries %> />
<div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3"> <div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3">
<% if policy(MusicRelease).new? %> <% if policy(MusicRelease).new? %>
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :music_release], class: "btn btn-primary mr-2 mb-2" %> <div class="mr-auto">
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :music_release], class: "btn btn-primary mr-2 mb-2" %>
</div>
<% end %> <% end %>
<% if @music_releases.any? && policy(MusicRelease).tag_multiple? %> <% if @music_releases.any? && policy(MusicRelease).tag_multiple? %>
@@ -10,7 +13,7 @@
<% end %> <% end %>
<% if @music_releases.any? && policy(MusicRelease).download_multiple? %> <% if @music_releases.any? && policy(MusicRelease).download_multiple? %>
<%= link_to "Download All", [@project, :contract_downloads, release_type: @music_releases.name], method: :post, remote: true, class: "btn btn-light border ml-auto mr-2 mb-2" %> <%= button_to "Download", [@project, :contract_downloads, release_type: @music_releases.name], id: "download_releases", method: :post, remote: true, class: "btn btn-light border mr-2 mb-2" %>
<% end %> <% end %>
<%= bootstrap_form_with url: [@project, :music_releases], method: :get, remote: true, layout: :inline, id: "search" do |form| %> <%= bootstrap_form_with url: [@project, :music_releases], method: :get, remote: true, layout: :inline, id: "search" do |form| %>

View File

@@ -1,3 +1,5 @@
$("#music_releases").html("<%= j render(@music_releases) %>"); $("#music_releases").html("<%= j render(@music_releases) %>");
$("form input[type='search']").val("<%= params[:query] %>"); $("form input[type='search']").val("<%= params[:query] %>");
$("#music_releases_pagination").html("<%= j will_paginate(@music_releases) %>"); $("#music_releases_pagination").html("<%= j will_paginate(@music_releases) %>");
$("#selected_releases_form").attr('data-releasable-ids', JSON.stringify([]));
$("#total_entries").val(<%= @music_releases.total_entries %>);

View File

@@ -0,0 +1,45 @@
<div>
<div id="playerDiv"></div>
<script type="text/javascript" src="https://demo.nanocosmos.de/nanoplayer/api/release/nanoplayer.4.min.js"></script>
<%= javascript_tag nonce: true do %>
var urlParams = new URLSearchParams(window.location.search);
var streamName = urlParams.get('stream_name');
console.log("streamName", streamName);
var player;
var config = {
"source": {
"entries": [
{
"h5live": {
// your rtmp stream
"rtmp": {
"url": "rtmp://bintu-play.nanocosmos.de/play",
"streamname": streamName,
},
"server": {
"websocket": "wss://bintu-h5live.nanocosmos.de:443/h5live/stream.mp4",
"hls": "https://bintu-h5live.nanocosmos.de:443/h5live/http/playlist.m3u8",
"progressive": "https://bintu-h5live.nanocosmos.de:443/h5live/http/stream.mp4"
}
}
}
]
},
"style": {
"width": "auto",
}
};
function initPlayer() {
player = new NanoPlayer('playerDiv');
player.setup(config).then(function (config) {
console.log('setup ok with config: ' + JSON.stringify(config));
}, function (error) {
console.log(error);
});
}
// load player from playerDiv
document.addEventListener('DOMContentLoaded', function () {
initPlayer();
});
<% end %>
</div>

View File

@@ -1,8 +1,11 @@
<div class="row"> <div class="row">
<div class="col-md-12"> <div class="col-md-12">
<input id="total_entries" type=hidden value=<%= @talent_releases.total_entries %> />
<div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3"> <div class="d-md-flex d-sm-flex flex-sm-column flex-md-row flex-md-wrap mb-3">
<% if policy(TalentRelease).new? %> <% if policy(TalentRelease).new? %>
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :talent_release], class: "btn btn-primary mr-2 mb-2" %> <div class="mr-auto">
<%= link_to fa_icon("plus", text: t(".actions.new")), [:new, @project, :talent_release], class: "btn btn-primary mr-2 mb-2" %>
</div>
<% end %> <% end %>
<% if @talent_releases.any? && policy(TalentRelease).tag_multiple? %> <% if @talent_releases.any? && policy(TalentRelease).tag_multiple? %>
@@ -10,7 +13,7 @@
<% end %> <% end %>
<% if @talent_releases.any? && policy(TalentRelease).download_multiple? %> <% if @talent_releases.any? && policy(TalentRelease).download_multiple? %>
<%= link_to "Download All", [@project, :contract_downloads, release_type: @talent_releases.name], method: :post, remote: true, class: "btn btn-light border ml-auto mr-2 mb-2", data: { <%= button_to "Download", [@project, :contract_downloads, release_type: @talent_releases.name], id: "download_releases", method: :post, remote: true, class: "btn btn-light border mr-2 mb-2", data: {
disable_with: "Please wait..." } %> disable_with: "Please wait..." } %>
<% end %> <% end %>

View File

@@ -1,3 +1,5 @@
$("#talent_releases").html("<%= j render(@talent_releases) %>"); $("#talent_releases").html("<%= j render(@talent_releases) %>");
$("form input[type='search']").val("<%= params[:query] %>"); $("form input[type='search']").val("<%= params[:query] %>");
$("#talent_releases_pagination").html("<%= j will_paginate(@talent_releases) %>"); $("#talent_releases_pagination").html("<%= j will_paginate(@talent_releases) %>");
$("#selected_releases_form").attr('data-releasable-ids', JSON.stringify([]));
$("#total_entries").val(<%= @talent_releases.total_entries %>);

View File

@@ -9,12 +9,12 @@ Rails.application.config.content_security_policy do |policy|
policy.font_src :self, :https, :data policy.font_src :self, :https, :data
policy.img_src :self, :https, :data policy.img_src :self, :https, :data
policy.object_src :self policy.object_src :self
policy.script_src :self, :https, AppHost.new.domain_with_port, "https://stream.mux.com", :blob, :unsafe_eval policy.script_src :self, :https, AppHost.new.domain_with_port, "https://stream.mux.com", "https://demo.nanocosmos.de", :blob, :unsafe_eval
policy.media_src :self, :https, AppHost.new.domain_with_port, "https://stream.mux.com", :data, :blob policy.media_src :self, :https, AppHost.new.domain_with_port, "https://stream.mux.com", :data, :blob
# policy.style_src :self, :https, :unsafe_inline # policy.style_src :self, :https, :unsafe_inline
# If you are using webpack-dev-server then specify webpack-dev-server host # If you are using webpack-dev-server then specify webpack-dev-server host
# policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development? # policy.connect_src :self, :https, "http://localhost:3035", "ws://localhost:3035" if Rails.env.development?
policy.connect_src :self, :https, "ws://#{AppHost.new.domain_with_port}", "wss://#{AppHost.new.domain_with_port}" policy.connect_src :self, :https, "ws://#{AppHost.new.domain_with_port}", "wss://#{AppHost.new.domain_with_port}", "wss://bintu-h5live.nanocosmos.de"
# Specify URI for violation reports # Specify URI for violation reports
# policy.report_uri "/csp-violation-report-endpoint" # policy.report_uri "/csp-violation-report-endpoint"

View File

@@ -200,6 +200,7 @@ Rails.application.routes.draw do
get "cookies_disabled" => 'pages#show', id: "cookies_disabled", as: :cookies_disabled get "cookies_disabled" => 'pages#show', id: "cookies_disabled", as: :cookies_disabled
get "accountless_user" => 'pages#show', id: "accountless_user", as: :accountless_user get "accountless_user" => 'pages#show', id: "accountless_user", as: :accountless_user
get "nanocosmos_player" => 'pages#show', id: "nanocosmos_player", as: :nanocosmos_player
resource :session, only: [:new, :create] resource :session, only: [:new, :create]
resources :password_resets, only: [:new, :create, :edit, :update] resources :password_resets, only: [:new, :create, :edit, :update]

View File

@@ -30,6 +30,16 @@ RSpec.describe Api::AcquiredMediaReleasesController, type: :controller do
expect(response).to be_successful expect(response).to be_successful
end end
it 'contains files attachment data' do
tested_release = create(:acquired_media_release, name: 'ct1', project_id: project.id)
sign_in_to_api(current_user)
get :show, params: { id: tested_release.id }
expect(response.body).to match /file_infos/
expect(response.body).to match /files/
end
end end
describe '#create' do describe '#create' do

View File

@@ -14,6 +14,8 @@ RSpec.describe Api::ProfilesController, type: :controller do
expect(response).to be_successful expect(response).to be_successful
expect(response_body_data).to include('id' => current_user.to_param, 'type' => 'user') expect(response_body_data).to include('id' => current_user.to_param, 'type' => 'user')
expect(response_body_data_attributes).to include('email' => current_user.email) expect(response_body_data_attributes).to include('email' => current_user.email)
expect(response_body_data_attributes).to include('full_name' => current_user.full_name)
expect(response_body_data_attributes).to include('company_name' => current_user.primary_account.name)
end end
end end

View File

@@ -197,13 +197,13 @@ feature "User managing medical releases" do
expect(page).to have_css('i.fa.fa-check-circle.fa-2x', count: 1) expect(page).to have_css('i.fa.fa-check-circle.fa-2x', count: 1)
end end
scenario "Download All is visible" do scenario "Download button is visible" do
create(:medical_release_with_contract_template, :native, project: project) create(:medical_release_with_contract_template, :native, project: project)
create(:medical_release_with_contract_template, :non_native, project: project) create(:medical_release_with_contract_template, :non_native, project: project)
visit project_medical_releases_path(project) visit project_medical_releases_path(project)
expect(page).to have_content download_all_button expect(page).to have_content download_button
end end
scenario "Download action in Manage menu is visible" do scenario "Download action in Manage menu is visible" do
@@ -264,7 +264,7 @@ feature "User managing medical releases" do
visit project_medical_releases_path(project) visit project_medical_releases_path(project)
expect(page).not_to have_content download_all_button expect(page).not_to have_content download_button
end end
scenario "Download action in Manage menu is not visible" do scenario "Download action in Manage menu is not visible" do
@@ -308,7 +308,7 @@ feature "User managing medical releases" do
visit project_medical_releases_path(project) visit project_medical_releases_path(project)
expect(page).not_to have_content download_all_button expect(page).not_to have_content download_button
end end
scenario "Download action in Manage menu is not visible" do scenario "Download action in Manage menu is not visible" do
@@ -341,8 +341,8 @@ feature "User managing medical releases" do
private private
def download_all_button def download_button
'Download All' 'Download'
end end
def download_action def download_action

View File

@@ -62,12 +62,12 @@ feature "User managing misc releases" do
sign_in current_user sign_in current_user
end end
scenario "Download All is visible" do scenario "Download is visible" do
create(:misc_release_with_contract_template, :native, project: project) create(:misc_release_with_contract_template, :native, project: project)
visit project_misc_releases_path(project) visit project_misc_releases_path(project)
expect(page).to have_content download_all_button expect(page).to have_content download_button
end end
scenario "Downloading PDF of native misc release is possible" do scenario "Downloading PDF of native misc release is possible" do
@@ -145,8 +145,8 @@ feature "User managing misc releases" do
private private
def download_all_button def download_button
'Download All' 'Download'
end end
def view_release_pdf_link_for(release) def view_release_pdf_link_for(release)

View File

@@ -19,7 +19,7 @@ describe GenerateContractsZipJob do
describe ".perform_later" do describe ".perform_later" do
it "enqueues a background job for generating zip file" do it "enqueues a background job for generating zip file" do
expect { expect {
GenerateContractsZipJob.perform_later(project, download, "AppearanceRelease", project.appearance_releases.ids) GenerateContractsZipJob.perform_later(project, download, "AppearanceRelease", project.appearance_releases.ids, '', '')
}.to have_enqueued_job }.to have_enqueued_job
end end
end end
@@ -28,7 +28,7 @@ describe GenerateContractsZipJob do
shared_examples "generates ZIP containig CSV file with all releases data" do shared_examples "generates ZIP containig CSV file with all releases data" do
it "generates ZIP containing CSV file with all releases data for all release types" do it "generates ZIP containing CSV file with all releases data for all release types" do
lowercase_plural = subject.constantize.model_name.plural lowercase_plural = subject.constantize.model_name.plural
GenerateContractsZipJob.perform_now(project, download, subject, project.public_send(lowercase_plural).ids) GenerateContractsZipJob.perform_now(project, download, subject, project.public_send(lowercase_plural).ids, '', '')
generated_zip = download.file.blob.download generated_zip = download.file.blob.download
csv_file_name = "#{project.name.parameterize}_#{lowercase_plural.gsub('_', '-')}.csv" csv_file_name = "#{project.name.parameterize}_#{lowercase_plural.gsub('_', '-')}.csv"
@@ -50,8 +50,113 @@ describe GenerateContractsZipJob do
end end
end end
shared_examples "generates ZIP containig CSV file with specific releases data" do
it "generates ZIP containing CSV file with all selected releases data for selected releases" do
lowercase_plural = subject.constantize.model_name.plural
all_releases = project.public_send(lowercase_plural)
included_releases = all_releases.where(id: all_releases.ids[0..1])
not_included_releases = all_releases.where.not(id: all_releases.ids[0..1])
GenerateContractsZipJob.perform_now(project, download, subject, included_releases.ids, '', '')
generated_zip = download.file.blob.download
csv_file_name = "#{project.name.parameterize}_#{lowercase_plural.gsub('_', '-')}.csv"
Zip::InputStream.open(StringIO.new(generated_zip)) do |io|
while entry = io.get_next_entry
next unless entry.name == csv_file_name
csv_file = entry.get_input_stream.read
release_class = Object.const_get subject
release_headers = release_class.csv_headers
release_headers.each do |header|
expect(csv_file).to match header
expect(csv_file).not_to match translation_missing
end
included_releases.each do |release|
expect(csv_file).to match release.person_first_name
end
not_included_releases.each do |release|
expect(csv_file).not_to match release.person_first_name
end
end
end
end
it "generates ZIP containing CSV file with all filtered releases data for filtered releases" do
if subject.respond_to?(:complete) && subject.respond_to?(:incomplete)
lowercase_plural = subject.constantize.model_name.plural
GenerateContractsZipJob.perform_now(project, download, subject, [], '', 'complete')
complete_releases = project.public_send(lowercase_plural).complete
incomplete_releases = project.public_send(lowercase_plural).incomplete
generated_zip = download.file.blob.download
csv_file_name = "#{project.name.parameterize}_#{lowercase_plural.gsub('_', '-')}.csv"
Zip::InputStream.open(StringIO.new(generated_zip)) do |io|
while entry = io.get_next_entry
next unless entry.name == csv_file_name
csv_file = entry.get_input_stream.read
release_class = Object.const_get subject
release_headers = release_class.csv_headers
release_headers.each do |header|
expect(csv_file).to match header
expect(csv_file).not_to match translation_missing
end
complete_releases.each do |release|
expect(csv_file).to match release.person_first_name
end
incomplete_releases.each do |release|
expect(csv_file).not_to match release.person_first_name
end
end
end
end
end
it "generates ZIP containing CSV file with all search query matching releases" do
lowercase_plural = subject.constantize.model_name.plural
matched_releases = project.public_send(lowercase_plural).search('Brad')
not_matched_releases = project.public_send(lowercase_plural).where.not(id: matched_releases.ids)
GenerateContractsZipJob.perform_now(project, download, subject, [], 'Brad', '')
generated_zip = download.file.blob.download
csv_file_name = "#{project.name.parameterize}_#{lowercase_plural.gsub('_', '-')}.csv"
Zip::InputStream.open(StringIO.new(generated_zip)) do |io|
while entry = io.get_next_entry
next unless entry.name == csv_file_name
csv_file = entry.get_input_stream.read
release_class = Object.const_get subject
release_headers = release_class.csv_headers
release_headers.each do |header|
expect(csv_file).to match header
expect(csv_file).not_to match translation_missing
end
matched_releases.each do |release|
expect(csv_file).to match release.person_first_name
end
not_matched_releases.each do |release|
expect(csv_file).not_to match release.person_first_name
end
end
end
end
end
it "updates a download record and creates attachment for it" do it "updates a download record and creates attachment for it" do
GenerateContractsZipJob.perform_now(project, download, "AppearanceRelease", project.appearance_releases.ids) GenerateContractsZipJob.perform_now(project, download, "AppearanceRelease", project.appearance_releases.ids, '', '')
expect(download.project).to eq project expect(download.project).to eq project
expect(download.release_type).to eq "AppearanceRelease" expect(download.release_type).to eq "AppearanceRelease"
@@ -61,59 +166,83 @@ describe GenerateContractsZipJob do
end end
context "generates ZIP for acquired media releases" do context "generates ZIP for acquired media releases" do
let(:release) { create(:acquired_media_release_with_contract_template, :native, project: project) } let(:release) { create(:acquired_media_release_with_contract_template, :native, project: project, name: "John Doe") }
let(:release2) { create(:acquired_media_release_with_contract_template, :native, project: project, name: "Jane Doe") }
let(:release3) { create(:acquired_media_release_with_contract_template, :native, project: project, name: "Brad Doe") }
subject { 'AcquiredMediaRelease' } subject { 'AcquiredMediaRelease' }
it_behaves_like "generates ZIP containig CSV file with all releases data" it_behaves_like "generates ZIP containig CSV file with all releases data"
it_behaves_like "generates ZIP containig CSV file with specific releases data"
end end
context "generates ZIP for appearance releases" do context "generates ZIP for appearance releases" do
let(:release) { create(:appearance_release_with_contract_template, :native, project: project, person_name: "John Doe") } let(:release) { create(:appearance_release_with_contract_template, :native, project: project, person_name: "John") }
let(:incomplete_release) { create(:appearance_release_with_contract_template, project: project, person_name: "Jane") }
let(:complete_release) { create(:appearance_release_with_contract_template, :non_native, project: project, person_name: "Brad") }
subject { 'AppearanceRelease' } subject { 'AppearanceRelease' }
it_behaves_like "generates ZIP containig CSV file with all releases data" it_behaves_like "generates ZIP containig CSV file with all releases data"
it_behaves_like "generates ZIP containig CSV file with specific releases data"
end end
context "generates ZIP for location releases" do context "generates ZIP for location releases" do
let(:release) { create(:location_release_with_contract_template, :native, project: project) } let(:release) { create(:location_release_with_contract_template, :native, project: project, name: "John") }
let(:release2) { create(:location_release_with_contract_template, :native, project: project, name: "Jane") }
let(:release3) { create(:location_release_with_contract_template, :native, project: project, name: "Brad") }
subject { 'LocationRelease' } subject { 'LocationRelease' }
it_behaves_like "generates ZIP containig CSV file with all releases data" it_behaves_like "generates ZIP containig CSV file with all releases data"
it_behaves_like "generates ZIP containig CSV file with specific releases data"
end end
context "generates ZIP for material releases" do context "generates ZIP for material releases" do
let(:release) { create(:material_release_with_contract_template, :native, project: project) } let(:release) { create(:material_release_with_contract_template, :native, project: project, name: "John") }
let(:release2) { create(:material_release_with_contract_template, :native, project: project, name: "Jane") }
let(:release3) { create(:material_release_with_contract_template, :native, project: project, name: "Brad") }
subject { 'MaterialRelease' } subject { 'MaterialRelease' }
it_behaves_like "generates ZIP containig CSV file with all releases data" it_behaves_like "generates ZIP containig CSV file with all releases data"
it_behaves_like "generates ZIP containig CSV file with specific releases data"
end end
context "generates ZIP for medical releases" do context "generates ZIP for medical releases" do
let(:release) { create(:medical_release_with_contract_template, :native, project: project) } let(:release) { create(:medical_release_with_contract_template, :native, project: project, person_name: "John Doe") }
let(:release2) { create(:medical_release_with_contract_template, :native, project: project, person_name: "Jane Doe") }
let(:release3) { create(:medical_release_with_contract_template, :native, project: project, person_name: "Brad Doe") }
subject { 'MedicalRelease' } subject { 'MedicalRelease' }
it_behaves_like "generates ZIP containig CSV file with all releases data" it_behaves_like "generates ZIP containig CSV file with all releases data"
it_behaves_like "generates ZIP containig CSV file with specific releases data"
end end
context "generates ZIP for misc releases" do context "generates ZIP for misc releases" do
let(:release) { create(:misc_release_with_contract_template, :native, project: project) } let(:release) { create(:misc_release_with_contract_template, :native, project: project, person_name: "John Doe") }
let(:release2) { create(:misc_release_with_contract_template, :native, project: project, person_name: "Jane Doe") }
let(:release3) { create(:misc_release_with_contract_template, :native, project: project, person_name: "Brad Doe") }
subject { 'MiscRelease' } subject { 'MiscRelease' }
it_behaves_like "generates ZIP containig CSV file with all releases data" it_behaves_like "generates ZIP containig CSV file with all releases data"
it_behaves_like "generates ZIP containig CSV file with specific releases data"
end end
context "generates ZIP for music releases" do context "generates ZIP for music releases" do
let(:release) { create(:music_release_with_contract_template, project: project) } let(:release) { create(:music_release_with_contract_template, project: project, name: "John") }
let(:release2) { create(:music_release_with_contract_template, project: project, name: "Jane") }
let(:release3) { create(:music_release_with_contract_template, project: project, name: "Brad") }
subject { 'MusicRelease' } subject { 'MusicRelease' }
it_behaves_like "generates ZIP containig CSV file with all releases data" it_behaves_like "generates ZIP containig CSV file with all releases data"
it_behaves_like "generates ZIP containig CSV file with specific releases data"
end end
context "generates ZIP for talent releases" do context "generates ZIP for talent releases" do
let(:release) { create(:talent_release_with_contract_template, :native, project: project) } let(:release) { create(:talent_release_with_contract_template, :native, project: project, person_name: "John Doe") }
let(:release2) { create(:talent_release_with_contract_template, :native, project: project, person_name: "Jane Doe") }
let(:release3) { create(:talent_release_with_contract_template, :native, project: project, person_name: "Brad Doe") }
subject { 'TalentRelease' } subject { 'TalentRelease' }
it_behaves_like "generates ZIP containig CSV file with all releases data" it_behaves_like "generates ZIP containig CSV file with all releases data"
it_behaves_like "generates ZIP containig CSV file with specific releases data"
end end
context "When there are errors" do context "When there are errors" do
@@ -125,7 +254,7 @@ describe GenerateContractsZipJob do
end end
it "updates status to 'failure' and sends user a notification" do it "updates status to 'failure' and sends user a notification" do
GenerateContractsZipJob.perform_now(project, download, "AppearanceRelease", project.appearance_releases.ids) GenerateContractsZipJob.perform_now(project, download, "AppearanceRelease", project.appearance_releases.ids, '', '')
expect(download.status).to eq "failure" expect(download.status).to eq "failure"
expect(ProjectsChannel).to have_received(:broadcast_download_generation_update).with(download, I18n.t("contract_downloads.download.failure")) expect(ProjectsChannel).to have_received(:broadcast_download_generation_update).with(download, I18n.t("contract_downloads.download.failure"))