diff options
author | Stan Hu <stanhu@gmail.com> | 2016-08-20 06:33:53 -0700 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2016-08-20 06:53:14 -0700 |
commit | 1954bb17eca49d375c92a4b8fa7f52fa39873a7d (patch) | |
tree | c5ccf8bd6806f024db38299400517ef056b2be7b | |
parent | be95e03a5633696d79260ae61bb9e8f4c6755855 (diff) | |
download | gitlab-ce-1954bb17eca49d375c92a4b8fa7f52fa39873a7d.tar.gz |
Make Ability#project_abilities return unique values and fix countsfix-rspec-failures-due-to-cached-permissions
-rw-r--r-- | app/models/ability.rb | 2 | ||||
-rw-r--r-- | spec/models/ability_spec.rb | 19 |
2 files changed, 11 insertions, 10 deletions
diff --git a/app/models/ability.rb b/app/models/ability.rb index b82632ccc0b..a49dd703926 100644 --- a/app/models/ability.rb +++ b/app/models/ability.rb @@ -203,7 +203,7 @@ class Ability rules -= project_archived_rules end - rules - project_disabled_features_rules(project) + (rules - project_disabled_features_rules(project)).uniq end def project_team_rules(team, user) diff --git a/spec/models/ability_spec.rb b/spec/models/ability_spec.rb index fe32d367176..aa3b2bbf471 100644 --- a/spec/models/ability_spec.rb +++ b/spec/models/ability_spec.rb @@ -191,21 +191,22 @@ describe Ability, lib: true do admin = create(:admin) results = described_class.project_abilities(admin, project) - expect(results.count).to eq(90) + + expect(results.count).to eq(68) end it 'returns permissions for an owner' do results = described_class.project_abilities(project.owner, project) - expect(results.count).to eq(90) + expect(results.count).to eq(68) end - it 'returns permissions for a guest' do - project.team << [user, :guest] + it 'returns permissions for a master' do + project.team << [user, :master] results = described_class.project_abilities(user, project) - expect(results.count).to eq(22) + expect(results.count).to eq(60) end it 'returns permissions for a developer' do @@ -213,15 +214,15 @@ describe Ability, lib: true do results = described_class.project_abilities(user, project) - expect(results.count).to eq(22) + expect(results.count).to eq(44) end - it 'returns permissions for a master' do - project.team << [user, :master] + it 'returns permissions for a guest' do + project.team << [user, :guest] results = described_class.project_abilities(user, project) - expect(results.count).to eq(22) + expect(results.count).to eq(21) end end end |