Fix model tests

This commit is contained in:
Dmitriy Zaporozhets 2012-11-23 20:53:24 +02:00
parent 9304d049de
commit e92b563acf
4 changed files with 13 additions and 13 deletions

View file

@ -29,14 +29,17 @@ FactoryGirl.define do
owner owner
end end
factory :group do
sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') }
owner
type 'Group'
end
factory :namespace do factory :namespace do
sequence(:name) { |n| "group#{n}" } sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
owner owner
factory :group do
type 'Group'
end
end end
factory :users_project do factory :users_project do

View file

@ -18,7 +18,7 @@ describe Group do
it { should have_many :projects } it { should have_many :projects }
it { should validate_presence_of :name } it { should validate_presence_of :name }
it { should validate_uniqueness_of(:name) } it { should validate_uniqueness_of(:name) }
it { should validate_presence_of :code } it { should validate_presence_of :path }
it { should validate_uniqueness_of(:code) } it { should validate_uniqueness_of(:path) }
it { should validate_presence_of :owner } it { should validate_presence_of :owner }
end end

View file

@ -6,7 +6,7 @@ describe Namespace do
it { should have_many :projects } it { should have_many :projects }
it { should validate_presence_of :name } it { should validate_presence_of :name }
it { should validate_uniqueness_of(:name) } it { should validate_uniqueness_of(:name) }
it { should validate_presence_of :code } it { should validate_presence_of :path }
it { should validate_uniqueness_of(:code) } it { should validate_uniqueness_of(:path) }
it { should validate_presence_of :owner } it { should validate_presence_of :owner }
end end

View file

@ -59,9 +59,6 @@ describe Project do
it { should ensure_length_of(:description).is_within(0..2000) } it { should ensure_length_of(:description).is_within(0..2000) }
it { should validate_presence_of(:code) }
it { should validate_uniqueness_of(:code) }
it { should ensure_length_of(:code).is_within(1..255) }
# TODO: Formats # TODO: Formats
it { should validate_presence_of(:owner) } it { should validate_presence_of(:owner) }
@ -152,7 +149,7 @@ describe Project do
end end
it "returns the full web URL for this repo" do it "returns the full web URL for this repo" do
project = Project.new(code: "somewhere") project = Project.new(path: "somewhere")
project.web_url.should == "#{Gitlab.config.url}/somewhere" project.web_url.should == "#{Gitlab.config.url}/somewhere"
end end
@ -163,7 +160,7 @@ describe Project do
end end
it "should be invalid repo" do it "should be invalid repo" do
project = Project.new(name: "ok_name", path: "/INVALID_PATH/", code: "NEOK") project = Project.new(name: "ok_name", path: "/INVALID_PATH/", path: "NEOK")
project.valid_repo?.should be_false project.valid_repo?.should be_false
end end
end end