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
end
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)
@event = create(:closed_issue_event, project: @project)
......
......@@ -25,13 +25,15 @@ describe Projects::CreateContext do
context 'group namespace' do
before do
@group = create :group, owner: @user
@group = create :group
@group.add_owner(@user)
@opts.merge!(namespace_id: @group.id)
@project = create_project(@user, @opts)
end
it { @project.should be_valid }
it { @project.owner.should == @user }
it { @project.owner.should == @group }
it { @project.namespace.should == @group }
end
......
......@@ -71,7 +71,6 @@ FactoryGirl.define do
factory :group do
sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') }
owner
type 'Group'
end
......
......@@ -10,11 +10,13 @@ describe "Group access" do
describe "Group" do
let(:group) { create(:group) }
let(:owner) { create(:owner) }
let(:master) { create(:user) }
let(:reporter) { create(:user) }
let(:guest) { create(:user) }
before do
group.add_user(owner, Gitlab::Access::OWNER)
group.add_user(master, Gitlab::Access::MASTER)
group.add_user(reporter, Gitlab::Access::REPORTER)
group.add_user(guest, Gitlab::Access::GUEST)
......@@ -23,7 +25,7 @@ describe "Group access" do
describe "GET /groups/:path" do
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 reporter }
it { should be_allowed_for :admin }
......@@ -35,7 +37,7 @@ describe "Group access" do
describe "GET /groups/:path/issues" do
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 reporter }
it { should be_allowed_for :admin }
......@@ -47,7 +49,7 @@ describe "Group access" do
describe "GET /groups/:path/merge_requests" do
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 reporter }
it { should be_allowed_for :admin }
......@@ -59,7 +61,7 @@ describe "Group access" do
describe "GET /groups/:path/members" do
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 reporter }
it { should be_allowed_for :admin }
......@@ -71,7 +73,7 @@ describe "Group access" do
describe "GET /groups/:path/edit" do
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 reporter }
it { should be_allowed_for :admin }
......
......@@ -26,10 +26,10 @@ describe Group do
it { should validate_uniqueness_of(:name) }
it { should validate_presence_of :path }
it { should validate_uniqueness_of(:path) }
it { should validate_presence_of :owner }
it { should_not validate_presence_of :owner }
describe :users do
it { group.users.should == [group.owner] }
it { group.users.should == group.owners }
end
describe :human_name do
......@@ -38,7 +38,7 @@ describe Group do
describe :add_users do
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) }
end
......
......@@ -85,7 +85,6 @@ describe Project do
it { should respond_to(:execute_hooks) }
it { should respond_to(:transfer) }
it { should respond_to(:name_with_namespace) }
it { should respond_to(:namespace_owner) }
it { should respond_to(:owner) }
it { should respond_to(:path_with_namespace) }
end
......
......@@ -130,11 +130,12 @@ describe User do
before do
ActiveRecord::Base.observers.enable(:user_observer)
@user = create :user
@group = create :group, owner: @user
@group = create :group
@group.add_owner(@user)
end
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.owned_groups.should == [@group] }
end
......@@ -144,9 +145,10 @@ describe User do
ActiveRecord::Base.observers.enable(:user_observer)
@user = 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
it { @user2.several_namespaces?.should be_true }
......
......@@ -6,8 +6,13 @@ describe API::API do
let(:user1) { create(:user) }
let(:user2) { create(:user) }
let(:admin) { create(:admin) }
let!(:group1) { create(:group, owner: user1) }
let!(:group2) { create(:group, owner: user2) }
let!(:group1) { create(:group) }
let!(:group2) { create(:group) }
before do
group1.add_owner(user1)
group2.add_owner(user2)
end
describe "GET /groups" do
context "when unauthenticated" do
......@@ -130,14 +135,19 @@ describe API::API do
let(:master) { create(:user) }
let(:guest) { create(:user) }
let!(:group_with_members) do
group = create(:group, owner: owner)
group = create(:group)
group.add_users([reporter.id], UsersGroup::REPORTER)
group.add_users([developer.id], UsersGroup::DEVELOPER)
group.add_users([master.id], UsersGroup::MASTER)
group.add_users([guest.id], UsersGroup::GUEST)
group
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
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