refactored factory + fixed tests
This commit is contained in:
parent
fa3ae24ca7
commit
d683ce5c10
|
@ -47,6 +47,12 @@ FactoryGirl.define do
|
||||||
owner
|
owner
|
||||||
end
|
end
|
||||||
|
|
||||||
|
factory :group do
|
||||||
|
sequence(:name) { |n| "group#{n}" }
|
||||||
|
code { name.downcase.gsub(/\s/, '_') }
|
||||||
|
owner
|
||||||
|
end
|
||||||
|
|
||||||
factory :users_project do
|
factory :users_project do
|
||||||
user
|
user
|
||||||
project
|
project
|
||||||
|
|
|
@ -1,21 +0,0 @@
|
||||||
# == Schema Information
|
|
||||||
#
|
|
||||||
# Table name: groups
|
|
||||||
#
|
|
||||||
# id :integer not null, primary key
|
|
||||||
# name :string(255) not null
|
|
||||||
# code :string(255) not null
|
|
||||||
# owner_id :integer not null
|
|
||||||
# created_at :datetime not null
|
|
||||||
# updated_at :datetime not null
|
|
||||||
#
|
|
||||||
|
|
||||||
# Read about factories at https://github.com/thoughtbot/factory_girl
|
|
||||||
|
|
||||||
FactoryGirl.define do
|
|
||||||
factory :group do
|
|
||||||
name "MyString"
|
|
||||||
code "MyString"
|
|
||||||
owner_id 1
|
|
||||||
end
|
|
||||||
end
|
|
|
@ -13,6 +13,8 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Group do
|
describe Group do
|
||||||
|
let!(:group) { create(:group) }
|
||||||
|
|
||||||
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) }
|
||||||
|
|
Loading…
Reference in a new issue