Skip to content
This repository has been archived by the owner on Apr 17, 2023. It is now read-only.

webhook: don't forbid users to see the webhooks on their personal namespace #992

Merged
merged 1 commit into from
Jul 18, 2016
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 2 additions & 3 deletions app/policies/webhook_policy.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,11 +43,10 @@ def resolve
.joins(team: [:team_users])
.where(
"(namespaces.visibility = :public OR namespaces.visibility = :protected OR "\
"team_users.user_id = :user_id) AND " \
"namespaces.global = :global AND namespaces.name != :username",
"team_users.user_id = :user_id) AND namespaces.global = :global",
public: Namespace.visibilities[:visibility_public],
protected: Namespace.visibilities[:visibility_protected], user_id: user.id,
global: false, username: user.username
global: false
)
.pluck(:id)

Expand Down
4 changes: 3 additions & 1 deletion spec/policies/webhook_policy_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -75,8 +75,10 @@
expect(Pundit.policy_scope(viewer, Webhook).to_a).to match_array(expected)
end

it "does not show webhooks to user" do
it "does show webhooks to user when appropiate" do
expect(Pundit.policy_scope(user, Webhook).to_a).to be_empty
create(:webhook, namespace: user.namespace)
expect(Pundit.policy_scope(user, Webhook).to_a).to_not be_empty
end
end
end