Skip to content

Commit

Permalink
Merge pull request #3999 from evanrolfe/fix/subscriptions_for_users_i…
Browse files Browse the repository at this point in the history
…n_groups

[webui] Fix emails for users in groups with emails disabled.
  • Loading branch information
Evan Rolfe committed Oct 12, 2017
2 parents a50b4ed + 1f8745a commit a63a93f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/api/app/models/event_subscription/find_for_event.rb
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@ def filter_and_convert_groups_without_emails_to_users(receivers)
if receiver.email.present?
new_receivers << receiver
else
new_receivers += receiver.users
new_receivers += receiver.email_users
end
end
end
Expand Down
20 changes: 17 additions & 3 deletions src/api/spec/models/event_subscription/find_for_event_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -156,10 +156,24 @@
context 'which is enabled' do
let!(:subscription) { create(:event_subscription_comment_for_project_without_subscriber, receiver_role: 'maintainer', subscriber: user) }

it 'returns the subscription for that user/group' do
subscriber_result = subject.find { |subscription| subscription.subscriber == user }
context 'and the user has emails enabled for the group' do
it 'returns the subscription for that user/group' do
subscriber_result = subject.find { |subscription| subscription.subscriber == user }

expect(subscriber_result).to eq(subscription)
expect(subscriber_result).to eq(subscription)
end
end

context 'and the user has emails disabled for the group' do
before do
groups_user = GroupsUser.find_by(user: user, group: group)
groups_user.email = false
groups_user.save
end

it 'does not include that user' do
expect(subject.map(&:subscriber)).not_to include(user)
end
end
end

Expand Down

0 comments on commit a63a93f

Please sign in to comment.