2011-12-07 19:51:08 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
|
|
|
describe MembersController do
|
2011-12-09 23:40:13 +00:00
|
|
|
before(:each) do
|
|
|
|
@group = Factory(:group)
|
|
|
|
@user = @group.owner
|
2011-12-14 20:49:33 +00:00
|
|
|
set_session_for @user
|
2011-12-09 23:40:13 +00:00
|
|
|
@another_user = Factory(:user)
|
|
|
|
@add_params = {:group_id => @group.id, :user_id => @another_user.uname}
|
|
|
|
end
|
2011-12-07 19:51:08 +00:00
|
|
|
|
2011-12-09 23:40:13 +00:00
|
|
|
context 'for owner user' do
|
|
|
|
it 'should add member to group' do
|
|
|
|
post :add, @add_params
|
2011-12-14 20:49:33 +00:00
|
|
|
response.should redirect_to(edit_group_members_path(@group))
|
2011-12-09 23:40:13 +00:00
|
|
|
Relation.by_target(@group).by_object(@another_user).count.should eql(1)
|
|
|
|
end
|
|
|
|
|
|
|
|
it 'should add reader member to group' do
|
|
|
|
post :add, @add_params
|
2011-12-14 20:49:33 +00:00
|
|
|
Relation.by_target(@group).by_object(@another_user).first.role.should eql('reader')
|
2011-12-09 23:40:13 +00:00
|
|
|
end
|
|
|
|
end
|
2011-12-07 19:51:08 +00:00
|
|
|
end
|