Skip to content

Commit 233be29

Browse files
committed
small refactor for non student abilities
1 parent 53a8a39 commit 233be29

2 files changed

Lines changed: 3 additions & 6 deletions

File tree

app/models/ability.rb

Lines changed: 2 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ class Ability
44
include CanCan::Ability
55

66
def initialize(user)
7-
define_common_non_student_abilities(user)
7+
define_common_abilities
88

99
return unless user
1010

@@ -21,10 +21,7 @@ def initialize(user)
2121

2222
private
2323

24-
def define_common_non_student_abilities(user)
25-
can :show, Project, user_id: nil, school_id: nil, project_type: Project::Types::CODE_EDITOR_SCRATCH
26-
return if user&.student?
27-
24+
def define_common_abilities
2825
# Anyone can view projects not owned by a user or a school.
2926
can :show, Project, user_id: nil, school_id: nil
3027
can :show, Component, project: { user_id: nil, school_id: nil }

spec/models/ability_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -492,7 +492,7 @@
492492

493493
context 'with a starter project' do
494494
it { is_expected.not_to be_able_to(:index, starter_project) }
495-
it { is_expected.not_to be_able_to(:show, starter_project) }
495+
it { is_expected.to be_able_to(:show, starter_project) }
496496
it { is_expected.not_to be_able_to(:create, starter_project) }
497497
it { is_expected.not_to be_able_to(:update, starter_project) }
498498
it { is_expected.not_to be_able_to(:destroy, starter_project) }

0 commit comments

Comments
 (0)