From 2b26e07e953159facd4c6fd95406b51f78ff85e3 Mon Sep 17 00:00:00 2001 From: Vokhmin Alexey V Date: Fri, 3 Apr 2015 00:35:15 +0300 Subject: [PATCH] #465: Update specs for Platforms::ContentsController --- .../platforms/contents_controller.rb | 4 +--- .../platforms/contents_controller_spec.rb | 20 +++++++++---------- 2 files changed, 11 insertions(+), 13 deletions(-) diff --git a/app/controllers/platforms/contents_controller.rb b/app/controllers/platforms/contents_controller.rb index ee4a8e796..904f005dc 100644 --- a/app/controllers/platforms/contents_controller.rb +++ b/app/controllers/platforms/contents_controller.rb @@ -4,8 +4,6 @@ class Platforms::ContentsController < Platforms::BaseController before_action :authenticate_user! skip_before_action :authenticate_user!, only: :index if APP_CONFIG['anonymous_access'] - load_and_authorize_resource :platform - def index respond_to do |format| format.html @@ -22,7 +20,7 @@ class Platforms::ContentsController < Platforms::BaseController end def remove_file - authorize!(:remove_file, @platform) + authorize @platform PlatformContent.remove_file(@platform, params[:path]) render nothing: true end diff --git a/spec/controllers/platforms/contents_controller_spec.rb b/spec/controllers/platforms/contents_controller_spec.rb index ae5949fc3..09fe5361d 100644 --- a/spec/controllers/platforms/contents_controller_spec.rb +++ b/spec/controllers/platforms/contents_controller_spec.rb @@ -4,7 +4,7 @@ shared_examples_for 'content platform user without show rights for hidden platfo it 'should not be able to perform index action' do @platform.update_column(:visibility, 'hidden') get :index, platform_id: @platform - response.should_not be_success + expect(response).to_not be_success end end @@ -12,31 +12,31 @@ shared_examples_for 'content platform user with show rights for hidden platform' it 'should be able to perform index action' do @platform.update_column(:visibility, 'hidden') get :index, platform_id: @platform - response.should be_success + expect(response).to be_success end end shared_examples_for 'content platform user with show rights' do it 'should be able to perform index action for main platform' do get :index, platform_id: @platform - response.should be_success + expect(response).to be_success end it 'should be able to perform index action for personal platform' do get :index, platform_id: @personal_platform - response.should be_success + expect(response).to be_success end end shared_examples_for 'content platform user without member rights' do it 'should not be able to perform remove_file action for main platform' do get :remove_file, platform_id: @platform, path: '/test' - response.should_not be_success + expect(response).to_not be_success end it 'should not be able to perform index remove_file for personal platform' do get :remove_file, platform_id: @personal_platform, path: '/test' - response.should_not be_success + expect(response).to_not be_success end end @@ -47,12 +47,12 @@ shared_examples_for 'content platform user with member rights' do it 'should be able to perform remove_file action for main platform' do get :remove_file, platform_id: @platform, path: '/test' - response.should be_success + expect(response).to be_success end it 'should be able to perform remove_file action for personal platform' do get :remove_file, platform_id: @personal_platform, path: '/test' - response.should be_success + expect(response).to be_success end end @@ -70,12 +70,12 @@ describe Platforms::ContentsController, type: :controller do it 'should not be able to perform index action for main platform', anonymous_access: false do get :index, platform_id: @platform - response.should_not be_success + expect(response).to_not be_success end it 'should not be able to perform index action for personal platform', anonymous_access: false do get :index, platform_id: @personal_platform - response.should_not be_success + expect(response).to_not be_success end it_should_behave_like 'content platform user with show rights' if APP_CONFIG['anonymous_access']