Skip to content

Commit

Permalink
fix: Fixes failing test cases from #242 (#364)
Browse files Browse the repository at this point in the history
  • Loading branch information
cbaudouinjr authored Sep 20, 2020
1 parent 58b5849 commit 113cd61
Show file tree
Hide file tree
Showing 10 changed files with 31 additions and 31 deletions.
6 changes: 3 additions & 3 deletions app/controllers/manage/questionnaires_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -97,9 +97,9 @@ def check_in

def destroy
if @questionnaire.is_bus_captain
admins = User.where(role: :admin)
admins.each do |user|
AdminMailer.bus_captain_left(@questionnaire.bus_list_id, @questionnaire.user_id, user.id).deliver_later
directors = User.where(role: :director)
directors.each do |user|
StaffMailer.bus_captain_left(@questionnaire.bus_list_id, @questionnaire.user_id, user.id).deliver_later
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/questionnaires_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,9 +95,9 @@ def update
# DELETE /apply.json
def destroy
if @questionnaire.is_bus_captain
admins = User.where(role: :admin)
admins.each do |user|
AdminMailer.bus_captain_left(@questionnaire.bus_list_id, @questionnaire.user_id, user.id).deliver_later
directors = User.where(role: :director)
directors.each do |user|
StaffMailer.bus_captain_left(@questionnaire.bus_list_id, @questionnaire.user_id, user.id).deliver_later
end
end

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/rsvps_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,9 @@ def update

if bus != nil && (acc_status != acc_status_after_rsvp || bus != bus_after_rsvp) && @questionnaire.is_bus_captain == true
@questionnaire.is_bus_captain = false
admins = User.where(role: :admin)
admins.each do |user|
AdminMailer.bus_captain_left(@questionnaire.bus_list_id, @questionnaire.user_id, user.id).deliver_later
directors = User.where(role: :director)
directors.each do |user|
StaffMailer.bus_captain_left(@questionnaire.bus_list_id, @questionnaire.user_id, user.id).deliver_later
end
end

Expand Down
6 changes: 3 additions & 3 deletions test/controllers/manage/dashboard_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class Manage::DashboardControllerTest < ActionController::TestCase
should "not allow access to manage_dashboard#index" do
get :index
assert_response :redirect
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end

should "not allow access to all data endpoints" do
Expand Down Expand Up @@ -101,11 +101,11 @@ class Manage::DashboardControllerTest < ActionController::TestCase

paths.each do |path|
get path
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end

get :map_data, format: "tsv"
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end
end

Expand Down
8 changes: 4 additions & 4 deletions test/controllers/manage/messages_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -210,13 +210,13 @@ class Manage::MessagesControllerTest < ActionController::TestCase
should "not allow access to manage_messages#index" do
get :index
assert_response :redirect
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end

should "not allow access to manage_messages datatables api" do
post :datatable, format: :json, params: { "columns[0][data]" => "" }
assert_response :redirect
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end

should "not allow access to manage_messages#new" do
Expand All @@ -228,7 +228,7 @@ class Manage::MessagesControllerTest < ActionController::TestCase
should "not allow access to manage_messages#show" do
get :show, params: { id: @message }
assert_response :redirect
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end

should "not allow access to manage_messages#edit" do
Expand Down Expand Up @@ -266,7 +266,7 @@ class Manage::MessagesControllerTest < ActionController::TestCase
should "not allow access to manage_messages#preview" do
get :preview, params: { id: @message }
assert_response :redirect
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end

should "not allow access to manage_messages#live_preview" do
Expand Down
6 changes: 3 additions & 3 deletions test/controllers/manage/questionnaires_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -346,10 +346,10 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
end

context "destroy questionnaire" do
should "if bus captain, notify admins that bus captain has been removed" do
@user = create(:admin)
should "if bus captain, notify directors that bus captain has been removed" do
@user = create(:director)
@questionnaire.update_attribute(:is_bus_captain, true)
assert_difference('enqueued_jobs.size', User.where(role: :admin).size) do
assert_difference('enqueued_jobs.size', User.where(role: :director).size) do
delete :destroy, params: { id: @questionnaire }
end
end
Expand Down
4 changes: 2 additions & 2 deletions test/controllers/manage/stats_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -49,14 +49,14 @@ class Manage::StatsControllerTest < ActionController::TestCase
should "not allow access to stats#index" do
get :index
assert_response :redirect
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end

should "not allow access to data endpoints" do
paths.each do |path|
patch path
assert_response :redirect
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions test/controllers/manage/users_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -105,22 +105,22 @@ class Manage::UsersControllerTest < ActionController::TestCase

should "not allow access to manage_users#index" do
get :index
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end

should "not allow access to manage_users users datatables api" do
post :user_datatable, format: :json, params: { "columns[0][data]" => "" }
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end

should "not allow access to manage_users staff datatables api" do
post :staff_datatable, format: :json, params: { "columns[0][data]" => "" }
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end

should "allow access to manage_users#show" do
get :show, params: { id: @user }
assert_redirected_to manage_root_path
assert_redirected_to manage_checkins_path
end

should "not allow access to manage_users#edit" do
Expand Down
6 changes: 3 additions & 3 deletions test/controllers/questionnaires_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -166,10 +166,10 @@ class QuestionnairesControllerTest < ActionController::TestCase
end

context "destroy questionnaire" do
should "if bus captain, notify admins that bus captain has been removed" do
@admin = create(:admin)
should "if bus captain, notify directors that bus captain has been removed" do
@director = create(:director)
@questionnaire.update_attribute(:is_bus_captain, true)
assert_difference('enqueued_jobs.size', User.where(role: :admin).size) do
assert_difference('enqueued_jobs.size', User.where(role: :director).size) do
delete :destroy
end
end
Expand Down
6 changes: 3 additions & 3 deletions test/controllers/rsvps_controller_test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -244,8 +244,8 @@ class RsvpsControllerTest < ActionController::TestCase
assert_redirected_to rsvp_path
end

should "if bus captain leaves a bus, notify admins that bus captain has been removed" do
@admin = create(:admin)
should "if bus captain leaves a bus, notify directors that bus captain has been removed" do
@director = create(:director)
@questionnaire.update_attribute(:is_bus_captain, true)
@questionnaire.update_attribute(:acc_status, "rsvp_confirmed")

Expand All @@ -259,7 +259,7 @@ class RsvpsControllerTest < ActionController::TestCase
}
}

assert_difference('enqueued_jobs.size', User.where(role: :admin).size) do
assert_difference('enqueued_jobs.size', User.where(role: :director).size) do
patch :update, params: {
questionnaire: {
acc_status: "rsvp_confirmed",
Expand Down

0 comments on commit 113cd61

Please sign in to comment.