Commit bab575a0fa4dc9f27843100915976262e386dcb6
1 parent
0ab40a69
Exists in
master
and in
1 other branch
Add project watchers
Showing
4 changed files
with
31 additions
and
0 deletions
Show diff stats
app/models/project.rb
@@ -5,6 +5,7 @@ class Project | @@ -5,6 +5,7 @@ class Project | ||
5 | field :name, :type => String | 5 | field :name, :type => String |
6 | field :api_key | 6 | field :api_key |
7 | 7 | ||
8 | + embeds_many :watchers | ||
8 | references_many :errs | 9 | references_many :errs |
9 | 10 | ||
10 | before_validation :generate_api_key, :on => :create | 11 | before_validation :generate_api_key, :on => :create |
spec/factories/project_factories.rb
1 | Factory.sequence(:project_name) {|n| "Project ##{n}"} | 1 | Factory.sequence(:project_name) {|n| "Project ##{n}"} |
2 | +Factory.sequence(:email) {|n| "email#{n}@example.com"} | ||
2 | 3 | ||
3 | Factory.define(:project) do |p| | 4 | Factory.define(:project) do |p| |
4 | p.name { Factory.next :project_name } | 5 | p.name { Factory.next :project_name } |
6 | +end | ||
7 | + | ||
8 | +Factory.define(:watcher) do |w| | ||
9 | + w.project {|p| p.association :project} | ||
10 | + w.email { Factory.next :email } | ||
5 | end | 11 | end |
6 | \ No newline at end of file | 12 | \ No newline at end of file |
@@ -0,0 +1,13 @@ | @@ -0,0 +1,13 @@ | ||
1 | +require 'spec_helper' | ||
2 | + | ||
3 | +describe Watcher do | ||
4 | + | ||
5 | + context 'validations' do | ||
6 | + it 'requires an email address' do | ||
7 | + watcher = Factory.build(:watcher, :email => nil) | ||
8 | + watcher.should_not be_valid | ||
9 | + watcher.errors[:email].should include("can't be blank") | ||
10 | + end | ||
11 | + end | ||
12 | + | ||
13 | +end |