diff options
author | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-14 20:32:51 +0400 |
---|---|---|
committer | Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com> | 2014-09-14 20:32:51 +0400 |
commit | c69b8e04591907d030b2cd544a606fd0e576116a (patch) | |
tree | 317db4259219bc7f3a3ff6e3c38c802a8d086d2c /spec/models | |
parent | eb4a9bfbca5427e6b9a8fcf2ed0b1f9f96ae099d (diff) |
Huge replace of old users_project and users_group references
Signed-off-by: Dmitriy Zaporozhets <dmitriy.zaporozhets@gmail.com>
Diffstat (limited to 'spec/models')
-rw-r--r-- | spec/models/group_member_spec.rb (renamed from spec/models/users_group_spec.rb) | 29 | ||||
-rw-r--r-- | spec/models/group_spec.rb | 16 | ||||
-rw-r--r-- | spec/models/members_spec.rb | 5 | ||||
-rw-r--r-- | spec/models/note_spec.rb | 14 | ||||
-rw-r--r-- | spec/models/project_member_spec.rb (renamed from spec/models/users_project_spec.rb) | 31 | ||||
-rw-r--r-- | spec/models/project_security_spec.rb | 16 | ||||
-rw-r--r-- | spec/models/system_hook_spec.rb | 2 | ||||
-rw-r--r-- | spec/models/user_spec.rb | 2 |
8 files changed, 37 insertions, 78 deletions
diff --git a/spec/models/users_group_spec.rb b/spec/models/group_member_spec.rb index 0b6f7a08198..9eb4859ebd5 100644 --- a/spec/models/users_group_spec.rb +++ b/spec/models/group_member_spec.rb @@ -13,30 +13,7 @@ require 'spec_helper' -describe UsersGroup do - describe "Associations" do - it { should belong_to(:group) } - it { should belong_to(:user) } - end - - describe "Mass assignment" do - end - - describe "Validation" do - let!(:users_group) { create(:users_group) } - - it { should validate_presence_of(:user_id) } - it { should validate_uniqueness_of(:user_id).scoped_to(:group_id).with_message(/already exists/) } - - it { should validate_presence_of(:group_id) } - it { should ensure_inclusion_of(:group_access).in_array(UsersGroup.group_access_roles.values) } - end - - describe "Delegate methods" do - it { should respond_to(:user_name) } - it { should respond_to(:user_email) } - end - +describe GroupMember do context 'notification' do describe "#after_create" do it "should send email to user" do @@ -55,12 +32,12 @@ describe UsersGroup do it "should send email to user" do @membership.should_receive(:notification_service) - @membership.update_attribute(:group_access, UsersGroup::MASTER) + @membership.update_attribute(:group_access, GroupMember::MASTER) end it "does not send an email when the access level has not changed" do @membership.should_not_receive(:notification_service) - @membership.update_attribute(:group_access, UsersGroup::OWNER) + @membership.update_attribute(:group_access, GroupMember::OWNER) end end end diff --git a/spec/models/group_spec.rb b/spec/models/group_spec.rb index 8259ed88d83..006a8402d00 100644 --- a/spec/models/group_spec.rb +++ b/spec/models/group_spec.rb @@ -39,26 +39,26 @@ describe Group do describe :add_users do let(:user) { create(:user) } - before { group.add_user(user, UsersGroup::MASTER) } + before { group.add_user(user, GroupMember::MASTER) } - it { group.users_groups.masters.map(&:user).should include(user) } + it { group.group_members.masters.map(&:user).should include(user) } end describe :add_users do let(:user) { create(:user) } - before { group.add_users([user.id], UsersGroup::GUEST) } + before { group.add_users([user.id], GroupMember::GUEST) } it "should update the group permission" do - group.users_groups.guests.map(&:user).should include(user) - group.add_users([user.id], UsersGroup::DEVELOPER) - group.users_groups.developers.map(&:user).should include(user) - group.users_groups.guests.map(&:user).should_not include(user) + group.group_members.guests.map(&:user).should include(user) + group.add_users([user.id], GroupMember::DEVELOPER) + group.group_members.developers.map(&:user).should include(user) + group.group_members.guests.map(&:user).should_not include(user) end end describe :avatar_type do let(:user) { create(:user) } - before { group.add_user(user, UsersGroup::MASTER) } + before { group.add_user(user, GroupMember::MASTER) } it "should be true if avatar is image" do group.update_attribute(:avatar, 'uploads/avatar.png') diff --git a/spec/models/members_spec.rb b/spec/models/members_spec.rb index 33e97686654..6866c4794c2 100644 --- a/spec/models/members_spec.rb +++ b/spec/models/members_spec.rb @@ -12,4 +12,9 @@ describe Member do it { should validate_presence_of(:source) } it { should ensure_inclusion_of(:access_level).in_array(Gitlab::Access.values) } end + + describe "Delegate methods" do + it { should respond_to(:user_name) } + it { should respond_to(:user_email) } + end end diff --git a/spec/models/note_spec.rb b/spec/models/note_spec.rb index d06dee6ce92..a6796d4ab15 100644 --- a/spec/models/note_spec.rb +++ b/spec/models/note_spec.rb @@ -321,8 +321,8 @@ describe Note do describe :read do before do - @p1.users_projects.create(user: @u2, project_access: UsersProject::GUEST) - @p2.users_projects.create(user: @u3, project_access: UsersProject::GUEST) + @p1.project_members.create(user: @u2, project_access: ProjectMember::GUEST) + @p2.project_members.create(user: @u3, project_access: ProjectMember::GUEST) end it { @abilities.allowed?(@u1, :read_note, @p1).should be_false } @@ -332,8 +332,8 @@ describe Note do describe :write do before do - @p1.users_projects.create(user: @u2, project_access: UsersProject::DEVELOPER) - @p2.users_projects.create(user: @u3, project_access: UsersProject::DEVELOPER) + @p1.project_members.create(user: @u2, project_access: ProjectMember::DEVELOPER) + @p2.project_members.create(user: @u3, project_access: ProjectMember::DEVELOPER) end it { @abilities.allowed?(@u1, :write_note, @p1).should be_false } @@ -343,9 +343,9 @@ describe Note do describe :admin do before do - @p1.users_projects.create(user: @u1, project_access: UsersProject::REPORTER) - @p1.users_projects.create(user: @u2, project_access: UsersProject::MASTER) - @p2.users_projects.create(user: @u3, project_access: UsersProject::MASTER) + @p1.project_members.create(user: @u1, project_access: ProjectMember::REPORTER) + @p1.project_members.create(user: @u2, project_access: ProjectMember::MASTER) + @p2.project_members.create(user: @u3, project_access: ProjectMember::MASTER) end it { @abilities.allowed?(@u1, :admin_note, @p1).should be_false } diff --git a/spec/models/users_project_spec.rb b/spec/models/project_member_spec.rb index 3f38164e964..76c5437a555 100644 --- a/spec/models/users_project_spec.rb +++ b/spec/models/project_member_spec.rb @@ -13,30 +13,7 @@ require 'spec_helper' -describe UsersProject do - describe "Associations" do - it { should belong_to(:project) } - it { should belong_to(:user) } - end - - describe "Mass assignment" do - end - - describe "Validation" do - let!(:users_project) { create(:users_project) } - - it { should validate_presence_of(:user) } - it { should validate_uniqueness_of(:user_id).scoped_to(:project_id).with_message(/already exists/) } - - it { should validate_presence_of(:project) } - it { should ensure_inclusion_of(:project_access).in_array(UsersProject.access_roles.values) } - end - - describe "Delegate methods" do - it { should respond_to(:user_name) } - it { should respond_to(:user_email) } - end - +describe ProjectMember do describe :import_team do before do @abilities = Six.new @@ -78,10 +55,10 @@ describe UsersProject do @user_1 = create :user @user_2 = create :user - UsersProject.add_users_into_projects( + ProjectMember.add_users_into_projects( [@project_1.id, @project_2.id], [@user_1.id, @user_2.id], - UsersProject::MASTER + ProjectMember::MASTER ) end @@ -104,7 +81,7 @@ describe UsersProject do @project_1.team << [ @user_1, :developer] @project_2.team << [ @user_2, :reporter] - UsersProject.truncate_teams([@project_1.id, @project_2.id]) + ProjectMember.truncate_teams([@project_1.id, @project_2.id]) end it { @project_1.users.should be_empty } diff --git a/spec/models/project_security_spec.rb b/spec/models/project_security_spec.rb index 1f2bd7a56ff..564edaf8c1b 100644 --- a/spec/models/project_security_spec.rb +++ b/spec/models/project_security_spec.rb @@ -30,7 +30,7 @@ describe Project do describe "Guest Rules" do before do - @p1.users_projects.create(project: @p1, user: @u2, project_access: UsersProject::GUEST) + @p1.project_members.create(project: @p1, user: @u2, project_access: ProjectMember::GUEST) end it "should allow for project user any guest actions" do @@ -42,7 +42,7 @@ describe Project do describe "Report Rules" do before do - @p1.users_projects.create(project: @p1, user: @u2, project_access: UsersProject::REPORTER) + @p1.project_members.create(project: @p1, user: @u2, project_access: ProjectMember::REPORTER) end it "should allow for project user any report actions" do @@ -54,8 +54,8 @@ describe Project do describe "Developer Rules" do before do - @p1.users_projects.create(project: @p1, user: @u2, project_access: UsersProject::REPORTER) - @p1.users_projects.create(project: @p1, user: @u3, project_access: UsersProject::DEVELOPER) + @p1.project_members.create(project: @p1, user: @u2, project_access: ProjectMember::REPORTER) + @p1.project_members.create(project: @p1, user: @u3, project_access: ProjectMember::DEVELOPER) end it "should deny for developer master-specific actions" do @@ -73,8 +73,8 @@ describe Project do describe "Master Rules" do before do - @p1.users_projects.create(project: @p1, user: @u2, project_access: UsersProject::DEVELOPER) - @p1.users_projects.create(project: @p1, user: @u3, project_access: UsersProject::MASTER) + @p1.project_members.create(project: @p1, user: @u2, project_access: ProjectMember::DEVELOPER) + @p1.project_members.create(project: @p1, user: @u3, project_access: ProjectMember::MASTER) end it "should deny for developer master-specific actions" do @@ -92,8 +92,8 @@ describe Project do describe "Admin Rules" do before do - @p1.users_projects.create(project: @p1, user: @u2, project_access: UsersProject::DEVELOPER) - @p1.users_projects.create(project: @p1, user: @u3, project_access: UsersProject::MASTER) + @p1.project_members.create(project: @p1, user: @u2, project_access: ProjectMember::DEVELOPER) + @p1.project_members.create(project: @p1, user: @u3, project_access: ProjectMember::MASTER) end it "should deny for masters admin-specific actions" do diff --git a/spec/models/system_hook_spec.rb b/spec/models/system_hook_spec.rb index 2b98acdeb6c..4ab5261dc9d 100644 --- a/spec/models/system_hook_spec.rb +++ b/spec/models/system_hook_spec.rb @@ -58,7 +58,7 @@ describe SystemHook do user = create(:user) project = create(:project) project.team << [user, :master] - project.users_projects.destroy_all + project.project_members.destroy_all WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once end end diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 7221328a45f..f5c42f7cb2d 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -182,7 +182,7 @@ describe User do @group = create :group @group.add_owner(@user) - @group.add_user(@user2, UsersGroup::OWNER) + @group.add_user(@user2, GroupMember::OWNER) end it { @user2.several_namespaces?.should be_true } |