Permalink
Browse files

Don't use the admin role for determining auto-subscribe eligibility, …

…since it gets tiresome and probably looks weird in private threads.
  • Loading branch information...
1 parent 35f3f73 commit 480596a79698e2b14a971e1808d233d5a70df23a @gravitystorm gravitystorm committed May 24, 2012
Showing with 19 additions and 5 deletions.
  1. +2 −2 app/controllers/message_threads_controller.rb
  2. +17 −3 spec/requests/groups/threads_spec.rb
@@ -70,7 +70,7 @@ def subscribe_group_users(thread)
constraint = thread.issue ? pref : pref.and(t[:involve_my_groups_admin].eq(true))
members = thread.group.members.active.joins(:prefs).where(constraint)
members.each do |member|
- if Authorization::Engine.instance.permit? :show, { object: thread, user: member }
+ if Authorization::Engine.instance.permit? :show, { object: thread, user: member, user_roles: [:member, :guest] }
thread.subscriptions.create(user: member) unless member.subscribed_to_thread?(thread)
end
end
@@ -85,7 +85,7 @@ def subscribe_issue_users(thread)
all
locations.each do |loc|
- if Authorization::Engine.instance.permit? :show, { object: thread, user: loc.user }
+ if Authorization::Engine.instance.permit? :show, { object: thread, user: loc.user, user_roles: [:member, :guest] }
thread.subscriptions.create(user: loc.user) unless loc.user.subscribed_to_thread?(thread)
end
end
@@ -182,10 +182,10 @@ def enable_group_thread_prefs_for(u)
let(:issue) { FactoryGirl.create(:issue) }
let(:stranger) { FactoryGirl.create(:user) }
let!(:stranger_location) { FactoryGirl.create(:user_location, user: stranger, location: issue.location.buffer(1)) }
+ let(:stewie) { FactoryGirl.create(:stewie) }
+ let!(:stewie_location) { FactoryGirl.create(:user_location, user: stewie, location: issue.location.buffer(1)) }
- it "should not autosubscribe non-members with overlapping areas" do
- stranger.prefs.update_attribute(:involve_my_locations, "subscribe")
-
+ def create_private_group_thread
visit issue_path(issue)
click_on "Discuss"
fill_in "Title", with: "Private thread"
@@ -194,8 +194,22 @@ def enable_group_thread_prefs_for(u)
click_on "Create Thread"
current_group.threads.last.privacy.should eql("group")
+ end
+
+ it "should not autosubscribe non-members with overlapping areas" do
+ stranger.prefs.update_attribute(:involve_my_locations, "subscribe")
+ create_private_group_thread
+
stranger.subscribed_to_thread?(current_group.threads.last).should be_false
end
+
+ it "should not autosubscribe administrators with overlapping areas" do
+ # because it gets annoying fast, trust me.
+ stewie.prefs.update_attribute(:involve_my_locations, "subscribe")
+ create_private_group_thread
+
+ stewie.subscribed_to_thread?(current_group.threads.last).should be_false
+ end
end
end
end

0 comments on commit 480596a

Please sign in to comment.