Skip to content

Commit

Permalink
fix permissions for domains attribute. #687
Browse files Browse the repository at this point in the history
  • Loading branch information
Martin Fenner committed Dec 15, 2020
1 parent 4b4d81c commit b1f72db
Show file tree
Hide file tree
Showing 3 changed files with 27 additions and 2 deletions.
13 changes: 13 additions & 0 deletions app/serializers/client_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,19 @@ class ClientSerializer
object.password.present?
end

attribute :domains,
if:
Proc.new { |object, params|
params[:current_ability] &&
params[:current_ability].can?(
:read_contact_information,
object,
) ==
true
} do |object|
object.domains
end

attribute :contact_email,
if:
Proc.new { |object, params|
Expand Down
13 changes: 13 additions & 0 deletions app/serializers/repository_serializer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,19 @@ class RepositorySerializer
object.is_active.getbyte(0) == 1
end

attribute :domains,
if:
Proc.new { |object, params|
params[:current_ability] &&
params[:current_ability].can?(
:read_contact_information,
object,
) ==
true
} do |object|
object.domains
end

attribute :has_password,
if:
Proc.new { |object, params|
Expand Down
3 changes: 1 addition & 2 deletions spec/requests/clients_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -297,7 +297,7 @@

before do
ProviderPrefix.import
sleep 2
sleep 3
end

it "updates the record" do
Expand Down Expand Up @@ -332,7 +332,6 @@
).to eq(client.symbol.downcase)

get "provider-prefixes?query=#{prefix.uid}"
puts json
expect(
json.dig("meta", "total"),
).to eq(1)
Expand Down

0 comments on commit b1f72db

Please sign in to comment.