Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add simple auth to all admin-only controllers #837

Merged
merged 1 commit into from
Jan 26, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 1 addition & 3 deletions app/controllers/categories_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class CategoriesController < ApplicationController
include NotUsingPunditYet

class CategoriesController < AdminController
before_action :set_category, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/communication_logs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class CommunicationLogsController < ApplicationController
include NotUsingPunditYet

class CommunicationLogsController < AdminController
before_action :set_communication_log, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/custom_form_questions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class CustomFormQuestionsController < ApplicationController
include NotUsingPunditYet

class CustomFormQuestionsController < AdminController
before_action :set_custom_form_question, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/donations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class DonationsController < ApplicationController
include NotUsingPunditYet

class DonationsController < AdminController
before_action :authenticate_user!, except: %i[new create]
before_action :set_donation, only: %i[show edit update destroy]

Expand Down
6 changes: 3 additions & 3 deletions app/controllers/feedbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,8 @@
# frozen_string_literal: true

class FeedbacksController < ApplicationController
include NotUsingPunditYet

# FIXME: Will need to become a mixed-access controller when we add functionality for
# neigbhors to create feedback. Maybe also consider renaming (MatchFeedback)?
class FeedbacksController < AdminController
before_action :set_feedback, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/form_questions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class FormQuestionsController < ApplicationController
include NotUsingPunditYet

class FormQuestionsController < AdminController
before_action :set_form_question, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/forms_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class FormsController < ApplicationController
include NotUsingPunditYet

class FormsController < AdminController
before_action :set_form, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/history_logs_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class HistoryLogsController < ApplicationController
include NotUsingPunditYet

class HistoryLogsController < AdminController
def index
@history_logs = HistoryLog.all
end
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/listings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class ListingsController < ApplicationController
include NotUsingPunditYet

class ListingsController < AdminController
before_action :set_listing, only: %i[show edit update destroy match match_confirm]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/location_types_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class LocationTypesController < ApplicationController
include NotUsingPunditYet

class LocationTypesController < AdminController
before_action :set_location_type, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/locations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class LocationsController < ApplicationController
include NotUsingPunditYet

class LocationsController < AdminController
before_action :set_location, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/matches_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class MatchesController < ApplicationController
include NotUsingPunditYet

class MatchesController < AdminController
before_action :set_match, only: %i[edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/mobility_string_translations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class MobilityStringTranslationsController < ApplicationController
include NotUsingPunditYet

class MobilityStringTranslationsController < AdminController
before_action :set_mobility_string_translation, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/organizations_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class OrganizationsController < ApplicationController
include NotUsingPunditYet

class OrganizationsController < AdminController
before_action :set_organization, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/positions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class PositionsController < ApplicationController
include NotUsingPunditYet

class PositionsController < AdminController
before_action :set_position, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/service_areas_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class ServiceAreasController < ApplicationController
include NotUsingPunditYet

class ServiceAreasController < AdminController
before_action :set_service_area, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/shared_accounts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class SharedAccountsController < ApplicationController
include NotUsingPunditYet

class SharedAccountsController < AdminController
before_action :set_shared_account, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/shift_matches_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class ShiftMatchesController < ApplicationController
include NotUsingPunditYet

class ShiftMatchesController < AdminController
before_action :set_shift_match, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/shifts_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class ShiftsController < ApplicationController
include NotUsingPunditYet

class ShiftsController < AdminController
before_action :set_shift, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/software_feedbacks_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class SoftwareFeedbacksController < ApplicationController
include NotUsingPunditYet

class SoftwareFeedbacksController < AdminController
before_action :set_software_feedback, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/submission_response_imports_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class SubmissionResponseImportsController < ApplicationController
include NotUsingPunditYet

class SubmissionResponseImportsController < AdminController
def new; end

def create
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/submission_responses_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class SubmissionResponsesController < ApplicationController
include NotUsingPunditYet

class SubmissionResponsesController < AdminController
before_action :set_submission_response, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/submissions_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class SubmissionsController < ApplicationController
include NotUsingPunditYet

class SubmissionsController < AdminController
before_action :set_submission, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/system_locales_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class SystemLocalesController < ApplicationController
include NotUsingPunditYet

class SystemLocalesController < AdminController
before_action :set_system_locale, only: %i[show edit update destroy]

def index
Expand Down
4 changes: 1 addition & 3 deletions app/controllers/system_settings_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class SystemSettingsController < ApplicationController
include NotUsingPunditYet

class SystemSettingsController < AdminController
before_action :set_system_setting, only: %i[show edit update destroy]
before_action :set_primary_organization, only: %i[show edit update destroy]

Expand Down
4 changes: 1 addition & 3 deletions app/controllers/teams_controller.rb
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
# frozen_string_literal: true

class TeamsController < ApplicationController
include NotUsingPunditYet

class TeamsController < AdminController
before_action :set_team, only: %i[show edit update destroy]

def index
Expand Down
2 changes: 1 addition & 1 deletion app/models/listing.rb
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ def status
elsif matches_as_provider.any?
status = matches_as_provider.map{|m| m.completed?}.any? ? 'completed' : 'matched'
end
update_attributes(state: status)
update(state: status)
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Gets rid of an annoying deprecation warning :)

status
end

Expand Down
2 changes: 1 addition & 1 deletion spec/requests/listings_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@
location_attributes: { zip: '12e45' },
}}

before { sign_in create(:user) }
before { sign_in create(:user, :admin) }
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe ListingController is only currently used by admins?


describe 'GET /index' do
it 'renders a successful response' do
Expand Down