Commit d683ce5c10ee84d9fde153329d08425c7e99941f
1 parent
fa3ae24c
Exists in
master
and in
4 other branches
refactored factory + fixed tests
Showing
3 changed files
with
8 additions
and
21 deletions
Show diff stats
spec/factories.rb
@@ -47,6 +47,12 @@ FactoryGirl.define do | @@ -47,6 +47,12 @@ FactoryGirl.define do | ||
47 | owner | 47 | owner |
48 | end | 48 | end |
49 | 49 | ||
50 | + factory :group do | ||
51 | + sequence(:name) { |n| "group#{n}" } | ||
52 | + code { name.downcase.gsub(/\s/, '_') } | ||
53 | + owner | ||
54 | + end | ||
55 | + | ||
50 | factory :users_project do | 56 | factory :users_project do |
51 | user | 57 | user |
52 | project | 58 | project |
spec/factories/groups.rb
@@ -1,21 +0,0 @@ | @@ -1,21 +0,0 @@ | ||
1 | -# == Schema Information | ||
2 | -# | ||
3 | -# Table name: groups | ||
4 | -# | ||
5 | -# id :integer not null, primary key | ||
6 | -# name :string(255) not null | ||
7 | -# code :string(255) not null | ||
8 | -# owner_id :integer not null | ||
9 | -# created_at :datetime not null | ||
10 | -# updated_at :datetime not null | ||
11 | -# | ||
12 | - | ||
13 | -# Read about factories at https://github.com/thoughtbot/factory_girl | ||
14 | - | ||
15 | -FactoryGirl.define do | ||
16 | - factory :group do | ||
17 | - name "MyString" | ||
18 | - code "MyString" | ||
19 | - owner_id 1 | ||
20 | - end | ||
21 | -end |
spec/models/group_spec.rb
@@ -13,6 +13,8 @@ | @@ -13,6 +13,8 @@ | ||
13 | require 'spec_helper' | 13 | require 'spec_helper' |
14 | 14 | ||
15 | describe Group do | 15 | describe Group do |
16 | + let!(:group) { create(:group) } | ||
17 | + | ||
16 | it { should have_many :projects } | 18 | it { should have_many :projects } |
17 | it { should validate_presence_of :name } | 19 | it { should validate_presence_of :name } |
18 | it { should validate_uniqueness_of(:name) } | 20 | it { should validate_uniqueness_of(:name) } |