Commit 1954bb17 authored by Stan Hu's avatar Stan Hu

Make Ability#project_abilities return unique values and fix counts

parent be95e03a
...@@ -203,7 +203,7 @@ class Ability ...@@ -203,7 +203,7 @@ class Ability
rules -= project_archived_rules rules -= project_archived_rules
end end
rules - project_disabled_features_rules(project) (rules - project_disabled_features_rules(project)).uniq
end end
def project_team_rules(team, user) def project_team_rules(team, user)
......
...@@ -191,21 +191,22 @@ describe Ability, lib: true do ...@@ -191,21 +191,22 @@ describe Ability, lib: true do
admin = create(:admin) admin = create(:admin)
results = described_class.project_abilities(admin, project) results = described_class.project_abilities(admin, project)
expect(results.count).to eq(90)
expect(results.count).to eq(68)
end end
it 'returns permissions for an owner' do it 'returns permissions for an owner' do
results = described_class.project_abilities(project.owner, project) results = described_class.project_abilities(project.owner, project)
expect(results.count).to eq(90) expect(results.count).to eq(68)
end end
it 'returns permissions for a guest' do it 'returns permissions for a master' do
project.team << [user, :guest] project.team << [user, :master]
results = described_class.project_abilities(user, project) results = described_class.project_abilities(user, project)
expect(results.count).to eq(22) expect(results.count).to eq(60)
end end
it 'returns permissions for a developer' do it 'returns permissions for a developer' do
...@@ -213,15 +214,15 @@ describe Ability, lib: true do ...@@ -213,15 +214,15 @@ describe Ability, lib: true do
results = described_class.project_abilities(user, project) results = described_class.project_abilities(user, project)
expect(results.count).to eq(22) expect(results.count).to eq(44)
end end
it 'returns permissions for a master' do it 'returns permissions for a guest' do
project.team << [user, :master] project.team << [user, :guest]
results = described_class.project_abilities(user, project) results = described_class.project_abilities(user, project)
expect(results.count).to eq(22) expect(results.count).to eq(21)
end end
end end
end end
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment