Commit 0a2a34a4 authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Ignore owner_id for Group in tests

parent 65b9768c
...@@ -10,7 +10,8 @@ class Groups < Spinach::FeatureSteps ...@@ -10,7 +10,8 @@ class Groups < Spinach::FeatureSteps
end end
And 'I have group with projects' do And 'I have group with projects' do
@group = create(:group, owner: current_user) @group = create(:group)
@group.add_owner(current_user)
@project = create(:project, namespace: @group) @project = create(:project, namespace: @group)
@event = create(:closed_issue_event, project: @project) @event = create(:closed_issue_event, project: @project)
......
...@@ -25,13 +25,15 @@ describe Projects::CreateContext do ...@@ -25,13 +25,15 @@ describe Projects::CreateContext do
context 'group namespace' do context 'group namespace' do
before do before do
@group = create :group, owner: @user @group = create :group
@group.add_owner(@user)
@opts.merge!(namespace_id: @group.id) @opts.merge!(namespace_id: @group.id)
@project = create_project(@user, @opts) @project = create_project(@user, @opts)
end end
it { @project.should be_valid } it { @project.should be_valid }
it { @project.owner.should == @user } it { @project.owner.should == @group }
it { @project.namespace.should == @group } it { @project.namespace.should == @group }
end end
......
...@@ -71,7 +71,6 @@ FactoryGirl.define do ...@@ -71,7 +71,6 @@ FactoryGirl.define do
factory :group do factory :group do
sequence(:name) { |n| "group#{n}" } sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
owner
type 'Group' type 'Group'
end end
......
...@@ -10,11 +10,13 @@ describe "Group access" do ...@@ -10,11 +10,13 @@ describe "Group access" do
describe "Group" do describe "Group" do
let(:group) { create(:group) } let(:group) { create(:group) }
let(:owner) { create(:owner) }
let(:master) { create(:user) } let(:master) { create(:user) }
let(:reporter) { create(:user) } let(:reporter) { create(:user) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
before do before do
group.add_user(owner, Gitlab::Access::OWNER)
group.add_user(master, Gitlab::Access::MASTER) group.add_user(master, Gitlab::Access::MASTER)
group.add_user(reporter, Gitlab::Access::REPORTER) group.add_user(reporter, Gitlab::Access::REPORTER)
group.add_user(guest, Gitlab::Access::GUEST) group.add_user(guest, Gitlab::Access::GUEST)
...@@ -23,7 +25,7 @@ describe "Group access" do ...@@ -23,7 +25,7 @@ describe "Group access" do
describe "GET /groups/:path" do describe "GET /groups/:path" do
subject { group_path(group) } subject { group_path(group) }
it { should be_allowed_for group.owner } it { should be_allowed_for owner }
it { should be_allowed_for master } it { should be_allowed_for master }
it { should be_allowed_for reporter } it { should be_allowed_for reporter }
it { should be_allowed_for :admin } it { should be_allowed_for :admin }
...@@ -35,7 +37,7 @@ describe "Group access" do ...@@ -35,7 +37,7 @@ describe "Group access" do
describe "GET /groups/:path/issues" do describe "GET /groups/:path/issues" do
subject { issues_group_path(group) } subject { issues_group_path(group) }
it { should be_allowed_for group.owner } it { should be_allowed_for owner }
it { should be_allowed_for master } it { should be_allowed_for master }
it { should be_allowed_for reporter } it { should be_allowed_for reporter }
it { should be_allowed_for :admin } it { should be_allowed_for :admin }
...@@ -47,7 +49,7 @@ describe "Group access" do ...@@ -47,7 +49,7 @@ describe "Group access" do
describe "GET /groups/:path/merge_requests" do describe "GET /groups/:path/merge_requests" do
subject { merge_requests_group_path(group) } subject { merge_requests_group_path(group) }
it { should be_allowed_for group.owner } it { should be_allowed_for owner }
it { should be_allowed_for master } it { should be_allowed_for master }
it { should be_allowed_for reporter } it { should be_allowed_for reporter }
it { should be_allowed_for :admin } it { should be_allowed_for :admin }
...@@ -59,7 +61,7 @@ describe "Group access" do ...@@ -59,7 +61,7 @@ describe "Group access" do
describe "GET /groups/:path/members" do describe "GET /groups/:path/members" do
subject { members_group_path(group) } subject { members_group_path(group) }
it { should be_allowed_for group.owner } it { should be_allowed_for owner }
it { should be_allowed_for master } it { should be_allowed_for master }
it { should be_allowed_for reporter } it { should be_allowed_for reporter }
it { should be_allowed_for :admin } it { should be_allowed_for :admin }
...@@ -71,7 +73,7 @@ describe "Group access" do ...@@ -71,7 +73,7 @@ describe "Group access" do
describe "GET /groups/:path/edit" do describe "GET /groups/:path/edit" do
subject { edit_group_path(group) } subject { edit_group_path(group) }
it { should be_allowed_for group.owner } it { should be_allowed_for owner }
it { should be_denied_for master } it { should be_denied_for master }
it { should be_denied_for reporter } it { should be_denied_for reporter }
it { should be_allowed_for :admin } it { should be_allowed_for :admin }
......
...@@ -26,10 +26,10 @@ describe Group do ...@@ -26,10 +26,10 @@ describe Group do
it { should validate_uniqueness_of(:name) } it { should validate_uniqueness_of(:name) }
it { should validate_presence_of :path } it { should validate_presence_of :path }
it { should validate_uniqueness_of(:path) } it { should validate_uniqueness_of(:path) }
it { should validate_presence_of :owner } it { should_not validate_presence_of :owner }
describe :users do describe :users do
it { group.users.should == [group.owner] } it { group.users.should == group.owners }
end end
describe :human_name do describe :human_name do
...@@ -38,7 +38,7 @@ describe Group do ...@@ -38,7 +38,7 @@ describe Group do
describe :add_users do describe :add_users do
let(:user) { create(:user) } let(:user) { create(:user) }
before { group.add_users([user.id], UsersGroup::MASTER) } before { group.add_user(user, UsersGroup::MASTER) }
it { group.users_groups.masters.map(&:user).should include(user) } it { group.users_groups.masters.map(&:user).should include(user) }
end end
......
...@@ -85,7 +85,6 @@ describe Project do ...@@ -85,7 +85,6 @@ describe Project do
it { should respond_to(:execute_hooks) } it { should respond_to(:execute_hooks) }
it { should respond_to(:transfer) } it { should respond_to(:transfer) }
it { should respond_to(:name_with_namespace) } it { should respond_to(:name_with_namespace) }
it { should respond_to(:namespace_owner) }
it { should respond_to(:owner) } it { should respond_to(:owner) }
it { should respond_to(:path_with_namespace) } it { should respond_to(:path_with_namespace) }
end end
......
...@@ -130,11 +130,12 @@ describe User do ...@@ -130,11 +130,12 @@ describe User do
before do before do
ActiveRecord::Base.observers.enable(:user_observer) ActiveRecord::Base.observers.enable(:user_observer)
@user = create :user @user = create :user
@group = create :group, owner: @user @group = create :group
@group.add_owner(@user)
end end
it { @user.several_namespaces?.should be_true } it { @user.several_namespaces?.should be_true }
it { @user.namespaces.should include(@user.namespace, @group) } it { @user.namespaces.should include(@user.namespace) }
it { @user.authorized_groups.should == [@group] } it { @user.authorized_groups.should == [@group] }
it { @user.owned_groups.should == [@group] } it { @user.owned_groups.should == [@group] }
end end
...@@ -144,9 +145,10 @@ describe User do ...@@ -144,9 +145,10 @@ describe User do
ActiveRecord::Base.observers.enable(:user_observer) ActiveRecord::Base.observers.enable(:user_observer)
@user = create :user @user = create :user
@user2 = create :user @user2 = create :user
@group = create :group, owner: @user @group = create :group
@group.add_owner(@user)
@group.add_users([@user2.id], UsersGroup::OWNER) @group.add_user(@user2, UsersGroup::OWNER)
end end
it { @user2.several_namespaces?.should be_true } it { @user2.several_namespaces?.should be_true }
......
...@@ -6,8 +6,13 @@ describe API::API do ...@@ -6,8 +6,13 @@ describe API::API do
let(:user1) { create(:user) } let(:user1) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let!(:group1) { create(:group, owner: user1) } let!(:group1) { create(:group) }
let!(:group2) { create(:group, owner: user2) } let!(:group2) { create(:group) }
before do
group1.add_owner(user1)
group2.add_owner(user2)
end
describe "GET /groups" do describe "GET /groups" do
context "when unauthenticated" do context "when unauthenticated" do
...@@ -130,14 +135,19 @@ describe API::API do ...@@ -130,14 +135,19 @@ describe API::API do
let(:master) { create(:user) } let(:master) { create(:user) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
let!(:group_with_members) do let!(:group_with_members) do
group = create(:group, owner: owner) group = create(:group)
group.add_users([reporter.id], UsersGroup::REPORTER) group.add_users([reporter.id], UsersGroup::REPORTER)
group.add_users([developer.id], UsersGroup::DEVELOPER) group.add_users([developer.id], UsersGroup::DEVELOPER)
group.add_users([master.id], UsersGroup::MASTER) group.add_users([master.id], UsersGroup::MASTER)
group.add_users([guest.id], UsersGroup::GUEST) group.add_users([guest.id], UsersGroup::GUEST)
group group
end end
let!(:group_no_members) { create(:group, owner: owner) } let!(:group_no_members) { create(:group) }
before do
group_with_members.add_owner owner
group_no_members.add_owner owner
end
describe "GET /groups/:id/members" do describe "GET /groups/:id/members" do
context "when authenticated as user that is part or the group" do context "when authenticated as user that is part or the group" do
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment