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
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)
......
......@@ -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
......
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