2012-10-09 04:14:17 -04:00
|
|
|
# == Schema Information
|
|
|
|
#
|
2014-10-09 11:22:20 -04:00
|
|
|
# Table name: members
|
2012-10-09 04:14:17 -04:00
|
|
|
#
|
2013-04-04 15:11:51 -04:00
|
|
|
# id :integer not null, primary key
|
2014-10-09 11:22:20 -04:00
|
|
|
# access_level :integer not null
|
|
|
|
# source_id :integer not null
|
|
|
|
# source_type :string(255) not null
|
2015-05-03 12:05:38 -04:00
|
|
|
# user_id :integer
|
2014-10-09 11:22:20 -04:00
|
|
|
# notification_level :integer not null
|
|
|
|
# type :string(255)
|
2014-04-09 08:05:03 -04:00
|
|
|
# created_at :datetime
|
|
|
|
# updated_at :datetime
|
2015-05-03 12:05:38 -04:00
|
|
|
# created_by_id :integer
|
|
|
|
# invite_email :string(255)
|
|
|
|
# invite_token :string(255)
|
|
|
|
# invite_accepted_at :datetime
|
2012-10-09 04:14:17 -04:00
|
|
|
#
|
|
|
|
|
2011-10-08 17:36:38 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2015-12-09 04:50:51 -05:00
|
|
|
describe ProjectMember, models: true do
|
2012-10-24 07:52:17 -04:00
|
|
|
describe :import_team do
|
|
|
|
before do
|
|
|
|
@abilities = Six.new
|
|
|
|
@abilities << Ability
|
|
|
|
|
|
|
|
@project_1 = create :project
|
|
|
|
@project_2 = create :project
|
|
|
|
|
|
|
|
@user_1 = create :user
|
|
|
|
@user_2 = create :user
|
|
|
|
|
2013-01-04 01:43:25 -05:00
|
|
|
@project_1.team << [ @user_1, :developer ]
|
|
|
|
@project_2.team << [ @user_2, :reporter ]
|
2012-10-24 07:52:17 -04:00
|
|
|
|
2013-01-04 01:43:25 -05:00
|
|
|
@status = @project_2.team.import(@project_1)
|
2012-10-24 07:52:17 -04:00
|
|
|
end
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { expect(@status).to be_truthy }
|
2012-10-24 07:52:17 -04:00
|
|
|
|
|
|
|
describe 'project 2 should get user 1 as developer. user_2 should not be changed' do
|
2015-02-12 13:17:35 -05:00
|
|
|
it { expect(@project_2.users).to include(@user_1) }
|
|
|
|
it { expect(@project_2.users).to include(@user_2) }
|
2012-10-24 07:52:17 -04:00
|
|
|
|
2015-06-26 09:55:56 -04:00
|
|
|
it { expect(@abilities.allowed?(@user_1, :create_project, @project_2)).to be_truthy }
|
2015-02-12 13:17:35 -05:00
|
|
|
it { expect(@abilities.allowed?(@user_2, :read_project, @project_2)).to be_truthy }
|
2012-10-24 07:52:17 -04:00
|
|
|
end
|
|
|
|
|
|
|
|
describe 'project 1 should not be changed' do
|
2015-02-12 13:17:35 -05:00
|
|
|
it { expect(@project_1.users).to include(@user_1) }
|
|
|
|
it { expect(@project_1.users).not_to include(@user_2) }
|
2012-10-24 07:52:17 -04:00
|
|
|
end
|
|
|
|
end
|
2013-01-03 12:11:14 -05:00
|
|
|
|
|
|
|
describe :add_users_into_projects do
|
|
|
|
before do
|
|
|
|
@project_1 = create :project
|
|
|
|
@project_2 = create :project
|
|
|
|
|
|
|
|
@user_1 = create :user
|
|
|
|
@user_2 = create :user
|
|
|
|
|
2014-09-14 12:32:51 -04:00
|
|
|
ProjectMember.add_users_into_projects(
|
2013-01-03 12:11:14 -05:00
|
|
|
[@project_1.id, @project_2.id],
|
|
|
|
[@user_1.id, @user_2.id],
|
2014-09-14 12:32:51 -04:00
|
|
|
ProjectMember::MASTER
|
2013-01-03 12:11:14 -05:00
|
|
|
)
|
|
|
|
end
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { expect(@project_1.users).to include(@user_1) }
|
|
|
|
it { expect(@project_1.users).to include(@user_2) }
|
2013-01-03 12:11:14 -05:00
|
|
|
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { expect(@project_2.users).to include(@user_1) }
|
|
|
|
it { expect(@project_2.users).to include(@user_2) }
|
2013-01-03 12:11:14 -05:00
|
|
|
end
|
|
|
|
|
|
|
|
describe :truncate_teams do
|
|
|
|
before do
|
|
|
|
@project_1 = create :project
|
|
|
|
@project_2 = create :project
|
|
|
|
|
|
|
|
@user_1 = create :user
|
|
|
|
@user_2 = create :user
|
|
|
|
|
2013-01-04 01:43:25 -05:00
|
|
|
@project_1.team << [ @user_1, :developer]
|
|
|
|
@project_2.team << [ @user_2, :reporter]
|
2013-01-03 12:11:14 -05:00
|
|
|
|
2014-09-14 12:32:51 -04:00
|
|
|
ProjectMember.truncate_teams([@project_1.id, @project_2.id])
|
2013-01-03 12:11:14 -05:00
|
|
|
end
|
|
|
|
|
2015-02-12 13:17:35 -05:00
|
|
|
it { expect(@project_1.users).to be_empty }
|
|
|
|
it { expect(@project_2.users).to be_empty }
|
2013-01-03 12:11:14 -05:00
|
|
|
end
|
2011-10-08 17:36:38 -04:00
|
|
|
end
|