Commit 8672203b authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge pull request #5112 from hiroponz/drop-support-of-root-namespace

Drop support of root namespace in model
parents 9fabd703 a3ef6831
......@@ -83,6 +83,7 @@ class Project < ActiveRecord::Base
:wiki_enabled, inclusion: { in: [true, false] }
validates :issues_tracker_id, length: { within: 0..255 }
validates :namespace, presence: true
validates_uniqueness_of :name, scope: :namespace_id
validates_uniqueness_of :path, scope: :namespace_id
......@@ -165,11 +166,7 @@ class Project < ActiveRecord::Base
end
def to_param
if namespace
namespace.path + "/" + path
else
path
end
namespace.path + "/" + path
end
def web_url
......
require 'spec_helper'
describe Issues::BulkUpdateContext do
before(:each) { ActiveRecord::Base.observers.enable(:user_observer) }
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
let(:issue) {
create(:issue, project: @project)
......@@ -9,7 +11,8 @@ describe Issues::BulkUpdateContext do
before do
@user = create :user
opts = {
name: "GitLab"
name: "GitLab",
namespace: @user.namespace
}
@project = Projects::CreateContext.new(@user, opts).execute
end
......
require 'spec_helper'
describe Projects::CreateContext do
before(:each) { ActiveRecord::Base.observers.enable(:user_observer) }
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
describe :create_by_user do
before do
@user = create :user
@opts = {
name: "GitLab"
name: "GitLab",
namespace: @user.namespace
}
end
......
......@@ -67,6 +67,7 @@ describe Project do
it { should ensure_length_of(:description).is_within(0..2000) }
it { should validate_presence_of(:creator) }
it { should ensure_length_of(:issues_tracker_id).is_within(0..255) }
it { should validate_presence_of(:namespace) }
it "should not allow new projects beyond user limits" do
project2 = build(:project)
......
......@@ -2,6 +2,8 @@ require 'spec_helper'
describe API::API do
include ApiHelpers
before(:each) { ActiveRecord::Base.observers.enable(:user_observer) }
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
let(:user) { create(:user) }
let(:key) { create(:key, user: user) }
......
......@@ -2,6 +2,8 @@ require 'spec_helper'
describe API::API do
include ApiHelpers
before(:each) { ActiveRecord::Base.observers.enable(:user_observer) }
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
let(:user) { create(:user) }
let!(:project) { create(:project, namespace: user.namespace ) }
......
......@@ -2,6 +2,8 @@ require 'spec_helper'
describe API::API do
include ApiHelpers
before(:each) { ActiveRecord::Base.observers.enable(:user_observer) }
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
let(:user) { create(:user) }
let!(:project) { create(:project, namespace: user.namespace ) }
......
......@@ -21,25 +21,7 @@ describe ProjectTransferService do
let(:user) { create(:user) }
let(:project) { create(:project, namespace: user.namespace) }
before do
@result = service.transfer(project, nil)
end
it { @result.should be_true }
it { project.namespace.should == nil }
end
context 'no namespace -> namespace' do
let(:project) { create(:project) }
let(:user) { create(:user) }
before do
@result = service.transfer(project, user.namespace)
end
it { @result.should be_true }
it { project.namespace.should == user.namespace }
it { lambda{service.transfer(project, nil)}.should raise_error(ActiveRecord::RecordInvalid) }
end
def service
......
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