group manager can invite members into the group from any restricted topic

This commit is contained in:
Jason W. May
2015-03-02 11:25:25 -08:00
parent 35c58c1b00
commit 0f36774246
8 changed files with 132 additions and 7 deletions

View File

@@ -1,4 +1,4 @@
# encoding: UTF-8
# encoding: utf-8
require 'spec_helper'
require_dependency 'post_destroyer'
@@ -1352,4 +1352,37 @@ describe Topic do
topic.last_posted_at = 1.minute.ago
expect(topic.save).to eq(true)
end
context 'invite by group manager' do
let(:group_manager) { Fabricate(:user) }
let(:group) { Fabricate(:group).tap { |g| g.add(group_manager); g.appoint_manager(group_manager) } }
let(:private_category) { Fabricate(:private_category, group: group) }
let(:group_private_topic) { Fabricate(:topic, category: private_category, user: group_manager) }
context 'to an email' do
let(:randolph) { 'randolph@duke.ooo' }
it "should attach group to the invite" do
invite = group_private_topic.invite(group_manager, randolph)
expect(invite.groups).to eq([group])
end
end
# should work for an existing user - give access, send notification
context 'to an existing user' do
let(:walter) { Fabricate(:walter_white) }
it "should add user to the group" do
expect(Guardian.new(walter).can_see?(group_private_topic)).to be_falsey
invite = group_private_topic.invite(group_manager, walter.email)
expect(invite).to be_nil
expect(walter.groups).to include(group)
expect(Guardian.new(walter).can_see?(group_private_topic)).to be_truthy
end
end
context 'to a previously-invited user' do
end
end
end