2012-01-30 20:39:34 +00:00
|
|
|
# -*- encoding : utf-8 -*-
|
2011-12-07 19:51:08 +00:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2012-05-02 10:18:07 +01:00
|
|
|
describe Groups::MembersController do
|
2011-12-09 23:40:13 +00:00
|
|
|
before(:each) do
|
2012-02-20 23:13:05 +00:00
|
|
|
stub_rsync_methods
|
2012-03-29 21:34:22 +01:00
|
|
|
@group = FactoryGirl.create(:group)
|
2011-12-09 23:40:13 +00:00
|
|
|
@user = @group.owner
|
2011-12-14 20:49:33 +00:00
|
|
|
set_session_for @user
|
2012-03-29 21:34:22 +01:00
|
|
|
@another_user = FactoryGirl.create(:user)
|
2012-05-02 10:18:07 +01:00
|
|
|
@add_params = {:group_id => @group, :user_id => @another_user.uname}
|
2011-12-09 23:40:13 +00:00
|
|
|
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
|
2012-05-02 10:18:07 +01:00
|
|
|
response.should redirect_to(group_members_path(@group))
|
2012-04-26 02:38:33 +01:00
|
|
|
Relation.by_target(@group).by_actor(@another_user).count.should eql(1)
|
2011-12-09 23:40:13 +00:00
|
|
|
end
|
|
|
|
|
|
|
|
it 'should add reader member to group' do
|
|
|
|
post :add, @add_params
|
2012-04-26 02:38:33 +01:00
|
|
|
Relation.by_target(@group).by_actor(@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
|