\ No newline at end of file
diff --git a/db/seeds.rb b/db/seeds.rb
index 28ce41ec8..b72203e26 100644
--- a/db/seeds.rb
+++ b/db/seeds.rb
@@ -15,6 +15,7 @@
"questionnaire.accepted" => "You've been accepted!",
"questionnaire.denied" => "Your application status",
"questionnaire.rsvp_confirmed" => "RSVP Confirmation",
+ "questionnaire.rsvp_reminder" => "Are you coming to #{HackathonConfig['name']}?",
"user.24hr_incomplete_application" => "Incomplete application",
"bus_list.new_captain_confirmation" => "You're a bus captain!",
"bus_list.update_notes" => "Bus Update"
@@ -25,6 +26,7 @@
"questionnaire.accepted" => "Accepted email",
"questionnaire.denied" => "Denied email",
"questionnaire.rsvp_confirmed" => "RSVP confirmed email",
+ "questionnaire.rsvp_reminder" => "RSVP Reminder",
"user.24hr_incomplete_application" => "Incomplete application (24-hour reminder)",
"bus_list.new_captain_confirmation" => "New bus captain confirmation",
"bus_list.update_notes" => "Bus list update"
diff --git a/docs/api-overview.md b/docs/api-overview.md
index da4e24b63..ac81471f9 100644
--- a/docs/api-overview.md
+++ b/docs/api-overview.md
@@ -41,7 +41,6 @@ Example for questionnaire management endpoints:
Prefix Verb URI Pattern Controller#Action
datatable_manage_questionnaires POST /manage/questionnaires/datatable(.:format) manage/questionnaires#datatable
check_in_manage_questionnaire PATCH /manage/questionnaires/:id/check_in(.:format) manage/questionnaires#check_in
- convert_to_admin_manage_questionnaire PATCH /manage/questionnaires/:id/convert_to_admin(.:format) manage/questionnaires#convert_to_admin
update_acc_status_manage_questionnaire PATCH /manage/questionnaires/:id/update_acc_status(.:format) manage/questionnaires#update_acc_status
bulk_apply_manage_questionnaires PATCH /manage/questionnaires/bulk_apply(.:format) manage/questionnaires#bulk_apply
manage_questionnaires GET /manage/questionnaires(.:format) manage/questionnaires#index
diff --git a/docs/api-testing-setup.md b/docs/api-testing-setup.md
index 03e33e690..c4767b5a0 100644
--- a/docs/api-testing-setup.md
+++ b/docs/api-testing-setup.md
@@ -9,7 +9,7 @@ These programs allow you to run API requests (`GET`, `POST`, and so on) in an is
In order to make requests in either Postman or Paw, you need to setup _OAuth 2 authorization_, as in HackathonManager, each request needs to be authorized first. This guide discusses how to enable OAuth 2 for these apps.
-This guide assumes you have already setup an admin account on a local HackathonManager instance. For more details on this, see the [main README](https://github.com/codeRIT/hackathon-manager#local-development).
+This guide assumes you have already setup an account with Director status on a local HackathonManager instance. For more details on this, see the [main README](https://github.com/codeRIT/hackathon-manager#local-development).
> To make API requests on a live/remote instance, simply replace `localhost` in all following commands with your HackathonManager's URL.
@@ -27,7 +27,7 @@ Select an app below to jump directly to its guide:
## Connecting with Postman
-In HackathonManager, sign in to your admin account and click "Manage". Then, at the bottom left of the sidebar, click the **Doorkeeper** tab.
+In HackathonManager, sign in to your staff account and click "Manage". Then, at the bottom left of the sidebar, click the **Doorkeeper** tab.
@@ -47,7 +47,7 @@ On this screen, fill out the information but with your own keys from the image a
-You should get a popup with your hackathon's sign in screen. Type in your admin credentials and log in.
+You should get a popup with your hackathon's sign in screen. Type in your staff credentials and log in.
On the next screen, select `Authorize`:
diff --git a/docs/deployment-dokku.md b/docs/deployment-dokku.md
index 7f5c1cf04..0b080214d 100644
--- a/docs/deployment-dokku.md
+++ b/docs/deployment-dokku.md
@@ -6,14 +6,18 @@ title: Dokku Deployment
>These docs assume you already have a virtual machine with [Dokku](http://dokku.viewdocs.io/dokku/) running on it, and can SSH into the VM. DNS should be set up as well, but isn't required for bare minimum functionality.
>
>If you need a VM, check out [DigitalOcean](https://m.do.co/c/b5ee103e23c3) or [Linode](https://www.linode.com/?r=e90a6fb2a6999fb4ec7b60b1add3e288f97954bf) and the [Dokku docs](http://dokku.viewdocs.io/dokku/) to get started.
+>
+>**Student Developer?** The [GitHub Student Developer Pack](https://education.github.com/pack?sort=popularity&tag=Cloud) has several discounts for cloud hosting, Ruby tutorials, and more!
## Setting up a new deployment
-Below are steps & notes to deploy HackathonManager on Dokku. Need to update an existing deployment?
+Below are steps to deploy a new HackathonManager instance on Dokku. To update an existing Dokku deployment, check out our [updating docs](updating-hm.html).
+
+If you have any questions, please don't hesitate to reach out to the [codeRIT Engineering Team](mailto:engineering@coderit.org)! This doc is very much a work in progress but we want to keep it as up to date as possible.
-If you have any questions at all, please don't hesitate to reach out to the [codeRIT Engineering Team](mailto:engineering@coderit.org)! This doc is very much a work in progress but we want to keep it as up to date as possible.
+## Dokku Setup
-## Dokku plugins
+### Plugins
Currently used and required Dokku plugins (other than the defaults):
@@ -21,9 +25,9 @@ Currently used and required Dokku plugins (other than the defaults):
- [Redis](https://github.com/dokku/dokku-redis) (background jobs + caching)
- [dokku-letsencrypt](https://github.com/dokku/dokku-letsencrypt) (Optional: free, automated SSL certificates)
-### Dokku Setup Steps
+### Setup Steps
-**We'll be using `hm` as the app name in these steps,** as well as sharing the same `hm` name for both the app, database, and redis name. You're free to use another names.
+**We'll be using `hm` as the app name in these steps,** as well as sharing the same `hm` name for both the app, database, and redis name. You're free to use other names.
```bash
dokku apps:create hm
@@ -103,14 +107,14 @@ dokku letsencrypt hm
- Deploy should succeed without any red flags in the build log
- Should be able to submit an application on the website & receive an immediate confirmation email
-### Promote account to admin
+### Promote account to director
```bash
dokku enter hm web
# Wait for a bash shell to start...
$ bin/rails c
# Wait for the Rails console to start...
-User.find_by(email: "your-email@example.com").update_attribute(:role, :admin)
+User.find_by(email: "your-email@example.com").update_attribute(:role, :director)
exit
exit
```
@@ -177,4 +181,4 @@ In order to support groupdate, timezone tables must be created.
```bash
mysql_tzinfo_to_sql /usr/share/zoneinfo | mysql -u $OPENSHIFT_MYSQL_DB_USERNAME -p mysql
-```
\ No newline at end of file
+```
diff --git a/docs/deployment-okd.md b/docs/deployment-okd.md
index 69c00fcf8..23468082f 100644
--- a/docs/deployment-okd.md
+++ b/docs/deployment-okd.md
@@ -152,7 +152,7 @@ spec:
1. Seed the database (schools, emails, etc) -- do this **before** you create your first user
2. Apply as a hacker
-3. Manually promote your (first) account to an admin
+3. Manually promote your (first) account to a director
4. Configure your hackathon
### Seed the database
@@ -170,7 +170,7 @@ exit
1. Open your hackathon's website, create an account, and complete an application
2. Validate that you received a confirmation email (if you didn't, don't fix it now, but take note for later)
-### Manually promote your account to admin status
+### Manually promote your account to director status
1. On the OKD website, navigate to the currently-running HackathonManager pod (Applications -> Pods -> Click the HM pod in the list)
2. In the tab bar, click "Terminal"
@@ -178,7 +178,7 @@ exit
```bash
bin/rails c
# Wait for the Rails console to start...
-User.find_by(email: "your-email@example.com").update_attribute(:role, :admin)
+User.find_by(email: "your-email@example.com").update_attribute(:role, :director)
exit
exit
```
diff --git a/docs/messages.md b/docs/messages.md
index 9131d1553..c47392f52 100644
--- a/docs/messages.md
+++ b/docs/messages.md
@@ -53,7 +53,7 @@ Automated emails can also be sent out upon certain events happening. All events
* **Questionnaire status** — Upon being accepted, denied, RSVP'd, etc
* **Bust list** — Becoming a passenger or bus captain
-These messages are sent immediatley upon an applicant entering the given state. For example, when an admin marks someone as "accepted," they will immediately receive any automated messages associated with the "Questionnaire Status: Accepted" event.
+These messages are sent immediatley upon an applicant entering the given state. For example, when a staff member marks someone as "accepted," they will immediately receive any automated messages assocaited with the "Questionnaire Status: Accepted" event.
## Message formatting
diff --git a/test/controllers/bus_lists_controller_test.rb b/test/controllers/bus_lists_controller_test.rb
index c32066764..e50ecd7fc 100644
--- a/test/controllers/bus_lists_controller_test.rb
+++ b/test/controllers/bus_lists_controller_test.rb
@@ -19,7 +19,7 @@ class BusListsControllerTest < ActionController::TestCase
context "while authenticated without a questionnaire" do
setup do
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
@user = create(:user, email: "newabc@example.com")
sign_in @user
end
@@ -37,7 +37,7 @@ class BusListsControllerTest < ActionController::TestCase
context "while authenticated with a questionnaire but no bus list" do
setup do
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @questionnaire.user
@questionnaire.update_attribute(:acc_status, "accepted")
end
@@ -55,7 +55,7 @@ class BusListsControllerTest < ActionController::TestCase
context "while authenticated with a questionnaire with a bus list" do
setup do
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @questionnaire.user
@questionnaire.update_attribute(:acc_status, "accepted")
@bus_list = create(:bus_list)
diff --git a/test/controllers/manage/bus_lists_controller_test.rb b/test/controllers/manage/bus_lists_controller_test.rb
index c03b743b8..1d12d9363 100644
--- a/test/controllers/manage/bus_lists_controller_test.rb
+++ b/test/controllers/manage/bus_lists_controller_test.rb
@@ -137,10 +137,76 @@ class Manage::BusListsControllerTest < ActionController::TestCase
end
end
- context "while authenticated as a limited access admin" do
+ context "while authenticated as a volunteer" do
setup do
- @user = create(:limited_access_admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:volunteer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
+ sign_in @user
+ end
+
+ should "allow access to manage_bus_lists#index" do
+ get :index
+ assert_response :success
+ end
+
+ should "allow access to manage_bus_lists#show" do
+ get :show, params: { id: @bus_list }
+ assert_response :success
+ end
+
+ should "not allow access to manage_bus_lists#new" do
+ get :new
+ assert_response :redirect
+ assert_redirected_to manage_bus_lists_path
+ end
+
+ should "not allow access to manage_bus_lists#edit" do
+ get :edit, params: { id: @bus_list }
+ assert_response :redirect
+ assert_redirected_to manage_bus_lists_path
+ end
+
+ should "not allow access to manage_bus_lists#create" do
+ post :create, params: { bus_list: { email: "test@example.com" } }
+ assert_response :redirect
+ assert_redirected_to manage_bus_lists_path
+ end
+
+ should "not allow access to manage_bus_lists#update" do
+ patch :update, params: { id: @bus_list, bus_list: { email: "test@example.com" } }
+ assert_response :redirect
+ assert_redirected_to manage_bus_lists_path
+ end
+
+ should "not allow access to manage_bus_lists#toggle_bus_captain" do
+ questionnaire = create(:questionnaire)
+ assert_difference "enqueued_jobs.size", 0 do
+ patch :toggle_bus_captain, params: { id: @bus_list, questionnaire_id: questionnaire.id, bus_captain: "1" }
+ end
+ assert_equal false, questionnaire.reload.is_bus_captain
+ assert_response :redirect
+ assert_redirected_to manage_bus_lists_path
+ end
+
+ should "not allow access to manage_bus_lists#send_update_email" do
+ assert_difference "enqueued_jobs.size", 0 do
+ patch :send_update_email, params: { id: @bus_list }
+ end
+ assert_response :redirect
+ assert_redirected_to manage_bus_lists_path
+ end
+
+ should "not allow access to manage_bus_lists#destroy" do
+ patch :destroy, params: { id: @bus_list }
+ assert_response :redirect
+ assert_redirected_to manage_bus_lists_path
+ end
+ end
+
+ context "while authenticated as an organizer" do
+ setup do
+ @user = create(:organizer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
@@ -203,9 +269,9 @@ class Manage::BusListsControllerTest < ActionController::TestCase
end
end
- context "while authenticated as an admin" do
+ context "while authenticated as a director" do
setup do
- @user = create(:admin)
+ @user = create(:director)
@request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
diff --git a/test/controllers/manage/checkins_controller_test.rb b/test/controllers/manage/checkins_controller_test.rb
index 58d2f6df3..6b92b4276 100644
--- a/test/controllers/manage/checkins_controller_test.rb
+++ b/test/controllers/manage/checkins_controller_test.rb
@@ -15,7 +15,7 @@ class Manage::CheckinsControllerTest < ActionController::TestCase
setup do
if do_sign_in
@user = create(:user)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @user
end
end
@@ -43,7 +43,7 @@ class Manage::CheckinsControllerTest < ActionController::TestCase
context "while authenticated as a user" do
setup do
@user = create(:user)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @user
end
@@ -52,42 +52,17 @@ class Manage::CheckinsControllerTest < ActionController::TestCase
end
end
- limited_conditions = {
- 'event tracking user' => :event_tracking,
- }
-
- limited_conditions.each do |condition_name, user_role|
- context "while authenticated as a #{condition_name}" do
- setup do
- @user = create(:user, role: user_role)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
- sign_in @user
- end
-
- should "not get index" do
- test_index_failure
- end
-
- should "not show checkin" do
- test_show_failure
- end
-
- should "not render checking datatable" do
- test_datatable_failure
- end
- end
- end
-
success_conditions = {
- 'limited access admin' => :admin_limited_access,
- 'admin' => :admin
+ 'volunteer' => :volunteer,
+ 'organizer' => :organizer,
+ 'director' => :director
}
success_conditions.each do |condition_name, user_role|
context "while authenticated as a #{condition_name}" do
setup do
@user = create(:user, role: user_role)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @user
end
diff --git a/test/controllers/manage/configs_controller_test.rb b/test/controllers/manage/configs_controller_test.rb
index 038423fa4..826bb3043 100644
--- a/test/controllers/manage/configs_controller_test.rb
+++ b/test/controllers/manage/configs_controller_test.rb
@@ -31,7 +31,7 @@ class Manage::ConfigsControllerTest < ActionController::TestCase
context "while authenticated as a user" do
setup do
@user = create(:user)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @user
end
@@ -61,10 +61,10 @@ class Manage::ConfigsControllerTest < ActionController::TestCase
end
end
- context "while authenticated as a limited access admin" do
+ context "while authenticated as a volunteer" do
setup do
- @user = create(:limited_access_admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:volunteer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
@@ -91,10 +91,40 @@ class Manage::ConfigsControllerTest < ActionController::TestCase
end
end
- context "while authenticated as an admin" do
+ context "while authenticated as an organizer" do
setup do
- @user = create(:admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:organizer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
+ sign_in @user
+ end
+
+ should "not allow access to manage_configs#index" do
+ get :index
+ assert_response :redirect
+ end
+
+ should "not allow access to manage_configs#edit" do
+ get :edit, params: { id: "registration_is_open" }
+ assert_response :redirect
+ end
+
+ should "not update config" do
+ HackathonConfig["registration_is_open"] = false
+ patch :update, params: { id: "registration_is_open", hackathon_config: { registration_is_open: "true" } }
+ assert_equal false, HackathonConfig["registration_is_open"]
+ end
+
+ should "not update css config" do
+ HackathonConfig["custom_css"] = ""
+ patch :update_only_css_variables, params: { id: "custom_css", hackathon_config: { custom_css: ":root {\n --foo: #fff;\n}" } }
+ assert_equal "", HackathonConfig["custom_css"]
+ end
+ end
+
+ context "while authenticated as a director" do
+ setup do
+ @user = create(:director)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
diff --git a/test/controllers/manage/dashboard_controller_test.rb b/test/controllers/manage/dashboard_controller_test.rb
index f1dad23c1..f473968e6 100644
--- a/test/controllers/manage/dashboard_controller_test.rb
+++ b/test/controllers/manage/dashboard_controller_test.rb
@@ -12,21 +12,156 @@ class Manage::DashboardControllerTest < ActionController::TestCase
context "while authenticated as a user" do
setup do
@user = create(:user)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @user
end
- should "allow access to manage_dashboard#index" do
+ should "not allow access to manage_dashboard#index" do
get :index
assert_response :redirect
assert_redirected_to root_path
end
+
+ should "not allow access to all data endpoints" do
+ school1 = FactoryBot.create(:school)
+ school2 = FactoryBot.create(:school)
+ FactoryBot.create_list(:questionnaire, 20, school_id: school1.id, acc_status: "pending")
+ FactoryBot.create_list(:questionnaire, 20, school_id: school1.id, acc_status: "accepted")
+ FactoryBot.create_list(:questionnaire, 10, school_id: school2.id, acc_status: "accepted")
+ Questionnaire::POSSIBLE_ACC_STATUS.each do |status, _name|
+ FactoryBot.create_list(:questionnaire, 1, school_id: school2.id, acc_status: status)
+ end
+
+ stub_request(:get, "https://geocoding.geo.census.gov/geocoder/locations/address?street=123+Fake+Street&city=Rochester&state=NY&benchmark=Public_AR_Current&format=json")
+ .to_return(status: 200, body: '{ "result":{ "addressMatches":[{ "coordinates":{ "x": 100, "y": 100 } }] } }', headers: { 'Content-Type' => 'application/json; charset=UTF-8' })
+ stub_request(:get, "https://geo.fcc.gov/api/census/area?format=json&lat=100&lon=100")
+ .to_return(status: 200, body: '{ "results":[{ "country_fips":1234 }] }', headers: { 'Content-Type' => 'application/json; charset=UTF-8' })
+
+ paths = [
+ :todays_activity_data,
+ :todays_stats_data,
+ :checkin_activity_data,
+ :confirmation_activity_data,
+ :application_activity_data,
+ :schools_confirmed_data,
+ :user_distribution_data,
+ :application_distribution_data,
+ :schools_applied_data
+ ]
+
+ paths.each do |path|
+ get path
+ assert_redirected_to root_path
+ end
+
+ get :map_data, format: "tsv"
+ assert_redirected_to root_path
+ end
+ end
+
+ context "while authenticated as a volunteer" do
+ setup do
+ @user = create(:volunteer)
+ @request.env["devise.mapping"] = Devise.mappings[:director]
+ sign_in @user
+ end
+
+ should "not allow access to manage_dashboard#index" do
+ get :index
+ assert_response :redirect
+ assert_redirected_to manage_checkins_path
+ end
+
+ should "not allow access to all data endpoints" do
+ school1 = FactoryBot.create(:school)
+ school2 = FactoryBot.create(:school)
+ FactoryBot.create_list(:questionnaire, 20, school_id: school1.id, acc_status: "pending")
+ FactoryBot.create_list(:questionnaire, 20, school_id: school1.id, acc_status: "accepted")
+ FactoryBot.create_list(:questionnaire, 10, school_id: school2.id, acc_status: "accepted")
+ Questionnaire::POSSIBLE_ACC_STATUS.each do |status, _name|
+ FactoryBot.create_list(:questionnaire, 1, school_id: school2.id, acc_status: status)
+ end
+
+ stub_request(:get, "https://geocoding.geo.census.gov/geocoder/locations/address?street=123+Fake+Street&city=Rochester&state=NY&benchmark=Public_AR_Current&format=json")
+ .to_return(status: 200, body: '{ "result":{ "addressMatches":[{ "coordinates":{ "x": 100, "y": 100 } }] } }', headers: { 'Content-Type' => 'application/json; charset=UTF-8' })
+ stub_request(:get, "https://geo.fcc.gov/api/census/area?format=json&lat=100&lon=100")
+ .to_return(status: 200, body: '{ "results":[{ "country_fips":1234 }] }', headers: { 'Content-Type' => 'application/json; charset=UTF-8' })
+
+ paths = [
+ :todays_activity_data,
+ :todays_stats_data,
+ :checkin_activity_data,
+ :confirmation_activity_data,
+ :application_activity_data,
+ :schools_confirmed_data,
+ :user_distribution_data,
+ :application_distribution_data,
+ :schools_applied_data
+ ]
+
+ paths.each do |path|
+ get path
+ assert_redirected_to manage_checkins_path
+ end
+
+ get :map_data, format: "tsv"
+ assert_redirected_to manage_checkins_path
+ end
+ end
+
+ context "while authenticated as an organizer" do
+ setup do
+ @user = create(:organizer)
+ @request.env["devise.mapping"] = Devise.mappings[:director]
+ sign_in @user
+ end
+
+ should "allow access to manage_dashboard#index" do
+ get :index
+ assert_response :success
+ end
+
+ should "allow access to all data endpoints" do
+ school1 = FactoryBot.create(:school)
+ school2 = FactoryBot.create(:school)
+ FactoryBot.create_list(:questionnaire, 20, school_id: school1.id, acc_status: "pending")
+ FactoryBot.create_list(:questionnaire, 20, school_id: school1.id, acc_status: "accepted")
+ FactoryBot.create_list(:questionnaire, 10, school_id: school2.id, acc_status: "accepted")
+ Questionnaire::POSSIBLE_ACC_STATUS.each do |status, _name|
+ FactoryBot.create_list(:questionnaire, 1, school_id: school2.id, acc_status: status)
+ end
+
+ stub_request(:get, "https://geocoding.geo.census.gov/geocoder/locations/address?street=123+Fake+Street&city=Rochester&state=NY&benchmark=Public_AR_Current&format=json")
+ .to_return(status: 200, body: '{ "result":{ "addressMatches":[{ "coordinates":{ "x": 100, "y": 100 } }] } }', headers: { 'Content-Type' => 'application/json; charset=UTF-8' })
+ stub_request(:get, "https://geo.fcc.gov/api/census/area?format=json&lat=100&lon=100")
+ .to_return(status: 200, body: '{ "results":[{ "country_fips":1234 }] }', headers: { 'Content-Type' => 'application/json; charset=UTF-8' })
+
+ paths = [
+ :todays_activity_data,
+ :todays_stats_data,
+ :checkin_activity_data,
+ :confirmation_activity_data,
+ :application_activity_data,
+ :schools_confirmed_data,
+ :user_distribution_data,
+ :application_distribution_data,
+ :schools_applied_data
+ ]
+
+ paths.each do |path|
+ get path
+ assert_response :success
+ end
+
+ get :map_data, format: "tsv"
+ assert_response :success
+ end
end
- context "while authenticated as an admin" do
+ context "while authenticated as a director" do
setup do
- @user = create(:admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:director)
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @user
end
diff --git a/test/controllers/manage/messages_controller_test.rb b/test/controllers/manage/messages_controller_test.rb
index 291ee290a..c63245752 100644
--- a/test/controllers/manage/messages_controller_test.rb
+++ b/test/controllers/manage/messages_controller_test.rb
@@ -200,10 +200,110 @@ class Manage::MessagesControllerTest < ActionController::TestCase
end
end
- context "while authenticated as a limited access admin" do
+ context "while authenticated as a volunteer" do
setup do
- @user = create(:limited_access_admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:volunteer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
+ sign_in @user
+ end
+
+ should "not allow access to manage_messages#index" do
+ get :index
+ assert_response :redirect
+ 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_checkins_path
+ end
+
+ should "not allow access to manage_messages#new" do
+ get :new
+ assert_response :redirect
+ assert_redirected_to manage_messages_path
+ end
+
+ should "not allow access to manage_messages#show" do
+ get :show, params: { id: @message }
+ assert_response :redirect
+ assert_redirected_to manage_checkins_path
+ end
+
+ should "not allow access to manage_messages#edit" do
+ get :edit, params: { id: @message }
+ assert_response :redirect
+ assert_redirected_to manage_messages_path
+ end
+
+ should "not allow access to manage_messages#create" do
+ post :create, params: { message: { email: "test@example.com" } }
+ assert_response :redirect
+ assert_redirected_to manage_messages_path
+ end
+
+ should "not allow access to manage_messages#update" do
+ patch :update, params: { id: @message, message: { email: "test@example.com" } }
+ assert_response :redirect
+ assert_redirected_to manage_messages_path
+ end
+
+ should "not allow access to manage_messages#destroy" do
+ patch :destroy, params: { id: @message }
+ assert_response :redirect
+ assert_redirected_to manage_messages_path
+ end
+
+ should "not deliver message" do
+ assert_difference("enqueued_jobs.size", 0) do
+ patch :deliver, params: { id: @message }
+ end
+ assert_response :redirect
+ assert_redirected_to manage_messages_path
+ end
+
+ should "not allow access to manage_messages#preview" do
+ get :preview, params: { id: @message }
+ assert_response :redirect
+ assert_redirected_to manage_checkins_path
+ end
+
+ should "not allow access to manage_messages#live_preview" do
+ get :live_preview, params: { body: "foo bar" }
+ assert_response :redirect
+ assert_redirected_to manage_messages_path
+ end
+
+ should "not allow access to manage_messages#duplicate" do
+ assert_difference("Message.count", 0) do
+ patch :duplicate, params: { id: @message }
+ end
+ assert_response :redirect
+ assert_redirected_to manage_messages_path
+ end
+
+ should "not allow access to manage_messages#template" do
+ test_template_failure
+ end
+
+ should "not allow access to manage_messages#template_preview" do
+ test_template_preview_failure
+ end
+
+ should "not allow access to manage_messages#template_update" do
+ test_template_update_failure
+ end
+
+ should "not allow access to manage_messages#template_replace_with_default" do
+ test_template_replace_with_default_failure
+ end
+ end
+
+ context "while authenticated as an organizer" do
+ setup do
+ @user = create(:organizer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
@@ -296,9 +396,9 @@ class Manage::MessagesControllerTest < ActionController::TestCase
end
end
- context "while authenticated as an admin" do
+ context "while authenticated as a director" do
setup do
- @user = create(:admin)
+ @user = create(:director)
@request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
diff --git a/test/controllers/manage/questionnaires_controller_test.rb b/test/controllers/manage/questionnaires_controller_test.rb
index 969937faa..ab7f84023 100644
--- a/test/controllers/manage/questionnaires_controller_test.rb
+++ b/test/controllers/manage/questionnaires_controller_test.rb
@@ -50,12 +50,6 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
assert_redirected_to new_user_session_path
end
- should "not allow convert questionnaire's user to an admin" do
- patch :convert_to_admin, params: { id: @questionnaire }
- assert_response :redirect
- assert_redirected_to new_user_session_path
- end
-
should "not allow access to manage_questionnaires#destroy" do
patch :destroy, params: { id: @questionnaire }
assert_response :redirect
@@ -77,7 +71,7 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
context "while authenticated as a user" do
setup do
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @questionnaire.user
end
@@ -123,12 +117,6 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
assert_redirected_to root_path
end
- should "not allow convert questionnaire's user to an admin" do
- patch :convert_to_admin, params: { id: @questionnaire }
- assert_response :redirect
- assert_redirected_to root_path
- end
-
should "not allow access to manage_questionnaires#destroy" do
patch :destroy, params: { id: @questionnaire }
assert_response :redirect
@@ -148,10 +136,10 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
end
end
- context "while authenticated as a limited access admin" do
+ context "while authenticated as a volunteer" do
setup do
- @user = create(:limited_access_admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:volunteer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
@@ -194,8 +182,66 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
assert_redirected_to manage_questionnaires_path
end
- should "not allow convert questionnaire's user to an admin" do
- patch :convert_to_admin, params: { id: @questionnaire }
+ should "not allow access to manage_questionnaires#destroy" do
+ patch :destroy, params: { id: @questionnaire }
+ assert_response :redirect
+ assert_redirected_to manage_questionnaires_path
+ end
+
+ should "not access to manage_questionnaires#update_acc_status" do
+ patch :update_acc_status, params: { id: @questionnaire, questionnaire: { acc_status: "accepted" } }
+ assert_response :redirect
+ assert_redirected_to manage_questionnaires_path
+ end
+
+ should "allow access to manage_questionnaires#bulk_apply" do
+ patch :bulk_apply, params: { bulk_action: "waitlist", bulk_ids: [@questionnaire.id] }
+ assert_response :success
+ end
+ end
+
+ context "while authenticated as an organizer" do
+ setup do
+ @user = create(:organizer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
+ sign_in @user
+ end
+
+ should "allow access to manage_questionnaires#index" do
+ get :index
+ assert_response :success
+ end
+
+ should "allow access to manage_questionnaires datatables api" do
+ post :datatable, format: :json, params: { "columns[0][data]" => "" }
+ assert_response :success
+ end
+
+ should "allow access to manage_questionnaires#show" do
+ get :show, params: { id: @questionnaire }
+ assert_response :success
+ end
+
+ should "not allow access to manage_questionnaires#new" do
+ get :new, params: { id: @questionnaire }
+ assert_response :redirect
+ assert_redirected_to manage_questionnaires_path
+ end
+
+ should "not allow access to manage_questionnaires#edit" do
+ get :edit, params: { id: @questionnaire }
+ assert_response :redirect
+ assert_redirected_to manage_questionnaires_path
+ end
+
+ should "not allow access to manage_questionnaires#create" do
+ post :create, params: { questionnaire: { major: "Best Major" } }
+ assert_response :redirect
+ assert_redirected_to manage_questionnaires_path
+ end
+
+ should "not allow access to manage_questionnaires#update" do
+ patch :update, params: { id: @questionnaire, questionnaire: { major: "Best Major" } }
assert_response :redirect
assert_redirected_to manage_questionnaires_path
end
@@ -218,10 +264,10 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
end
end
- context "while authenticated as an admin" do
+ context "while authenticated as a director" do
setup do
- @user = create(:admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:director)
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @user
end
@@ -299,18 +345,21 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
assert_redirected_to manage_questionnaire_path(assigns(:questionnaire))
end
- should "convert questionnaire's user to an admin" do
- patch :convert_to_admin, params: { id: @questionnaire }
- assert assigns(:questionnaire).user.admin?
- assert_nil assigns(:questionnaire).user.reload.questionnaire
- assert_redirected_to edit_manage_user_path(assigns(:questionnaire).user)
- end
+ context "destroy questionnaire" do
+ 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: :director).size) do
+ delete :destroy, params: { id: @questionnaire }
+ end
+ end
- should "destroy questionnaire" do
- assert_difference("Questionnaire.count", -1) do
- delete :destroy, params: { id: @questionnaire }
+ should "user destroy questionnaire" do
+ assert_difference('Questionnaire.count', -1) do
+ delete :destroy, params: { id: @questionnaire }
+ end
+ assert_redirected_to manage_questionnaires_path
end
- assert_redirected_to manage_questionnaires_path
end
should "check in the questionnaire" do
@@ -341,7 +390,7 @@ class Manage::QuestionnairesControllerTest < ActionController::TestCase
assert_equal @user.id, @questionnaire.checked_in_by_id
assert_equal true, @questionnaire.agreement_accepted
assert_equal true, @questionnaire.can_share_info
- assert_equal "(123) 333-3333", @questionnaire.phone
+ assert_equal "1233333333", @questionnaire.phone
assert_equal "new_email@example.com", @questionnaire.email
assert_match /Checked in/, flash[:notice]
assert_response :redirect
diff --git a/test/controllers/manage/schools_controller_test.rb b/test/controllers/manage/schools_controller_test.rb
index 6402b80ce..a19f9406d 100644
--- a/test/controllers/manage/schools_controller_test.rb
+++ b/test/controllers/manage/schools_controller_test.rb
@@ -134,10 +134,75 @@ class Manage::SchoolsControllerTest < ActionController::TestCase
end
end
- context "while authenticated as a limited access admin" do
+ context "while authenticated as a volunteer" do
setup do
- @user = create(:limited_access_admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:volunteer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
+ sign_in @user
+ end
+
+ should "allow access to manage_schools#index" do
+ get :index
+ assert_response :success
+ end
+
+ should "allow access to manage_schools datatables api" do
+ post :datatable, format: :json, params: { "columns[0][data]" => "" }
+ assert_response :success
+ end
+
+ should "allow access to manage_schools#show" do
+ get :show, params: { id: @school }
+ assert_response :success
+ end
+
+ should "not allow access to manage_schools#new" do
+ get :new
+ assert_response :redirect
+ assert_redirected_to manage_schools_path
+ end
+
+ should "not allow access to manage_schools#edit" do
+ get :edit, params: { id: @school }
+ assert_response :redirect
+ assert_redirected_to manage_schools_path
+ end
+
+ should "not allow access to manage_schools#create" do
+ post :create, params: { school: { name: "My Test School" } }
+ assert_response :redirect
+ assert_redirected_to manage_schools_path
+ end
+
+ should "not allow access to manage_schools#update" do
+ patch :update, params: { id: @school, school: { name: "My Test School" } }
+ assert_response :redirect
+ assert_redirected_to manage_schools_path
+ end
+
+ should "not allow access to manage_schools#destroy" do
+ patch :destroy, params: { id: @school }
+ assert_response :redirect
+ assert_redirected_to manage_schools_path
+ end
+
+ should "not allow access to manage_schools#merge" do
+ patch :merge, params: { id: @school }
+ assert_response :redirect
+ assert_redirected_to manage_schools_path
+ end
+
+ should "not allow access to manage_schools#perform_merge" do
+ patch :perform_merge, params: { id: @school, school: { id: "My Test School" } }
+ assert_response :redirect
+ assert_redirected_to manage_schools_path
+ end
+ end
+
+ context "while authenticated as an organizer" do
+ setup do
+ @user = create(:organizer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
@@ -199,9 +264,9 @@ class Manage::SchoolsControllerTest < ActionController::TestCase
end
end
- context "while authenticated as an admin" do
+ context "while authenticated as a director" do
setup do
- @user = create(:admin)
+ @user = create(:director)
@request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
diff --git a/test/controllers/manage/stats_controller_test.rb b/test/controllers/manage/stats_controller_test.rb
index 9e4e66f65..79aa2c9cb 100644
--- a/test/controllers/manage/stats_controller_test.rb
+++ b/test/controllers/manage/stats_controller_test.rb
@@ -20,7 +20,7 @@ class Manage::StatsControllerTest < ActionController::TestCase
context "while authenticated as a user" do
setup do
@user = create(:user)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @user
end
@@ -39,14 +39,61 @@ class Manage::StatsControllerTest < ActionController::TestCase
end
end
- context "while authenticated as an admin" do
+ context "while authenticated as a volunteer" do
setup do
- @user = create(:admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:volunteer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
- should "allow access to manage_dashboard#index" do
+ should "not allow access to stats#index" do
+ get :index
+ assert_response :redirect
+ 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_checkins_path
+ end
+ end
+ end
+
+ context "while authenticated as an organizer" do
+ setup do
+ @user = create(:organizer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
+ sign_in @user
+ end
+
+ should "allow access to stats#index" do
+ get :index
+ assert_response :success
+ end
+
+ should "allow access to all data endpoints" do
+ school = create(:school)
+ Questionnaire::POSSIBLE_ACC_STATUS.each do |status, _name|
+ create_list(:questionnaire, 5, school_id: school.id, acc_status: status, dietary_restrictions: "Vegetarian", special_needs: "Something")
+ end
+
+ paths.each do |path|
+ patch path
+ assert_response :success
+ end
+ end
+ end
+
+ context "while authenticated as a director" do
+ setup do
+ @user = create(:director)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
+ sign_in @user
+ end
+
+ should "allow access to stats#index" do
get :index
assert_response :success
end
diff --git a/test/controllers/manage/trackable_events_controller_test.rb b/test/controllers/manage/trackable_events_controller_test.rb
index faf5b4478..67cd2d398 100644
--- a/test/controllers/manage/trackable_events_controller_test.rb
+++ b/test/controllers/manage/trackable_events_controller_test.rb
@@ -15,7 +15,7 @@ class Manage::TrackableEventsControllerTest < ActionController::TestCase
setup do
if do_sign_in
@user = create(:user)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @user
@trackable_event.update_attribute(:user, @user)
end
@@ -52,15 +52,15 @@ class Manage::TrackableEventsControllerTest < ActionController::TestCase
end
limited_conditions = {
- 'event tracking user' => :event_tracking,
- 'limited access admin' => :admin_limited_access
+ 'volunteer' => :volunteer,
+ 'organizer' => :organizer
}
limited_conditions.each do |condition_name, user_role|
context "while authenticated as a #{condition_name}" do
setup do
@user = create(:user, role: user_role)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
@trackable_event.update_attribute(:user, @user)
end
@@ -105,10 +105,10 @@ class Manage::TrackableEventsControllerTest < ActionController::TestCase
end
end
- context "while authenticated as an admin" do
+ context "while authenticated as a director" do
setup do
- @user = create(:admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:director)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
diff --git a/test/controllers/manage/trackable_tags_controller_test.rb b/test/controllers/manage/trackable_tags_controller_test.rb
index a392cf371..56c273cfa 100644
--- a/test/controllers/manage/trackable_tags_controller_test.rb
+++ b/test/controllers/manage/trackable_tags_controller_test.rb
@@ -15,7 +15,7 @@ class Manage::TrackableTagsControllerTest < ActionController::TestCase
setup do
if do_sign_in
@user = create(:user)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @user
end
end
@@ -51,15 +51,15 @@ class Manage::TrackableTagsControllerTest < ActionController::TestCase
end
limited_conditions = {
- 'event tracking user' => :event_tracking,
- 'limited access admin' => :admin_limited_access
+ 'volunteer' => :volunteer,
+ 'organizer' => :organizer
}
limited_conditions.each do |condition_name, user_role|
context "while authenticated as a #{condition_name}" do
setup do
@user = create(:user, role: user_role)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
@@ -93,10 +93,10 @@ class Manage::TrackableTagsControllerTest < ActionController::TestCase
end
end
- context "while authenticated as an admin" do
+ context "while authenticated as a director" do
setup do
- @user = create(:admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:director)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
diff --git a/test/controllers/manage/users_controller_test.rb b/test/controllers/manage/users_controller_test.rb
index 1a2b5dc42..2ea0cd3c9 100644
--- a/test/controllers/manage/users_controller_test.rb
+++ b/test/controllers/manage/users_controller_test.rb
@@ -17,8 +17,8 @@ class Manage::UsersControllerTest < ActionController::TestCase
assert_response 401
end
- should "not allow access to manage_users admin datatables api" do
- post :admin_datatable, format: :json, params: { "columns[0][data]" => "" }
+ should "not allow access to manage_users staff datatables api" do
+ post :staff_datatable, format: :json, params: { "columns[0][data]" => "" }
assert_response 401
end
@@ -65,8 +65,8 @@ class Manage::UsersControllerTest < ActionController::TestCase
assert_redirected_to root_path
end
- should "not allow access to manage_users admin datatables api" do
- post :admin_datatable, format: :json, params: { "columns[0][data]" => "" }
+ should "not allow access to manage_users staff datatables api" do
+ post :staff_datatable, format: :json, params: { "columns[0][data]" => "" }
assert_response :redirect
assert_redirected_to root_path
end
@@ -96,31 +96,77 @@ class Manage::UsersControllerTest < ActionController::TestCase
end
end
- context "while authenticated as a limited access admin" do
+ context "while authenticated as a volunteer" do
setup do
- @user = create(:limited_access_admin)
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @user = create(:volunteer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
should "not allow access to manage_users#index" do
get :index
- assert_redirected_to 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 root_path
+ assert_redirected_to manage_checkins_path
end
- should "not allow access to manage_users admins datatables api" do
- post :admin_datatable, format: :json, params: { "columns[0][data]" => "" }
- assert_redirected_to root_path
+ should "not allow access to manage_users staff datatables api" do
+ post :staff_datatable, format: :json, params: { "columns[0][data]" => "" }
+ assert_redirected_to manage_checkins_path
end
should "allow access to manage_users#show" do
get :show, params: { id: @user }
- assert_redirected_to root_path
+ assert_redirected_to manage_checkins_path
+ end
+
+ should "not allow access to manage_users#edit" do
+ get :edit, params: { id: @user }
+ assert_response :redirect
+ assert_redirected_to manage_users_path
+ end
+
+ should "not allow access to manage_users#update" do
+ patch :update, params: { id: @user, user: { email: "test@example.com" } }
+ assert_response :redirect
+ assert_redirected_to manage_users_path
+ end
+
+ should "not allow access to manage_users#destroy" do
+ patch :destroy, params: { id: @user }
+ assert_response :redirect
+ assert_redirected_to manage_users_path
+ end
+ end
+
+ context "while authenticated as an organizer" do
+ setup do
+ @user = create(:organizer)
+ @request.env["devise.mapping"] = Devise.mappings[:user]
+ sign_in @user
+ end
+
+ should "not allow access to manage_users#index" do
+ get :index
+ assert_redirected_to manage_root_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
+ 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
+ end
+
+ should "allow access to manage_users#show" do
+ get :show, params: { id: @user }
+ assert_redirected_to manage_root_path
end
should "not allow access to manage_users#edit" do
@@ -142,9 +188,9 @@ class Manage::UsersControllerTest < ActionController::TestCase
end
end
- context "while authenticated as an admin" do
+ context "while authenticated as a director" do
setup do
- @user = create(:admin)
+ @user = create(:director)
@request.env["devise.mapping"] = Devise.mappings[:user]
sign_in @user
end
diff --git a/test/controllers/questionnaires_controller_test.rb b/test/controllers/questionnaires_controller_test.rb
index faf0279a0..a3f14b404 100644
--- a/test/controllers/questionnaires_controller_test.rb
+++ b/test/controllers/questionnaires_controller_test.rb
@@ -35,7 +35,7 @@ class QuestionnairesControllerTest < ActionController::TestCase
context "while authenticated without a completed questionnaire" do
setup do
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
@user = create(:user)
sign_in @user
end
@@ -76,6 +76,15 @@ class QuestionnairesControllerTest < ActionController::TestCase
end
end
+ context "with block questionnaires set" do
+ should "not allow creation" do
+ HackathonConfig['accepting_questionnaires'] = false
+ assert_difference('Questionnaire.count', 0) do
+ post :create, params: { questionnaire: { experience: @questionnaire.experience, interest: @questionnaire.interest, phone: @questionnaire.phone, level_of_study: @questionnaire.level_of_study, date_of_birth: @questionnaire.date_of_birth, shirt_size: @questionnaire.shirt_size, school_id: @school.id, agreement_accepted: "1", code_of_conduct_accepted: "1", data_sharing_accepted: "1", major: @questionnaire.major, gender: @questionnaire.gender, why_attend: @questionnaire.why_attend, graduation_year: @questionnaire.graduation_year, race_ethnicity: @questionnaire.race_ethnicity } }
+ end
+ end
+ end
+
context "#school_name" do
context "on create" do
should "save existing school name" do
@@ -130,7 +139,7 @@ class QuestionnairesControllerTest < ActionController::TestCase
context "while authenticated with a completed questionnaire" do
setup do
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @questionnaire.user
end
@@ -156,12 +165,22 @@ class QuestionnairesControllerTest < ActionController::TestCase
assert_redirected_to questionnaires_path
end
- should "destroy questionnaire" do
- assert_difference('Questionnaire.count', -1) do
- delete :destroy
+ context "destroy questionnaire" do
+ 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: :director).size) do
+ delete :destroy
+ end
end
- assert_redirected_to questionnaires_path
+ should "user destroy questionnaire" do
+ assert_difference('Questionnaire.count', -1) do
+ delete :destroy
+ end
+
+ assert_redirected_to questionnaires_path
+ end
end
context "with invalid questionnaire params" do
diff --git a/test/controllers/rsvps_controller_test.rb b/test/controllers/rsvps_controller_test.rb
index 77a15dbe7..7a61408a5 100644
--- a/test/controllers/rsvps_controller_test.rb
+++ b/test/controllers/rsvps_controller_test.rb
@@ -32,7 +32,7 @@ class RsvpsControllerTest < ActionController::TestCase
context "while authenticated without a questionnaire" do
setup do
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
@user = create(:user, email: "newabc@example.com")
sign_in @user
end
@@ -60,7 +60,7 @@ class RsvpsControllerTest < ActionController::TestCase
context "while authenticated with a non-accepted questionnaire" do
setup do
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @questionnaire.user
@questionnaire.acc_status = "denied"
end
@@ -90,7 +90,7 @@ class RsvpsControllerTest < ActionController::TestCase
setup do
clear_enqueued_jobs
- @request.env["devise.mapping"] = Devise.mappings[:admin]
+ @request.env["devise.mapping"] = Devise.mappings[:director]
sign_in @questionnaire.user
@questionnaire.update_attribute(:acc_status, "accepted")
end
@@ -243,5 +243,38 @@ class RsvpsControllerTest < ActionController::TestCase
assert_match /select a RSVP status/, flash[:alert]
assert_redirected_to rsvp_path
end
+
+ 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")
+
+ bus_list1 = create(:bus_list, capacity: 1)
+ bus_list2 = create(:bus_list, capacity: 2)
+ patch :update, params: {
+ questionnaire: {
+ acc_status: "rsvp_confirmed",
+ phone: "(123) 456-7890",
+ bus_list_id: bus_list1.id
+ }
+ }
+
+ assert_difference('enqueued_jobs.size', User.where(role: :director).size) do
+ patch :update, params: {
+ questionnaire: {
+ acc_status: "rsvp_confirmed",
+ phone: "(123) 456-7890",
+ bus_list_id: bus_list2.id
+ }
+ }
+ end
+ end
+
+ should "not queue bus_captain_left email if questionnaire is not a bus captain" do
+ @questionnaire.update_attribute(:is_bus_captain, false)
+ assert_difference('enqueued_jobs.size', 0) do
+ patch :update, params: { questionnaire: { acc_status: "rsvp_confirmed" } }
+ end
+ end
end
end
diff --git a/test/controllers/admin_mailer_test.rb b/test/controllers/staff_mailer_test.rb
similarity index 68%
rename from test/controllers/admin_mailer_test.rb
rename to test/controllers/staff_mailer_test.rb
index 565b63158..591b4089d 100644
--- a/test/controllers/admin_mailer_test.rb
+++ b/test/controllers/staff_mailer_test.rb
@@ -1,6 +1,6 @@
require "test_helper"
-class AdminMailerTest < ActionMailer::TestCase
+class StaffMailerTest < ActionMailer::TestCase
context "weekly_report" do
setup do
@user = create(:user, email: "test@example.com", receive_weekly_report: true)
@@ -10,7 +10,7 @@ class AdminMailerTest < ActionMailer::TestCase
end
should "deliver weekly email report" do
- email = AdminMailer.weekly_report(@user.id).deliver_now
+ email = StaffMailer.weekly_report(@user.id).deliver_now
assert_equal ["test@example.com"], email.to
assert_equal "Your Weekly Report", email.subject
@@ -19,25 +19,25 @@ class AdminMailerTest < ActionMailer::TestCase
should "not send when more than 7 days after event started" do
HackathonConfig["event_start_date"] = 10.days.ago.to_s
- email = AdminMailer.weekly_report(@user.id).deliver_now
+ email = StaffMailer.weekly_report(@user.id).deliver_now
assert_nil email
end
- should "not send if admin is inactive" do
+ should "not send if staff member is inactive" do
@user.update_attribute(:is_active, false)
- email = AdminMailer.weekly_report(@user.id).deliver_now
+ email = StaffMailer.weekly_report(@user.id).deliver_now
assert_nil email
end
- should "not send if admin isn't receiving weekly reports" do
+ should "not send if staff member isn't receiving weekly reports" do
@user.update_attribute(:receive_weekly_report, false)
- email = AdminMailer.weekly_report(@user.id).deliver_now
+ email = StaffMailer.weekly_report(@user.id).deliver_now
assert_nil email
end
should "not send if there hasn't been new activity" do
@questionnaire.update_attribute(:created_at, Date.today)
- email = AdminMailer.weekly_report(@user.id).deliver_now
+ email = StaffMailer.weekly_report(@user.id).deliver_now
assert_nil email
end
end
diff --git a/test/controllers/user_mailer_test.rb b/test/controllers/user_mailer_test.rb
index 5b9d237e4..8bdaeea91 100644
--- a/test/controllers/user_mailer_test.rb
+++ b/test/controllers/user_mailer_test.rb
@@ -29,6 +29,19 @@ class UserMailerTest < ActionMailer::TestCase
end
end
+ context "upon scheduled rsvp reminder email" do
+ setup do
+ @user = create(:user, email: "test@example.com")
+ @message = create(:message, subject: "Are you coming to HackFoo?", type: "automated", trigger: "questionnaire.rsvp_reminder_email")
+
+ should "queue reminder bulk message" do
+ assert_difference "enqueued_jobs.size", 1 do
+ UserMailer.rsvp_reminder_email(@user.id).deliver_later
+ end
+ end
+ end
+ end
+
context "with customized HackathonConfig" do
setup do
@user = create(:user, email: "test@example.com")
diff --git a/test/factories/users.rb b/test/factories/users.rb
index f4b7bedf1..4b5f80572 100644
--- a/test/factories/users.rb
+++ b/test/factories/users.rb
@@ -10,18 +10,25 @@
is_active { true }
receive_weekly_report { false }
- factory :admin do
+ factory :director do
sequence :email do |n|
- "admin#{n}@example.com"
+ "director#{n}@example.com"
end
- role { :admin }
+ role { :director }
end
- factory :limited_access_admin do
+ factory :organizer do
sequence :email do |n|
- "limited_admin#{n}@example.com"
+ "organizer#{n}@example.com"
end
- role { :admin_limited_access }
+ role { :organizer }
+ end
+
+ factory :volunteer do
+ sequence :email do |n|
+ "volunteer#{n}@example.com"
+ end
+ role { :volunteer }
end
end
end
diff --git a/test/integration/user_flows_test.rb b/test/integration/user_flows_test.rb
index f6131b5cf..f8ca5767d 100644
--- a/test/integration/user_flows_test.rb
+++ b/test/integration/user_flows_test.rb
@@ -10,8 +10,8 @@ class UserFlowsTest < ActionDispatch::IntegrationTest
assert assigns(:questionnaire)
end
- should "be able to login and browse site as an admin" do
- login(FactoryBot.create(:admin))
+ should "be able to login and browse site as a director" do
+ login(FactoryBot.create(:director))
assert_redirected_to new_questionnaires_path
get manage_dashboard_index_path
@@ -24,7 +24,7 @@ class UserFlowsTest < ActionDispatch::IntegrationTest
get manage_questionnaires_path
assert_response :redirect
- login(FactoryBot.create(:admin))
+ login(FactoryBot.create(:director))
assert_redirected_to manage_questionnaires_path
end
diff --git a/test/jobs/admin_weekly_report_job_test.rb b/test/jobs/staff_weekly_report_job_test.rb
similarity index 74%
rename from test/jobs/admin_weekly_report_job_test.rb
rename to test/jobs/staff_weekly_report_job_test.rb
index c8b6007ba..094fd4403 100644
--- a/test/jobs/admin_weekly_report_job_test.rb
+++ b/test/jobs/staff_weekly_report_job_test.rb
@@ -1,11 +1,11 @@
require "test_helper"
-class AdminWeeklyReportJobTest < ActiveJob::TestCase
+class StaffWeeklyReportJobTest < ActiveJob::TestCase
should "queue a mailer per recipient" do
create_list(:user, 3, receive_weekly_report: true)
create_list(:user, 2, receive_weekly_report: false)
assert_difference "enqueued_jobs.size", 3 do
- worker = AdminWeeklyReportJob.new
+ worker = StaffWeeklyReportJob.new
worker.perform
end
end
diff --git a/test/models/questionnaire_test.rb b/test/models/questionnaire_test.rb
index d61fcfd47..c1d0ea6c1 100644
--- a/test/models/questionnaire_test.rb
+++ b/test/models/questionnaire_test.rb
@@ -194,16 +194,16 @@ class QuestionnaireTest < ActiveSupport::TestCase
end
should "return nil if author deleted" do
- user = create(:user, email: "admin@example.com")
+ user = create(:user, email: "director@example.com")
questionnaire = create(:questionnaire, acc_status_author_id: user.id)
user.destroy
assert_nil questionnaire.acc_status_author
end
should "return the questionnaire's user" do
- user = create(:user, email: "admin@example.com")
+ user = create(:user, email: "director@example.com")
questionnaire = create(:questionnaire, acc_status_author_id: user.id)
- assert_equal "admin@example.com", questionnaire.acc_status_author.email
+ assert_equal "director@example.com", questionnaire.acc_status_author.email
end
end
diff --git a/test/models/user_test.rb b/test/models/user_test.rb
index 86e264e0c..2bac1093b 100644
--- a/test/models/user_test.rb
+++ b/test/models/user_test.rb
@@ -64,11 +64,11 @@ class UserTest < ActiveSupport::TestCase
assert_equal 2, User.without_questionnaire.count
end
- should "not return admins" do
+ should "not return staff" do
create(:questionnaire) # user, has questionnaire
- create(:user, role: :event_tracking) # user, does not
- create(:user, role: :admin_limited_access) # admin, does not
- create(:user, role: :admin) # admin, does not
+ create(:user, role: :volunteer) # volunteer, does not
+ create(:user, role: :organizer) # organizer, does not
+ create(:user, role: :director) # director, does not
assert_equal 4, User.count
assert_equal 1, User.without_questionnaire.count
end
@@ -80,6 +80,50 @@ class UserTest < ActiveSupport::TestCase
end
end
+ context "current_user is staff" do
+ should "not report user as staff" do
+ user = create(:user, role: user)
+ assert_equal false, user.staff?
+ end
+
+ should "report volunteer as staff" do
+ user = create(:user, role: :volunteer)
+ assert_equal true, user.staff?
+ end
+
+ should "report organizer as staff" do
+ user = create(:user, role: :organizer)
+ assert_equal true, user.staff?
+ end
+
+ should "report director as staff" do
+ user = create(:user, role: :director)
+ assert_equal true, user.staff?
+ end
+ end
+
+ context "current_user is organizing staff" do
+ should "not report user as organizing staff" do
+ user = create(:user, role: user)
+ assert_equal false, user.organizing_staff?
+ end
+
+ should "not report volunteer as organizing staff" do
+ user = create(:user, role: :volunteer)
+ assert_equal false, user.organizing_staff?
+ end
+
+ should "report organizer as organizing staff" do
+ user = create(:user, role: :organizer)
+ assert_equal true, user.organizing_staff?
+ end
+
+ should "report director as organizing staff" do
+ user = create(:user, role: :director)
+ assert_equal true, user.organizing_staff?
+ end
+ end
+
context "safe_receive_weekly_report" do
should "return false if user is inactive" do
user = build(:user, is_active: true, receive_weekly_report: true)
diff --git a/vendor/cache/puma-4.3.4.gem b/vendor/cache/puma-4.3.4.gem
new file mode 100644
index 000000000..422fc484c
Binary files /dev/null and b/vendor/cache/puma-4.3.4.gem differ