improve specs

This commit is contained in:
Bilal
2020-09-15 11:40:17 +03:00
parent 219dfc8da0
commit 142efee2ca
3 changed files with 34 additions and 1 deletions

View File

@@ -9,6 +9,7 @@ RSpec.describe BroadcastsController, type: :controller do
before do
sign_in user
ENV['DAILYCO_ENABLED'] = '1'
end
describe "#index" do
@@ -156,6 +157,13 @@ RSpec.describe BroadcastsController, type: :controller do
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'
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))
end
it "assigns required variables" do
get :show, params: { project_id: project.id, id: broadcast.id }
@@ -163,6 +171,14 @@ RSpec.describe BroadcastsController, type: :controller do
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
context "when there are no multi-view broadcasts" do
it "renders the view dropdown with just the current broadcast" do
get :show, params: { project_id: project, id: broadcast }

View File

@@ -8,6 +8,7 @@ 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
@@ -21,12 +22,19 @@ RSpec.describe Public::BroadcastsController, type: :controller do
expect(assigns(:broadcast)).to eq(broadcast)
end
it "renders zoom meeting button" do
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'
get :show, params: { token: broadcast.token }
expect(response.body).to have_link("Video Conference", href: broadcast_zoom_meeting_url(broadcast.token))
end
it "doesn't render share url" do
get :show, params: { token: broadcast.token }
@@ -41,6 +49,14 @@ RSpec.describe Public::BroadcastsController, type: :controller do
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
context "when there are no multi-view broadcasts" do
it "renders the view dropdown with just the current broadcast" do
get :show, params: { token: broadcast.token }