Compare commits

..

6 Commits

Author SHA1 Message Date
Bilal
a4204e2fa3 fix after rebase 2020-09-16 12:01:47 +03:00
Bilal
afbde109d2 update specs 2020-09-16 11:44:23 +03:00
Bilal
43e996299a update specs 2020-09-16 11:44:23 +03:00
Bilal
9ce7d97c51 update specs 2020-09-16 11:44:23 +03:00
Bilal
8f83943ac2 update 2020-09-16 11:44:23 +03:00
Bilal
fb32746c81 add notice when matching is completed 2020-09-16 11:44:23 +03:00
28 changed files with 87 additions and 298 deletions

View File

@@ -32,9 +32,3 @@ CUSTOM_API_TOKEN=
# Required for simulcasting to Millicast for director mode
MILLICAST_API_SECRET=
MILLICAST_ACCOUNT_ID=
# Daily.co live chat API token
DAILYCO_API_KEY=
# Feature flag to switch between Zoom and Daily.co live meeting
DAILYCO_ENABLED= 1 (on) / 0 (off); When Off, Zoom meeting will be used if no override url is present

View File

@@ -17,6 +17,7 @@ $(document).on "turbolinks:load", ->
when "video_status_update" then @showVideoStatusUpdate(data.content)
when "download_status_update" then @showDownloadStatusUpdate(data.content)
when "conference_recording_ready" then @showDownloadStatusUpdate(data.content)
when "appearance_matching_flash_message" then @showMatchingStatusUpdate(data.content)
showVideoStatusUpdate: (content) ->
$("[data-ujs-target='video-analysis-msg']").replaceWith content
@@ -24,3 +25,7 @@ $(document).on "turbolinks:load", ->
showDownloadStatusUpdate: (content) ->
$(".flash-message").html content
$(".toast").toast('show')
showMatchingStatusUpdate: (content) ->
$(".flash-message").html content
$(".toast").toast('show')

View File

@@ -33,4 +33,15 @@ class ProjectsChannel < ApplicationCable::Channel
content = ApplicationController.render partial: 'application/flash', locals: { flash: flash }
broadcast_to project, event: :conference_recording_ready, content: content
end
def self.appearance_matching_flash_message(project, message, flash_type = :notice)
if (flash_type == :notice)
flash = OpenStruct.new notice: message
else
flash = OpenStruct.new alert: message
end
content = ApplicationController.render partial: 'application/flash', locals: { flash: flash }
broadcast_to project, event: :appearance_matching_flash_message, content: content
end
end

View File

@@ -114,12 +114,7 @@ class BroadcastsController < ApplicationController
end
def conference_url_for(broadcast)
if broadcast.video_conference_url_override.present?
broadcast.video_conference_url_override
else
conference_type = ENV['DAILYCO_ENABLED'] == '1' ? :live_meeting : :zoom_meeting
url_for([broadcast.project, broadcast, conference_type])
end
broadcast.video_conference_url_override.presence || url_for([broadcast.project, broadcast, :zoom_meeting])
end
def log_create_analytics

View File

@@ -1,11 +0,0 @@
class LiveMeetingsController < ApplicationController
def show
authorize broadcast = Broadcast.find(params[:broadcast_id])
if broadcast.project.live_meeting_url.blank?
room = Daily.create_room
room_url = room['url']
broadcast.project.update live_meeting_url: room_url
end
@live_meeting_url = broadcast.project.live_meeting_url
end
end

View File

@@ -44,11 +44,7 @@ class Public::BroadcastsController < Public::BaseController
end
def conference_url_for(broadcast)
if broadcast.video_conference_url_override.present?
broadcast.video_conference_url_override
else
ENV['DAILYCO_ENABLED'] == '1' ? broadcast_live_meeting_url(broadcast.token) : broadcast_zoom_meeting_url(broadcast.token)
end
broadcast.video_conference_url_override.presence || broadcast_zoom_meeting_url(broadcast.token)
end
class MultiViewBroadcast

View File

@@ -1,9 +0,0 @@
class Public::LiveMeetingsController < Public::BaseController
skip_after_action :verify_authorized
def show
broadcast = Broadcast.find_by_token!(params[:broadcast_token])
@live_meeting_url = broadcast.project.live_meeting_url
render 'public/live_meetings/show'
end
end

View File

@@ -6,7 +6,10 @@ class MatchAppearanceReleasesJob < ApplicationJob
def perform(project, attachments)
filtered_attachments_object = filter_attachments attachments
return if filtered_attachments_object[:keys].blank?
if filtered_attachments_object[:keys].blank?
ProjectsChannel.appearance_matching_flash_message project, failed_message, :alert
return
end
matching_request = MatchingRequest.create project: project, attachments: filtered_attachments_object[:signed_ids]
@@ -17,6 +20,8 @@ class MatchAppearanceReleasesJob < ApplicationJob
handle_matches matches, project, key_signed_id_hash
handle_unmatches matches, project, key_signed_id_hash
matching_request.destroy
ProjectsChannel.appearance_matching_flash_message project, success_message
end
private
@@ -113,4 +118,12 @@ class MatchAppearanceReleasesJob < ApplicationJob
signed_ids: filtered_attachments_signed_ids
}
end
def success_message
I18n.t 'appearance_releases.create.matching_completed'
end
def failed_message
I18n.t 'appearance_releases.create.matching_failed'
end
end

View File

@@ -3,14 +3,14 @@
<!-- Position toasts -->
<div class="position-absolute" style="top: 0.5rem; right: 0.5rem;">
<% if flash.alert.present? %>
<div class="toast fade show bg-black text-white toast-min-w-border-radius" data-autohide="false">
<div id="flash-message" class="toast fade show bg-black text-white toast-min-w-border-radius" data-autohide="false">
<div class="toast-body toast-border-left-danger">
<button type="button" class="close text-white ml-2" data-dismiss="toast">&times;</button>
<p><%= flash.alert.html_safe %></p>
</div>
</div>
<% elsif flash.notice.present? %>
<div class="toast fade show bg-black text-white toast-min-w-border-radius" data-autohide="false">
<div id="flash-message" class="toast fade show bg-black text-white toast-min-w-border-radius" data-autohide="false">
<div class="toast-body toast-border-left-primary">
<button type="button" class="close text-white ml-2" data-dismiss="toast">&times;</button>
<p><%= flash.notice.html_safe %></p>
@@ -19,4 +19,3 @@
<% end %>
</div>
</div>

View File

@@ -1,13 +0,0 @@
<%= javascript_include_tag "https://unpkg.com/@daily-co/daily-js" %>
<%= javascript_tag nonce: true do %>
callFrame = window.DailyIframe.createFrame({
showLeaveButton: true,
iframeStyle: {
position: 'fixed',
width: '100%',
height: '90%'
}
});
callFrame.join({ url: '<%= @live_meeting_url %>' });
<% end %>

View File

@@ -1,17 +0,0 @@
<% if @live_meeting_url.present? %>
<%= javascript_include_tag "https://unpkg.com/@daily-co/daily-js" %>
<%= javascript_tag nonce: true do %>
callFrame = window.DailyIframe.createFrame({
showLeaveButton: true,
iframeStyle: {
position: 'fixed',
width: '100%',
height: '90%'
}
});
callFrame.join({ url: '<%= @live_meeting_url %>' });
<% end %>
<% else %>
<p><%= t '.meeting_not_ready_message' %></p>
<% end %>

View File

@@ -1 +0,0 @@
require 'daily'

View File

@@ -151,6 +151,8 @@ en:
failed_import: Failed to create appearance release for files listed below
matching_started: Matching started
no_attachments: Failed to import - no attachments
matching_completed: Matching completed. Reload page to see new releases
matching_failed: Matching failed
edit:
heading: Edit Appearance Release
form:
@@ -1390,9 +1392,6 @@ en:
heading: Photos
signature:
heading: Signature
live_meetings:
show:
meeting_not_ready_message: Live meeting is not yet ready. Please contact project manager.
release_template_imports:
create:
error: There was a problem with importing selected templates

View File

@@ -58,6 +58,8 @@ es:
failed_import: Failed to create appearance release for files listed below (ES)
matching_started: Matching started (ES)
no_attachments: Failed to import - no attachments (ES)
matching_completed: Matching completed (ES)
matching_failed: Matching failed (ES)
form:
guardian_2_info:
heading: Second Guardian Information (if company requires) (ES)
@@ -632,9 +634,6 @@ es:
show:
choose_project: ¿Qué proyecto de la lista de abajo asistirá?
welcome_html: Bienvenidos a la plataforma de firma autorizaciónes de <strong>%{name}</strong>
live_meetings:
show:
meeting_not_ready_message: Live meeting is not yet ready. Please contact project manager. (ES)
shared:
print: Print (ES)
talent_releases:

View File

@@ -104,7 +104,6 @@ Rails.application.routes.draw do
member do
delete :destroy_file
end
resource :live_meeting, only: [:show]
resource :zoom_meeting, only: [:show]
resources :broadcast_recordings, only: [:destroy]
end
@@ -150,7 +149,6 @@ Rails.application.routes.draw do
end
end
resources :broadcasts, param: :token, only: [:show, :update] do
resource :live_meeting, only: [:show]
resource :zoom_meeting, only: [:show]
resources :broadcast_recordings, only: [:edit, :update] do
resources :broadcast_recording_starrings, only: :create

View File

@@ -1,5 +0,0 @@
class AddLiveMeetingUrlToProjects < ActiveRecord::Migration[6.0]
def change
add_column :projects, :live_meeting_url, :text
end
end

View File

@@ -543,9 +543,9 @@ CREATE TABLE public.broadcast_recordings (
updated_at timestamp(6) without time zone NOT NULL,
duration double precision,
hidden boolean DEFAULT false,
starred boolean DEFAULT false,
name character varying,
description text,
starred boolean DEFAULT false
description text
);
@@ -716,6 +716,15 @@ CREATE SEQUENCE public.contract_templates_id_seq
ALTER SEQUENCE public.contract_templates_id_seq OWNED BY public.contract_templates.id;
--
-- Name: data_migrations; Type: TABLE; Schema: public; Owner: -
--
CREATE TABLE public.data_migrations (
version character varying NOT NULL
);
--
-- Name: directories; Type: TABLE; Schema: public; Owner: -
--
@@ -1379,8 +1388,7 @@ CREATE TABLE public.projects (
updated_at timestamp without time zone NOT NULL,
sample boolean DEFAULT false,
headshot_collection_uid character varying,
account_id bigint,
live_meeting_url text
account_id bigint
);
@@ -1495,7 +1503,6 @@ CREATE TABLE public.settings (
--
CREATE SEQUENCE public.settings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1531,7 +1538,6 @@ CREATE TABLE public.taggings (
--
CREATE SEQUENCE public.taggings_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -1562,7 +1568,6 @@ CREATE TABLE public.tags (
--
CREATE SEQUENCE public.tags_id_seq
AS integer
START WITH 1
INCREMENT BY 1
NO MINVALUE
@@ -2406,6 +2411,14 @@ ALTER TABLE ONLY public.contract_templates
ADD CONSTRAINT contract_templates_pkey PRIMARY KEY (id);
--
-- Name: data_migrations data_migrations_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.data_migrations
ADD CONSTRAINT data_migrations_pkey PRIMARY KEY (version);
--
-- Name: directories directories_pkey; Type: CONSTRAINT; Schema: public; Owner: -
--
@@ -3254,7 +3267,6 @@ CREATE UNIQUE INDEX index_users_on_email ON public.users USING btree (email);
CREATE UNIQUE INDEX index_users_on_password_reset_token ON public.users USING btree (password_reset_token);
--
-- Name: index_video_release_confirmations_on_file_info_id; Type: INDEX; Schema: public; Owner: -
--
@@ -3460,14 +3472,6 @@ ALTER TABLE ONLY public.contract_templates
ADD CONSTRAINT fk_rails_21d503cdcd FOREIGN KEY (project_id) REFERENCES public.projects(id);
--
-- Name: video_release_confirmations fk_rails_2787252ceb; Type: FK CONSTRAINT; Schema: public; Owner: -
--
ALTER TABLE ONLY public.video_release_confirmations
ADD CONSTRAINT fk_rails_2787252ceb FOREIGN KEY (file_info_id) REFERENCES public.file_infos(id);
--
-- Name: medical_releases fk_rails_325442c794; Type: FK CONSTRAINT; Schema: public; Owner: -
--
@@ -4037,7 +4041,6 @@ INSERT INTO "schema_migrations" (version) VALUES
('20200820082501'),
('20200824171649'),
('20200908085319'),
('20200914113410'),
('20200914163203');

View File

@@ -1,26 +0,0 @@
# frozen_string_literal: true
class Daily
include HTTParty
base_uri 'api.daily.co/v1'
class << self
def create_room
response = post "#{base_uri}/rooms", headers: headers
if response.code != 200
throw StandardError.new('Failed to create a room')
end
response.parsed_response
end
private
def headers
{
'Authorization': "Bearer #{ENV['DAILYCO_API_KEY']}"
}
end
end
end

View File

@@ -9,7 +9,6 @@ RSpec.describe BroadcastsController, type: :controller do
before do
sign_in user
ENV['DAILYCO_ENABLED'] = '1'
end
describe "#index" do
@@ -151,14 +150,7 @@ RSpec.describe BroadcastsController, type: :controller do
expect(assigns(:broadcast)).to eq(broadcast)
end
it "displays live meeting button" do
get :show, params: { project_id: project.id, id: broadcast.id }
expect(response.body).to have_link("Video Conference", href: project_broadcast_live_meeting_url(project, broadcast))
end
it "displays zoom meeting button if dailyco is disabled" do
ENV['DAILYCO_ENABLED'] = '0'
it "displays zoom meeting button" do
get :show, params: { project_id: project.id, id: broadcast.id }
expect(response.body).to have_link("Video Conference", href: project_broadcast_zoom_meeting_url(project, broadcast))
@@ -167,14 +159,6 @@ RSpec.describe BroadcastsController, type: :controller do
it "assigns required variables" do
get :show, params: { project_id: project.id, id: broadcast.id }
expect(assigns(:conference_url)).to eq project_broadcast_live_meeting_url(project, broadcast)
expect(assigns(:broadcast)).to eq broadcast
end
it "assigns required variables when dailyco is disabled" do
ENV['DAILYCO_ENABLED'] = '0'
get :show, params: { project_id: project.id, id: broadcast.id }
expect(assigns(:conference_url)).to eq project_broadcast_zoom_meeting_url(project, broadcast)
expect(assigns(:broadcast)).to eq broadcast
end

View File

@@ -1,34 +0,0 @@
require 'rails_helper'
RSpec.describe LiveMeetingsController, type: :controller do
let(:user) { create(:user) }
let(:account) { user.primary_account }
let(:project) { create(:project, account: user.primary_account) }
let(:broadcast) { create(:broadcast, name: "Broadcast", project: project) }
before :each do
stub_mux_live_stream
end
describe "#show" do
before { sign_in user }
it "does not create new live meeting room if project already has a room" do
expect(project.live_meeting_url.present?).to eq true
expect(Daily).not_to receive(:create_room)
get :show, params: { project_id: project.id, broadcast_id: broadcast.id }
expect(response).to be_successful
end
it "creates new live meeting room if project has no room already created" do
project.update(live_meeting_url: nil)
dummy_room_response = { url: 'dummy_url' }.to_json
expect(Daily).to receive(:create_room).and_return(JSON.parse(dummy_room_response))
get :show, params: { project_id: project.id, broadcast_id: broadcast.id }
expect(response).to be_successful
end
end
end

View File

@@ -302,6 +302,6 @@ RSpec.describe ProjectsController, type: :controller do
private
def project_params
attributes_for(:project).except(:live_meeting_url)
attributes_for(:project)
end
end

View File

@@ -8,7 +8,6 @@ RSpec.describe Public::BroadcastsController, type: :controller do
let(:project) { create(:project, account: user.primary_account) }
before do
ENV['DAILYCO_ENABLED'] = '1'
stub_mux_live_stream
end
@@ -22,14 +21,7 @@ RSpec.describe Public::BroadcastsController, type: :controller do
expect(assigns(:broadcast)).to eq(broadcast)
end
it "renders live meeting button" do
get :show, params: { token: broadcast.token }
expect(response.body).to have_link("Video Conference", href: broadcast_live_meeting_url(broadcast.token))
end
it "renders zoom meeting button if dailyco is not enabled" do
ENV['DAILYCO_ENABLED'] = '0'
it "renders zoom meeting button" do
get :show, params: { token: broadcast.token }
expect(response.body).to have_link("Video Conference", href: broadcast_zoom_meeting_url(broadcast.token))
@@ -45,14 +37,6 @@ RSpec.describe Public::BroadcastsController, type: :controller do
it "assigns required variables" do
get :show, params: { token: broadcast.token }
expect(assigns(:conference_url)).to eq broadcast_live_meeting_url(broadcast.token)
expect(assigns(:broadcast)).to eq broadcast
end
it "assigns required variables - when dailyco is not enabled" do
ENV['DAILYCO_ENABLED'] = '0'
get :show, params: { token: broadcast.token }
expect(assigns(:conference_url)).to eq broadcast_zoom_meeting_url(broadcast.token)
expect(assigns(:broadcast)).to eq broadcast
end

View File

@@ -1,39 +0,0 @@
require 'rails_helper'
RSpec.describe Public::LiveMeetingsController, type: :controller do
let(:user) { create(:user) }
let(:account) { user.primary_account }
let(:project) { create(:project, account: user.primary_account) }
let(:broadcast) { create(:broadcast, name: "Broadcast", project: project) }
before :each do
stub_mux_live_stream
end
describe "#show" do
it "does not create new live meeting room if project already has a room" do
expect(project.live_meeting_url.present?).to eq true
expect(Daily).not_to receive(:create_room)
get :show, params: { broadcast_token: broadcast.token }
expect(response).to be_successful
expect(response.body).not_to match meeting_not_ready_message
end
it "creates new live meeting room if project has no room already created" do
project.update(live_meeting_url: nil)
expect(Daily).not_to receive(:create_room)
get :show, params: { broadcast_token: broadcast.token }
expect(response).to be_successful
end
end
private
def meeting_not_ready_message
t 'public.live_meetings.show.meeting_not_ready_message'
end
end

View File

@@ -18,7 +18,6 @@ RSpec.describe Public::ZoomMeetingsController, type: :controller do
describe "#show" do
it "redirects to meeting start url" do
skip 'will be deleted'
get :show, params: { broadcast_token: broadcast.token }
expect(response).to redirect_to(meeting_start_url)
end

View File

@@ -23,7 +23,6 @@ RSpec.describe ZoomMeetingsController, type: :controller do
before { sign_in user }
it "redirects to meeting start url" do
skip 'will be deleted'
get :show, params: { project_id: project.id, broadcast_id: broadcast.id }
expect(response).to redirect_to(meeting_start_url)
end

View File

@@ -9,8 +9,6 @@ FactoryBot.define do
producer_address "123 Corporate Lane, New York, NY 10001"
producer_name "Production Company, LLC"
live_meeting_url 'dummy_live_meeting_url'
# Enable all release category sections by default
after(:build) do |project, _|
project.settings(:features).attributes = {

View File

@@ -9,7 +9,6 @@ feature 'User managing broadcasts' do
context 'managing broadcasts' do
before do
ENV['DAILYCO_ENABLED'] = '1'
sign_in current_user
stub_mux_live_stream
end
@@ -98,36 +97,6 @@ feature 'User managing broadcasts' do
expect(page).to have_content token_reset_notice
end
scenario 'Clicking Conference button without previously created live meeting creates new room and opens live meeting' do
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
project.update(live_meeting_url: nil)
visit project_broadcast_path(project, broadcast)
dummy_room = { url: 'dummy_room_url' }.to_json
allow(Daily).to receive(:create_room).and_return JSON.parse(dummy_room)
expect {
click_link conference_button
}.not_to raise_error
expect(page).not_to have_content meeting_not_ready_message
end
scenario 'Clicking Conference button with previously created live meeting does not create new room and opens live meeting' do
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
visit project_broadcast_path(project, broadcast)
expect(Daily).not_to receive(:create_room)
expect {
click_link conference_button
}.not_to raise_error
expect(page).not_to have_content meeting_not_ready_message
end
scenario 'form will not submit if user clicks Add files without selected files', js: true do
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
@@ -285,26 +254,6 @@ feature 'User managing broadcasts' do
expect(Broadcast.find(broadcast.id).files.count).to eq 2
end
end
context 'When user is not signed in' do
before do
# sign_out
end
scenario 'Clicking Conference button without previously created live meeting does not create new meeting and shows error message' do
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
project.update(live_meeting_url: nil)
visit broadcast_url(broadcast.token)
expect(Daily).not_to receive(:create_room)
expect {
click_link conference_button
}.not_to raise_error
expect(page).to have_content meeting_not_ready_message
end
end
end
private
@@ -356,12 +305,5 @@ feature 'User managing broadcasts' do
t 'broadcasts.file.actions.delete_file'
end
def conference_button
'Video Conference'
end
def meeting_not_ready_message
t 'public.live_meetings.show.meeting_not_ready_message'
end
end

View File

@@ -13,6 +13,7 @@ describe MatchAppearanceReleasesJob do
it "returns if no attachment is sent" do
expect(MatchingRequest).not_to receive(:create)
attachments = []
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), failure_flash_message, :alert)
MatchAppearanceReleasesJob.perform_now project, attachments
end
@@ -20,6 +21,7 @@ describe MatchAppearanceReleasesJob do
expect(MatchingRequest).not_to receive(:create)
dummy_video = create(:video)
attachments = [dummy_video.file.blob.signed_id]
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), failure_flash_message, :alert)
MatchAppearanceReleasesJob.perform_now project, attachments
end
@@ -44,6 +46,8 @@ describe MatchAppearanceReleasesJob do
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
expect(dummy_matching_request).to receive(:destroy)
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
expect {
MatchAppearanceReleasesJob.perform_now project, signed_ids
}.to change{AppearanceRelease.count}.by(1)
@@ -73,6 +77,8 @@ describe MatchAppearanceReleasesJob do
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
expect(dummy_matching_request).to receive(:destroy)
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
expect {
MatchAppearanceReleasesJob.perform_now project, signed_ids
}.to change{AppearanceRelease.count}.by(1)
@@ -109,6 +115,8 @@ describe MatchAppearanceReleasesJob do
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
expect(dummy_matching_request).to receive(:destroy)
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
MatchAppearanceReleasesJob.perform_now project, signed_ids
expect(AppearanceRelease.last.identifier).to eq mock_match.identifier
@@ -144,6 +152,8 @@ describe MatchAppearanceReleasesJob do
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
expect(dummy_matching_request).to receive(:destroy)
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
expect {
MatchAppearanceReleasesJob.perform_now project, signed_ids
}.to change{AppearanceRelease.count}.by(2)
@@ -187,6 +197,8 @@ describe MatchAppearanceReleasesJob do
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
expect(dummy_matching_request).to receive(:destroy)
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
MatchAppearanceReleasesJob.perform_now project, signed_ids
expect(AppearanceRelease.last.identifier).to eq mock_match.identifier
@@ -228,6 +240,8 @@ describe MatchAppearanceReleasesJob do
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
expect(dummy_matching_request).to receive(:destroy)
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
MatchAppearanceReleasesJob.perform_now project, signed_ids
expect(AppearanceRelease.last.identifier).to eq mock_match.identifier
@@ -275,6 +289,8 @@ describe MatchAppearanceReleasesJob do
expect(BrayniacAI::QrMatching).to receive(:create!).with(qr_matching_payload).and_return(qr_matching_mock_response)
expect(dummy_matching_request).to receive(:destroy)
expect(ProjectsChannel).to receive(:appearance_matching_flash_message).with(kind_of(Project), success_flash_message)
MatchAppearanceReleasesJob.perform_now project, signed_ids
releases = AppearanceRelease.last(2)
@@ -288,4 +304,14 @@ describe MatchAppearanceReleasesJob do
expect(releases[1].contract.attached?).to eq true
end
end
private
def success_flash_message
I18n.t 'appearance_releases.create.matching_completed'
end
def failure_flash_message
I18n.t 'appearance_releases.create.matching_failed'
end
end