Commit 0a2a34a4d18d0489f7db6aad5b5518b503692b5b
1 parent
65b9768c
Exists in
master
and in
4 other branches
Ignore owner_id for Group in tests
Showing
8 changed files
with
36 additions
and
21 deletions
Show diff stats
features/steps/group/group.rb
... | ... | @@ -10,7 +10,8 @@ class Groups < Spinach::FeatureSteps |
10 | 10 | end |
11 | 11 | |
12 | 12 | And 'I have group with projects' do |
13 | - @group = create(:group, owner: current_user) | |
13 | + @group = create(:group) | |
14 | + @group.add_owner(current_user) | |
14 | 15 | @project = create(:project, namespace: @group) |
15 | 16 | @event = create(:closed_issue_event, project: @project) |
16 | 17 | ... | ... |
spec/contexts/projects_create_context_spec.rb
... | ... | @@ -25,13 +25,15 @@ describe Projects::CreateContext do |
25 | 25 | |
26 | 26 | context 'group namespace' do |
27 | 27 | before do |
28 | - @group = create :group, owner: @user | |
28 | + @group = create :group | |
29 | + @group.add_owner(@user) | |
30 | + | |
29 | 31 | @opts.merge!(namespace_id: @group.id) |
30 | 32 | @project = create_project(@user, @opts) |
31 | 33 | end |
32 | 34 | |
33 | 35 | it { @project.should be_valid } |
34 | - it { @project.owner.should == @user } | |
36 | + it { @project.owner.should == @group } | |
35 | 37 | it { @project.namespace.should == @group } |
36 | 38 | end |
37 | 39 | ... | ... |
spec/factories.rb
spec/features/security/group_access_spec.rb
... | ... | @@ -10,11 +10,13 @@ describe "Group access" do |
10 | 10 | describe "Group" do |
11 | 11 | let(:group) { create(:group) } |
12 | 12 | |
13 | + let(:owner) { create(:owner) } | |
13 | 14 | let(:master) { create(:user) } |
14 | 15 | let(:reporter) { create(:user) } |
15 | 16 | let(:guest) { create(:user) } |
16 | 17 | |
17 | 18 | before do |
19 | + group.add_user(owner, Gitlab::Access::OWNER) | |
18 | 20 | group.add_user(master, Gitlab::Access::MASTER) |
19 | 21 | group.add_user(reporter, Gitlab::Access::REPORTER) |
20 | 22 | group.add_user(guest, Gitlab::Access::GUEST) |
... | ... | @@ -23,7 +25,7 @@ describe "Group access" do |
23 | 25 | describe "GET /groups/:path" do |
24 | 26 | subject { group_path(group) } |
25 | 27 | |
26 | - it { should be_allowed_for group.owner } | |
28 | + it { should be_allowed_for owner } | |
27 | 29 | it { should be_allowed_for master } |
28 | 30 | it { should be_allowed_for reporter } |
29 | 31 | it { should be_allowed_for :admin } |
... | ... | @@ -35,7 +37,7 @@ describe "Group access" do |
35 | 37 | describe "GET /groups/:path/issues" do |
36 | 38 | subject { issues_group_path(group) } |
37 | 39 | |
38 | - it { should be_allowed_for group.owner } | |
40 | + it { should be_allowed_for owner } | |
39 | 41 | it { should be_allowed_for master } |
40 | 42 | it { should be_allowed_for reporter } |
41 | 43 | it { should be_allowed_for :admin } |
... | ... | @@ -47,7 +49,7 @@ describe "Group access" do |
47 | 49 | describe "GET /groups/:path/merge_requests" do |
48 | 50 | subject { merge_requests_group_path(group) } |
49 | 51 | |
50 | - it { should be_allowed_for group.owner } | |
52 | + it { should be_allowed_for owner } | |
51 | 53 | it { should be_allowed_for master } |
52 | 54 | it { should be_allowed_for reporter } |
53 | 55 | it { should be_allowed_for :admin } |
... | ... | @@ -59,7 +61,7 @@ describe "Group access" do |
59 | 61 | describe "GET /groups/:path/members" do |
60 | 62 | subject { members_group_path(group) } |
61 | 63 | |
62 | - it { should be_allowed_for group.owner } | |
64 | + it { should be_allowed_for owner } | |
63 | 65 | it { should be_allowed_for master } |
64 | 66 | it { should be_allowed_for reporter } |
65 | 67 | it { should be_allowed_for :admin } |
... | ... | @@ -71,7 +73,7 @@ describe "Group access" do |
71 | 73 | describe "GET /groups/:path/edit" do |
72 | 74 | subject { edit_group_path(group) } |
73 | 75 | |
74 | - it { should be_allowed_for group.owner } | |
76 | + it { should be_allowed_for owner } | |
75 | 77 | it { should be_denied_for master } |
76 | 78 | it { should be_denied_for reporter } |
77 | 79 | it { should be_allowed_for :admin } | ... | ... |
spec/models/group_spec.rb
... | ... | @@ -26,10 +26,10 @@ describe Group do |
26 | 26 | it { should validate_uniqueness_of(:name) } |
27 | 27 | it { should validate_presence_of :path } |
28 | 28 | it { should validate_uniqueness_of(:path) } |
29 | - it { should validate_presence_of :owner } | |
29 | + it { should_not validate_presence_of :owner } | |
30 | 30 | |
31 | 31 | describe :users do |
32 | - it { group.users.should == [group.owner] } | |
32 | + it { group.users.should == group.owners } | |
33 | 33 | end |
34 | 34 | |
35 | 35 | describe :human_name do |
... | ... | @@ -38,7 +38,7 @@ describe Group do |
38 | 38 | |
39 | 39 | describe :add_users do |
40 | 40 | let(:user) { create(:user) } |
41 | - before { group.add_users([user.id], UsersGroup::MASTER) } | |
41 | + before { group.add_user(user, UsersGroup::MASTER) } | |
42 | 42 | |
43 | 43 | it { group.users_groups.masters.map(&:user).should include(user) } |
44 | 44 | end | ... | ... |
spec/models/project_spec.rb
... | ... | @@ -85,7 +85,6 @@ describe Project do |
85 | 85 | it { should respond_to(:execute_hooks) } |
86 | 86 | it { should respond_to(:transfer) } |
87 | 87 | it { should respond_to(:name_with_namespace) } |
88 | - it { should respond_to(:namespace_owner) } | |
89 | 88 | it { should respond_to(:owner) } |
90 | 89 | it { should respond_to(:path_with_namespace) } |
91 | 90 | end | ... | ... |
spec/models/user_spec.rb
... | ... | @@ -130,11 +130,12 @@ describe User do |
130 | 130 | before do |
131 | 131 | ActiveRecord::Base.observers.enable(:user_observer) |
132 | 132 | @user = create :user |
133 | - @group = create :group, owner: @user | |
133 | + @group = create :group | |
134 | + @group.add_owner(@user) | |
134 | 135 | end |
135 | 136 | |
136 | 137 | it { @user.several_namespaces?.should be_true } |
137 | - it { @user.namespaces.should include(@user.namespace, @group) } | |
138 | + it { @user.namespaces.should include(@user.namespace) } | |
138 | 139 | it { @user.authorized_groups.should == [@group] } |
139 | 140 | it { @user.owned_groups.should == [@group] } |
140 | 141 | end |
... | ... | @@ -144,9 +145,10 @@ describe User do |
144 | 145 | ActiveRecord::Base.observers.enable(:user_observer) |
145 | 146 | @user = create :user |
146 | 147 | @user2 = create :user |
147 | - @group = create :group, owner: @user | |
148 | + @group = create :group | |
149 | + @group.add_owner(@user) | |
148 | 150 | |
149 | - @group.add_users([@user2.id], UsersGroup::OWNER) | |
151 | + @group.add_user(@user2, UsersGroup::OWNER) | |
150 | 152 | end |
151 | 153 | |
152 | 154 | it { @user2.several_namespaces?.should be_true } | ... | ... |
spec/requests/api/groups_spec.rb
... | ... | @@ -6,8 +6,13 @@ describe API::API do |
6 | 6 | let(:user1) { create(:user) } |
7 | 7 | let(:user2) { create(:user) } |
8 | 8 | let(:admin) { create(:admin) } |
9 | - let!(:group1) { create(:group, owner: user1) } | |
10 | - let!(:group2) { create(:group, owner: user2) } | |
9 | + let!(:group1) { create(:group) } | |
10 | + let!(:group2) { create(:group) } | |
11 | + | |
12 | + before do | |
13 | + group1.add_owner(user1) | |
14 | + group2.add_owner(user2) | |
15 | + end | |
11 | 16 | |
12 | 17 | describe "GET /groups" do |
13 | 18 | context "when unauthenticated" do |
... | ... | @@ -130,14 +135,19 @@ describe API::API do |
130 | 135 | let(:master) { create(:user) } |
131 | 136 | let(:guest) { create(:user) } |
132 | 137 | let!(:group_with_members) do |
133 | - group = create(:group, owner: owner) | |
138 | + group = create(:group) | |
134 | 139 | group.add_users([reporter.id], UsersGroup::REPORTER) |
135 | 140 | group.add_users([developer.id], UsersGroup::DEVELOPER) |
136 | 141 | group.add_users([master.id], UsersGroup::MASTER) |
137 | 142 | group.add_users([guest.id], UsersGroup::GUEST) |
138 | 143 | group |
139 | 144 | end |
140 | - let!(:group_no_members) { create(:group, owner: owner) } | |
145 | + let!(:group_no_members) { create(:group) } | |
146 | + | |
147 | + before do | |
148 | + group_with_members.add_owner owner | |
149 | + group_no_members.add_owner owner | |
150 | + end | |
141 | 151 | |
142 | 152 | describe "GET /groups/:id/members" do |
143 | 153 | context "when authenticated as user that is part or the group" do | ... | ... |