: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
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)
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
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)
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) }
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 ) }
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 ) }
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