Skip to content
This repository has been archived by the owner on Jan 4, 2021. It is now read-only.

Merge can can right #12

Merged
merged 4 commits into from
Apr 12, 2018
Merged

Merge can can right #12

merged 4 commits into from
Apr 12, 2018

Conversation

mnoack
Copy link
Contributor

@mnoack mnoack commented Apr 10, 2018

NOTE - This is ontop of another PR - With this PR there should be no need to depend both on this gem and cancanright gem. Unfortunately when cancanright was created it was created with inter-dependency.

 * Now all dependencies exist in one place
   (Much better than intermingled dependencies)

context 'when the subject is a model' do
let(:right) {
double(name: 'Do Something', can: true, action: 'action', subject: 'Model', conditions: {})

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [99/80]

end

context 'when the subject is a model' do
let(:right) {

Choose a reason for hiding this comment

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

Style/BlockDelimiters: Avoid using {...} for multi-line blocks.


context 'when the subject is not a model' do
let(:right) {
double(name: 'Do Something', can: true, action: 'action', subject: 'subject', conditions: {})

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [101/80]

end

context 'when the subject is not a model' do
let(:right) {

Choose a reason for hiding this comment

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

Style/BlockDelimiters: Avoid using {...} for multi-line blocks.

}

it 'should fail with exception' do
expect{rule}.to raise_error(RightOn::Error, 'must specify an action')

Choose a reason for hiding this comment

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

Layout/SpaceBeforeBlockBraces: Space missing to the left of {.
Layout/SpaceInsideBlockBraces: Space missing inside {.
Layout/SpaceInsideBlockBraces: Space missing inside }.

@@ -0,0 +1,81 @@
require 'active_record'

Choose a reason for hiding this comment

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

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.


context 'edit action' do
specify do
expect(edit_action.allowed?(other)).to eq false # as specific action exists

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [83/80]


context 'index action' do
specify do
expect(index_action.allowed?(other)).to eq false # as specific action exists

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [84/80]

let(:other) { double(id: 2, name: 'models', controller: 'models', action: nil) }
let(:index) { double(id: 3, name: 'models#index', controller: 'models', action: 'index') }
let(:change) { double(id: 4, name: 'models#change', controller: 'models', action: 'change') }
let(:view) { double(id: 5, name: 'models#view', controller: 'models', action: 'view') }

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [97/80]


let(:other) { double(id: 2, name: 'models', controller: 'models', action: nil) }
let(:index) { double(id: 3, name: 'models#index', controller: 'models', action: 'index') }
let(:change) { double(id: 4, name: 'models#change', controller: 'models', action: 'change') }

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [97/80]

@coveralls
Copy link

coveralls commented Apr 10, 2018

Coverage Status

Coverage increased (+1.1%) to 92.398% when pulling 91f0c01 on merge_can_can_right into 20c811c on master.

end
end

context 'for complex rights' do

Choose a reason for hiding this comment

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

Metrics/BlockLength: Block has too many lines. [32/25]

require 'spec_helper'
require 'support/bootstrap'

describe RightOn::RightAllowed do

Choose a reason for hiding this comment

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

Metrics/BlockLength: Block has too many lines. [61/25]

@@ -0,0 +1,89 @@
require 'active_record'

Choose a reason for hiding this comment

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

Style/FrozenStringLiteralComment: Missing magic comment # frozen_string_literal: true.

let(:allowed) {
double(name: 'create_user', allowed?: true, roles: [double(title: 'Users')])
}
let(:create_user_right) { double(name: 'create_user', allowed?: true, roles: [double(title: 'Users')]) }

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [106/80]

context 'when rights from is a symbol' do
specify do
expect{controller.send(:authorize_action!)}.to(
raise_error(CanCan::AccessDenied, 'You are not authorized to access this page.'))

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [91/80]
Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.


context 'when rights from is a symbol' do
specify do
expect{controller.send(:authorize_action!)}.to(

Choose a reason for hiding this comment

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

Layout/SpaceBeforeBlockBraces: Space missing to the left of {.
Layout/SpaceInsideBlockBraces: Space missing inside {.
Layout/SpaceInsideBlockBraces: Space missing inside }.

end

describe 'private #authorize_action!' do
let(:controller) {

Choose a reason for hiding this comment

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

Style/BlockDelimiters: Avoid using {...} for multi-line blocks.


it 'should not grant access to controller#action' do
expect{controller.send(:authorize_action!)}.to(
raise_error(CanCan::AccessDenied, 'You are not authorized to access this page.'))

Choose a reason for hiding this comment

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

Metrics/LineLength: Line is too long. [91/80]
Layout/MultilineMethodCallBraceLayout: Closing method call brace must be on the line after the last argument when opening brace is on a separate line from the first argument.

@alvinypyim alvinypyim merged commit ca54b0a into master Apr 12, 2018
@alvinypyim alvinypyim deleted the merge_can_can_right branch April 12, 2018 01:28
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants