Skip to content

Commit

Permalink
Drop ExaminationsController#show
Browse files Browse the repository at this point in the history
  • Loading branch information
mpugach committed Mar 6, 2023
1 parent b57f32a commit e0a4b25
Show file tree
Hide file tree
Showing 5 changed files with 7 additions and 16 deletions.
10 changes: 3 additions & 7 deletions app/controllers/examinations_controller.rb
@@ -1,12 +1,8 @@
class ExaminationsController < HtmlRespondableController
before_action :set_examination, only: %i[show edit update destroy]
before_action :set_examination, only: %i[edit update destroy]

after_action :verify_authorized

def show
respond_with(@examination)
end

def new
@examination = Examination.new(passing_score: 1, min_result: 0, max_result: 1, course_id: params[:course_id])

Expand All @@ -24,13 +20,13 @@ def create

@examination.save

respond_with(@examination, location: -> { course_examination_path(params[:course_id], @examination.id) })
respond_with(@examination, location: -> { course_path(@examination.course_id) })
end

def update
@examination.update(examination_params)

respond_with(@examination, location: -> { course_examination_path(params[:course_id], @examination.id) })
respond_with(@examination, location: -> { course_path(@examination.course_id) })
end

def destroy
Expand Down
5 changes: 1 addition & 4 deletions app/views/courses/show.html.haml
Expand Up @@ -88,10 +88,7 @@
%tbody
- @examinations.each do |examination|
%tr
%td
= link_to_if policy(examination).show?, examination.title, course_examination_path(examination.course_id, examination) do
= examination.title

%td= examination.title
%td.col-xs-1= examination.min_result
%td.col-xs-1= examination.max_result
%td.col-xs-1= examination.passing_score
Expand Down
2 changes: 0 additions & 2 deletions app/views/examinations/show.html.haml

This file was deleted.

2 changes: 1 addition & 1 deletion config/routes.rb
Expand Up @@ -45,7 +45,7 @@
resource :subscriptions, only: %i[edit update]

resources :courses do
resources :examinations, only: %i[new create edit update show destroy]
resources :examinations, only: %i[new create edit update destroy]
end

resources :programs, only: %i[new create edit update index destroy]
Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/examinations_controller_spec.rb
Expand Up @@ -6,7 +6,7 @@
Given(:nested_route_params) { { course_id: course.id } }

describe 'not signed in' do
it_behaves_like :failed_auth_crud, :not_authenticated, %i[index]
it_behaves_like :failed_auth_crud, :not_authenticated, %i[index show]
end

describe 'signed in' do
Expand All @@ -20,7 +20,7 @@
describe 'as regular user' do
Given(:default_id) { examination.id }

it_behaves_like :failed_auth_crud, :not_authorized, %i[index]
it_behaves_like :failed_auth_crud, :not_authorized, %i[index show]
end

describe 'as admin' do
Expand Down

0 comments on commit e0a4b25

Please sign in to comment.