Compare commits

...

5 Commits

Author SHA1 Message Date
Bilal
c17f41525d fix MR comment 2020-07-15 19:03:35 +02:00
Bilal
d12cec8487 remove validation and add specs 2020-07-15 12:25:54 +02:00
Bilal
bde18ab0f1 add Chat Now button 2020-07-15 12:25:54 +02:00
Bilal
fc320a3421 rebase 2020-07-15 12:25:54 +02:00
Senad Uka
7f49f31ebf Master sync 2020-07-15 11:58:34 +02:00
11 changed files with 104 additions and 24 deletions

View File

@@ -33,6 +33,11 @@ class BroadcastsController < ApplicationController
end end
def update def update
unless params.has_key?(:broadcast)
@broadcast.regenerate_token
redirect_to([@project, @broadcast], notice: t('.reset_notice')) and return
end
@broadcast.update(broadcast_params) @broadcast.update(broadcast_params)
@files = @broadcast.files.order("created_at DESC").paginate(page: 1) @files = @broadcast.files.order("created_at DESC").paginate(page: 1)

View File

@@ -6,5 +6,5 @@ class TaskRequest < ApplicationRecord
scope :order_by_recent, -> { order(created_at: :desc) } scope :order_by_recent, -> { order(created_at: :desc) }
validates :time_allowed, numericality: { only_integer: true, greater_than_or_equal_to: 2 } validates :time_allowed, numericality: { only_integer: true, greater_than_or_equal_to: 2 }, allow_blank: true
end end

View File

@@ -102,6 +102,7 @@
<i class="fa fa-clipboard"></i> <i class="fa fa-clipboard"></i>
Copy URL Copy URL
</button> </button>
<%= link_to t('.actions.reset_url'), [@project, @broadcast], method: :patch, class: "btn btn-danger" %>
</div> </div>
<% else %> <% else %>
<input type="text" class="form-control" value="<%= broadcast_url(@broadcast.token) %>" readonly> <input type="text" class="form-control" value="<%= broadcast_url(@broadcast.token) %>" readonly>
@@ -110,6 +111,7 @@
<i class="fa fa-clipboard"></i> <i class="fa fa-clipboard"></i>
Copy URL Copy URL
</button> </button>
<%= link_to t('.actions.reset_url'), [@project, @broadcast], method: :patch, class: "btn btn-danger" %>
</div> </div>
<% end %> <% end %>
</div> </div>

View File

@@ -1,9 +1,19 @@
<%= errors_summary_for task_request %> <%= errors_summary_for task_request %>
<%= bootstrap_form_with model: model, url: [@project, @task_request, show_chat: true], local: true do |form| %> <%= bootstrap_form_with model: model, url: [@project, @task_request, show_chat: true], local: true do |form| %>
<div class="alert alert-info text-center text-md-left">
<%= fa_icon "info-circle" %> <div class="d-flex">
<strong><%= t '.info_message' %></strong> <div class="row">
<div class="col-xl-10 col-12">
<div class="alert alert-info text-center text-md-left">
<%= fa_icon "info-circle" %>
<strong><%= t '.info_message' %></strong>
</div>
</div>
<div class="col-xl-2 col-12">
<%= form.submit t('.actions.chat_now'), class: "btn btn-block btn-warning pt-4 pb-4 mb-1", data: { disable_with: t("shared.disable_with") } %>
</div>
</div>
</div> </div>
<%= form.text_area :description, label: t('.labels.description') %> <%= form.text_area :description, label: t('.labels.description') %>

View File

@@ -217,6 +217,9 @@ en:
new: new:
heading: heading:
Create Live Stream Create Live Stream
show:
actions:
reset_url: Reset URL
splash: splash:
actions: actions:
book_demo: Schedule a Demo book_demo: Schedule a Demo
@@ -235,6 +238,8 @@ en:
share_stream: Share live stream link with clients share_stream: Share live stream link with clients
stream_from_mobile_app: Stream from ME Suite Mobile app, or via a professional camera stream_from_mobile_app: Stream from ME Suite Mobile app, or via a professional camera
stream_multiple_cameras: Stream multiple cameras at one time stream_multiple_cameras: Stream multiple cameras at one time
update:
reset_notice: The Share URL has been reset, and the previous URL will no longer work. Please click "Copy URL" and share it again with those who you want to have access to this live stream
bulk_taggings: bulk_taggings:
new_bulk_tag_modal: new_bulk_tag_modal:
submit: Add submit: Add
@@ -1279,7 +1284,9 @@ en:
heading: heading:
Edit Task Request Edit Task Request
form: form:
info_message: After submitting this task request, you'll be connected via chat with a ME Suite representative. actions:
chat_now: Chat Now
info_message: For best results, please fill out this form prior to being connected with a TaskME assistant. However, if urgent, you can start speaking with a TaskME assistant by pressing the Chat Now button to the right
labels: labels:
additional_notes: Please add any additional notes we should be aware of regarding this task. additional_notes: Please add any additional notes we should be aware of regarding this task.
deadline: What is the deadline for this task? deadline: What is the deadline for this task?

View File

@@ -81,6 +81,9 @@ es:
do_not_copy_warning: "Do not copy (ES)" do_not_copy_warning: "Do not copy (ES)"
serial_number_label: "Serial Number (ES)" serial_number_label: "Serial Number (ES)"
broadcasts: broadcasts:
show:
actions:
reset_url: Reset URL (ES)
splash: splash:
actions: actions:
book_demo: Schedule a Demo book_demo: Schedule a Demo
@@ -99,6 +102,8 @@ es:
share_stream: Share live stream link with clients share_stream: Share live stream link with clients
stream_from_mobile_app: Stream from ME Suite Mobile app, or via a professional camera stream_from_mobile_app: Stream from ME Suite Mobile app, or via a professional camera
stream_multiple_cameras: Stream multiple cameras at one time stream_multiple_cameras: Stream multiple cameras at one time
update:
reset_notice: The Share URL has been reset, and the previous URL will no longer work. Please click "Copy URL" and share it again with those who you want to have access to this live stream
contract_templates: contract_templates:
blank_contracts: blank_contracts:
create: create:
@@ -479,7 +484,9 @@ es:
create: create:
success_message: Your task request was successfully submitted. Thank you. A chat window will pop up on the lower right in a few seconds. (ES) success_message: Your task request was successfully submitted. Thank you. A chat window will pop up on the lower right in a few seconds. (ES)
form: form:
info_message: After submitting this task request, you'll be connected via chat with a ME Suite representative. (ES) actions:
chat_now: Chat Now (ES)
info_message: For best results, please fill out this form prior to being connected with a TaskME assistant. However, if urgent, you can start speaking with a TaskME assistant by pressing the Chat Now button to the right (ES)
index: index:
table_headers: table_headers:
task_request_description: Description (ES) task_request_description: Description (ES)

View File

@@ -9,20 +9,6 @@ SET xmloption = content;
SET client_min_messages = warning; SET client_min_messages = warning;
SET row_security = off; SET row_security = off;
--
-- Name: plpgsql; Type: EXTENSION; Schema: -; Owner: -
--
CREATE EXTENSION IF NOT EXISTS plpgsql WITH SCHEMA pg_catalog;
--
-- Name: EXTENSION plpgsql; Type: COMMENT; Schema: -; Owner: -
--
COMMENT ON EXTENSION plpgsql IS 'PL/pgSQL procedural language';
-- --
-- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: - -- Name: fuzzystrmatch; Type: EXTENSION; Schema: -; Owner: -
-- --

View File

@@ -203,6 +203,15 @@ RSpec.describe BroadcastsController, type: :controller do
expect(BroadcastsChannel).to have_received(:broadcast_file_upload_updates) expect(BroadcastsChannel).to have_received(:broadcast_file_upload_updates)
end end
it "regenerates token if #update is called without broadcast param" do
old_token = broadcast.token
patch :update, params: { project_id: project.id, id: broadcast.id }
expect(response).to redirect_to [project, broadcast]
expect(flash.notice).to eq token_reset_notice
expect(Broadcast.last.token).not_to eq old_token
end
end end
describe "#destroy" do describe "#destroy" do
@@ -252,4 +261,8 @@ RSpec.describe BroadcastsController, type: :controller do
def create_stream def create_stream
t 'broadcasts.splash.actions.create_stream' t 'broadcasts.splash.actions.create_stream'
end end
def token_reset_notice
t 'broadcasts.update.reset_notice'
end
end end

View File

@@ -63,6 +63,21 @@ feature 'User managing broadcasts' do
expect(page).to have_content(recording.download_file_name) expect(page).to have_content(recording.download_file_name)
end end
scenario 'Clicking Reset URL regenerates broadcast token' do
broadcast = create(:broadcast, :with_stream, :with_files, project: project)
old_token = broadcast.token
visit project_broadcast_path(project, broadcast)
expect(page).to have_content reset_url
expect(page).to have_xpath "//input[@readonly][@value='#{broadcast_url(old_token)}']"
click_link reset_url
expect(Broadcast.last.token).not_to eq old_token
expect(page).to have_xpath "//input[@readonly][@value='#{broadcast_url(Broadcast.last.token)}']"
expect(page).to have_content token_reset_notice
end
scenario 'user can go back and forth between live session and previous sessions', js: true do scenario 'user can go back and forth between live session and previous sessions', js: true do
broadcast = create(:broadcast, :with_stream, :with_files, project: project) broadcast = create(:broadcast, :with_stream, :with_files, project: project)
recording = create(:broadcast_recording, broadcast: broadcast) recording = create(:broadcast_recording, broadcast: broadcast)
@@ -189,4 +204,12 @@ feature 'User managing broadcasts' do
def create_stream def create_stream
t 'broadcasts.splash.actions.create_stream' t 'broadcasts.splash.actions.create_stream'
end end
def reset_url
t 'broadcasts.show.actions.reset_url'
end
def token_reset_notice
t 'broadcasts.update.reset_notice'
end
end end

View File

@@ -91,6 +91,21 @@ feature "User managing task requests" do
expect(page).to have_content add_new_project_label expect(page).to have_content add_new_project_label
end end
scenario "user can click Chat Now and start chat event with a blank form" do
visit project_task_requests_path(project)
click_on create_task_request
expect(page).to have_content chat_now_button
expect(page).to have_content form_notice
expect do
click_on chat_now_button
end.to change(TaskRequest, :count).by(1)
expect(page).to have_content task_request_created_notice
end
private private
def no_task_requests_label def no_task_requests_label
@@ -120,4 +135,20 @@ feature "User managing task requests" do
def schedule_demo def schedule_demo
t 'task_requests.splash.actions.book_demo' t 'task_requests.splash.actions.book_demo'
end end
def create_task_request
t 'task_requests.index.actions.new'
end
def chat_now_button
t 'task_requests.form.actions.chat_now'
end
def form_notice
t 'task_requests.form.info_message'
end
def task_request_created_notice
t 'task_requests.create.success_message'
end
end end

View File

@@ -13,8 +13,4 @@ RSpec.describe TaskRequest, type: :model do
subject { described_class } subject { described_class }
it { is_expected.to respond_to(:order_by_recent) } it { is_expected.to respond_to(:order_by_recent) }
end end
describe "#validations" do
it { should validate_numericality_of(:time_allowed).only_integer.is_greater_than_or_equal_to(2) }
end
end end