Commit 4b7804e48a10d3ea5547fbdb1d5d95b20b7be17e
Exists in
master
and in
1 other branch
Merge pull request #134 from shingara/fabrication_gem
Migration from factory girls to Fabrication Gem
Showing
42 changed files
with
397 additions
and
378 deletions
Show diff stats
Gemfile
@@ -31,8 +31,7 @@ gem 'ri_cal' | @@ -31,8 +31,7 @@ gem 'ri_cal' | ||
31 | group :development, :test do | 31 | group :development, :test do |
32 | gem 'rspec-rails', '~> 2.6' | 32 | gem 'rspec-rails', '~> 2.6' |
33 | gem 'webmock', :require => false | 33 | gem 'webmock', :require => false |
34 | - gem 'factory_girl', '~> 1.3.3' | ||
35 | - gem 'factory_girl_rails', '~> 1.0.1' | 34 | + gem 'fabrication' |
36 | unless ENV['TRAVIS'] | 35 | unless ENV['TRAVIS'] |
37 | gem 'ruby-debug', :platform => :mri_18 | 36 | gem 'ruby-debug', :platform => :mri_18 |
38 | gem 'ruby-debug19', :platform => :mri_19, :require => 'ruby-debug' | 37 | gem 'ruby-debug19', :platform => :mri_19, :require => 'ruby-debug' |
Gemfile.lock
@@ -55,10 +55,7 @@ GEM | @@ -55,10 +55,7 @@ GEM | ||
55 | rspec (~> 2.0) | 55 | rspec (~> 2.0) |
56 | erubis (2.6.6) | 56 | erubis (2.6.6) |
57 | abstract (>= 1.0.0) | 57 | abstract (>= 1.0.0) |
58 | - factory_girl (1.3.3) | ||
59 | - factory_girl_rails (1.0.1) | ||
60 | - factory_girl (~> 1.3) | ||
61 | - railties (>= 3.0.0) | 58 | + fabrication (1.2.0) |
62 | faraday (0.7.4) | 59 | faraday (0.7.4) |
63 | addressable (~> 2.2.6) | 60 | addressable (~> 2.2.6) |
64 | multipart-post (~> 1.1.0) | 61 | multipart-post (~> 1.1.0) |
@@ -219,8 +216,7 @@ DEPENDENCIES | @@ -219,8 +216,7 @@ DEPENDENCIES | ||
219 | database_cleaner (~> 0.6.0) | 216 | database_cleaner (~> 0.6.0) |
220 | devise (~> 1.4.0) | 217 | devise (~> 1.4.0) |
221 | email_spec | 218 | email_spec |
222 | - factory_girl (~> 1.3.3) | ||
223 | - factory_girl_rails (~> 1.0.1) | 219 | + fabrication |
224 | haml | 220 | haml |
225 | hoptoad_notifier (~> 2.4) | 221 | hoptoad_notifier (~> 2.4) |
226 | htmlentities (~> 4.3.0) | 222 | htmlentities (~> 4.3.0) |
app/models/problem.rb
@@ -116,7 +116,9 @@ class Problem | @@ -116,7 +116,9 @@ class Problem | ||
116 | self.last_deploy_at = if (last_deploy = app.deploys.where(:environment => self.environment).last) | 116 | self.last_deploy_at = if (last_deploy = app.deploys.where(:environment => self.environment).last) |
117 | last_deploy.created_at | 117 | last_deploy.created_at |
118 | end | 118 | end |
119 | - self.save if persisted? | 119 | + collection.update({'_id' => self.id}, |
120 | + {'$set' => {'app_name' => self.app_name, | ||
121 | + 'last_deploy_at' => self.last_deploy_at}}) | ||
120 | end | 122 | end |
121 | end | 123 | end |
122 | 124 |
config/application.rb
@@ -45,6 +45,7 @@ module Errbit | @@ -45,6 +45,7 @@ module Errbit | ||
45 | g.orm :mongoid | 45 | g.orm :mongoid |
46 | g.template_engine :haml | 46 | g.template_engine :haml |
47 | g.test_framework :rspec, :fixture => false | 47 | g.test_framework :rspec, :fixture => false |
48 | + g.fixture_replacement :fabrication | ||
48 | end | 49 | end |
49 | 50 | ||
50 | # IssueTracker subclasses use inheritance, so preloading models provides querying consistency in dev mode. | 51 | # IssueTracker subclasses use inheritance, so preloading models provides querying consistency in dev mode. |
spec/controllers/apps_controller_spec.rb
@@ -10,8 +10,8 @@ describe AppsController do | @@ -10,8 +10,8 @@ describe AppsController do | ||
10 | describe "GET /apps" do | 10 | describe "GET /apps" do |
11 | context 'when logged in as an admin' do | 11 | context 'when logged in as an admin' do |
12 | it 'finds all apps' do | 12 | it 'finds all apps' do |
13 | - sign_in Factory(:admin) | ||
14 | - 3.times { Factory(:app) } | 13 | + sign_in Fabricate(:admin) |
14 | + 3.times { Fabricate(:app) } | ||
15 | apps = App.all | 15 | apps = App.all |
16 | get :index | 16 | get :index |
17 | assigns(:apps).should == apps | 17 | assigns(:apps).should == apps |
@@ -20,12 +20,12 @@ describe AppsController do | @@ -20,12 +20,12 @@ describe AppsController do | ||
20 | 20 | ||
21 | context 'when logged in as a regular user' do | 21 | context 'when logged in as a regular user' do |
22 | it 'finds apps the user is watching' do | 22 | it 'finds apps the user is watching' do |
23 | - sign_in(user = Factory(:user)) | ||
24 | - unwatched_app = Factory(:app) | ||
25 | - watched_app1 = Factory(:app) | ||
26 | - watched_app2 = Factory(:app) | ||
27 | - Factory(:user_watcher, :user => user, :app => watched_app1) | ||
28 | - Factory(:user_watcher, :user => user, :app => watched_app2) | 23 | + sign_in(user = Fabricate(:user)) |
24 | + unwatched_app = Fabricate(:app) | ||
25 | + watched_app1 = Fabricate(:app) | ||
26 | + watched_app2 = Fabricate(:app) | ||
27 | + Fabricate(:user_watcher, :user => user, :app => watched_app1) | ||
28 | + Fabricate(:user_watcher, :user => user, :app => watched_app2) | ||
29 | get :index | 29 | get :index |
30 | assigns(:apps).should include(watched_app1, watched_app2) | 30 | assigns(:apps).should include(watched_app1, watched_app2) |
31 | assigns(:apps).should_not include(unwatched_app) | 31 | assigns(:apps).should_not include(unwatched_app) |
@@ -36,10 +36,10 @@ describe AppsController do | @@ -36,10 +36,10 @@ describe AppsController do | ||
36 | describe "GET /apps/:id" do | 36 | describe "GET /apps/:id" do |
37 | context 'logged in as an admin' do | 37 | context 'logged in as an admin' do |
38 | before(:each) do | 38 | before(:each) do |
39 | - @user = Factory(:admin) | 39 | + @user = Fabricate(:admin) |
40 | sign_in @user | 40 | sign_in @user |
41 | - @app = Factory(:app) | ||
42 | - @problem = Factory(:notice, :err => Factory(:err, :problem => Factory(:problem, :app => @app))).problem | 41 | + @app = Fabricate(:app) |
42 | + @problem = Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => @app))).problem | ||
43 | end | 43 | end |
44 | 44 | ||
45 | it 'finds the app' do | 45 | it 'finds the app' do |
@@ -48,7 +48,7 @@ describe AppsController do | @@ -48,7 +48,7 @@ describe AppsController do | ||
48 | end | 48 | end |
49 | 49 | ||
50 | it "should not raise errors for app with err without notices" do | 50 | it "should not raise errors for app with err without notices" do |
51 | - Factory(:err, :problem => Factory(:problem, :app => @app)) | 51 | + Fabricate(:err, :problem => Fabricate(:problem, :app => @app)) |
52 | lambda { get :show, :id => @app.id }.should_not raise_error | 52 | lambda { get :show, :id => @app.id }.should_not raise_error |
53 | end | 53 | end |
54 | 54 | ||
@@ -60,7 +60,7 @@ describe AppsController do | @@ -60,7 +60,7 @@ describe AppsController do | ||
60 | 60 | ||
61 | context "pagination" do | 61 | context "pagination" do |
62 | before(:each) do | 62 | before(:each) do |
63 | - 35.times { Factory(:err, :problem => Factory(:problem, :app => @app)) } | 63 | + 35.times { Fabricate(:err, :problem => Fabricate(:problem, :app => @app)) } |
64 | end | 64 | end |
65 | 65 | ||
66 | it "should have default per_page value for user" do | 66 | it "should have default per_page value for user" do |
@@ -77,8 +77,8 @@ describe AppsController do | @@ -77,8 +77,8 @@ describe AppsController do | ||
77 | 77 | ||
78 | context 'with resolved errors' do | 78 | context 'with resolved errors' do |
79 | before(:each) do | 79 | before(:each) do |
80 | - resolved_problem = Factory(:problem, :app => @app) | ||
81 | - Factory(:notice, :err => Factory(:err, :problem => resolved_problem)) | 80 | + resolved_problem = Fabricate(:problem, :app => @app) |
81 | + Fabricate(:notice, :err => Fabricate(:err, :problem => resolved_problem)) | ||
82 | resolved_problem.resolve! | 82 | resolved_problem.resolve! |
83 | end | 83 | end |
84 | 84 | ||
@@ -101,7 +101,7 @@ describe AppsController do | @@ -101,7 +101,7 @@ describe AppsController do | ||
101 | before(:each) do | 101 | before(:each) do |
102 | environments = ['production', 'test', 'development', 'staging'] | 102 | environments = ['production', 'test', 'development', 'staging'] |
103 | 20.times do |i| | 103 | 20.times do |i| |
104 | - Factory.create(:problem, :app => @app, :environment => environments[i % environments.length]) | 104 | + Fabricate(:problem, :app => @app, :environment => environments[i % environments.length]) |
105 | end | 105 | end |
106 | end | 106 | end |
107 | 107 | ||
@@ -144,17 +144,17 @@ describe AppsController do | @@ -144,17 +144,17 @@ describe AppsController do | ||
144 | 144 | ||
145 | context 'logged in as a user' do | 145 | context 'logged in as a user' do |
146 | it 'finds the app if the user is watching it' do | 146 | it 'finds the app if the user is watching it' do |
147 | - user = Factory(:user) | ||
148 | - app = Factory(:app) | ||
149 | - watcher = Factory(:user_watcher, :app => app, :user => user) | 147 | + user = Fabricate(:user) |
148 | + app = Fabricate(:app) | ||
149 | + watcher = Fabricate(:user_watcher, :app => app, :user => user) | ||
150 | sign_in user | 150 | sign_in user |
151 | get :show, :id => app.id | 151 | get :show, :id => app.id |
152 | assigns(:app).should == app | 152 | assigns(:app).should == app |
153 | end | 153 | end |
154 | 154 | ||
155 | it 'does not find the app if the user is not watching it' do | 155 | it 'does not find the app if the user is not watching it' do |
156 | - sign_in Factory(:user) | ||
157 | - app = Factory(:app) | 156 | + sign_in Fabricate(:user) |
157 | + app = Fabricate(:app) | ||
158 | lambda { | 158 | lambda { |
159 | get :show, :id => app.id | 159 | get :show, :id => app.id |
160 | }.should raise_error(Mongoid::Errors::DocumentNotFound) | 160 | }.should raise_error(Mongoid::Errors::DocumentNotFound) |
@@ -164,7 +164,7 @@ describe AppsController do | @@ -164,7 +164,7 @@ describe AppsController do | ||
164 | 164 | ||
165 | context 'logged in as an admin' do | 165 | context 'logged in as an admin' do |
166 | before do | 166 | before do |
167 | - sign_in Factory(:admin) | 167 | + sign_in Fabricate(:admin) |
168 | end | 168 | end |
169 | 169 | ||
170 | describe "GET /apps/new" do | 170 | describe "GET /apps/new" do |
@@ -176,7 +176,7 @@ describe AppsController do | @@ -176,7 +176,7 @@ describe AppsController do | ||
176 | end | 176 | end |
177 | 177 | ||
178 | it "should copy attributes from an existing app" do | 178 | it "should copy attributes from an existing app" do |
179 | - @app = Factory(:app, :name => "do not copy", | 179 | + @app = Fabricate(:app, :name => "do not copy", |
180 | :github_url => "github.com/test/example") | 180 | :github_url => "github.com/test/example") |
181 | get :new, :copy_attributes_from => @app.id | 181 | get :new, :copy_attributes_from => @app.id |
182 | assigns(:app).should be_a(App) | 182 | assigns(:app).should be_a(App) |
@@ -188,7 +188,7 @@ describe AppsController do | @@ -188,7 +188,7 @@ describe AppsController do | ||
188 | 188 | ||
189 | describe "GET /apps/:id/edit" do | 189 | describe "GET /apps/:id/edit" do |
190 | it 'finds the correct app' do | 190 | it 'finds the correct app' do |
191 | - app = Factory(:app) | 191 | + app = Fabricate(:app) |
192 | get :edit, :id => app.id | 192 | get :edit, :id => app.id |
193 | assigns(:app).should == app | 193 | assigns(:app).should == app |
194 | end | 194 | end |
@@ -196,7 +196,7 @@ describe AppsController do | @@ -196,7 +196,7 @@ describe AppsController do | ||
196 | 196 | ||
197 | describe "POST /apps" do | 197 | describe "POST /apps" do |
198 | before do | 198 | before do |
199 | - @app = Factory(:app) | 199 | + @app = Fabricate(:app) |
200 | App.stub(:new).and_return(@app) | 200 | App.stub(:new).and_return(@app) |
201 | end | 201 | end |
202 | 202 | ||
@@ -219,7 +219,7 @@ describe AppsController do | @@ -219,7 +219,7 @@ describe AppsController do | ||
219 | 219 | ||
220 | describe "PUT /apps/:id" do | 220 | describe "PUT /apps/:id" do |
221 | before do | 221 | before do |
222 | - @app = Factory(:app) | 222 | + @app = Fabricate(:app) |
223 | end | 223 | end |
224 | 224 | ||
225 | context "when the update is successful" do | 225 | context "when the update is successful" do |
@@ -257,7 +257,7 @@ describe AppsController do | @@ -257,7 +257,7 @@ describe AppsController do | ||
257 | end | 257 | end |
258 | context "failed parsing of CSV" do | 258 | context "failed parsing of CSV" do |
259 | it "should set the default value" do | 259 | it "should set the default value" do |
260 | - @app = Factory(:app, :email_at_notices => [1, 2, 3, 4]) | 260 | + @app = Fabricate(:app, :email_at_notices => [1, 2, 3, 4]) |
261 | put :update, :id => @app.id, :app => { :email_at_notices => 'asdf, -1,0,foobar,gd00,0,abc' } | 261 | put :update, :id => @app.id, :app => { :email_at_notices => 'asdf, -1,0,foobar,gd00,0,abc' } |
262 | @app.reload | 262 | @app.reload |
263 | @app.email_at_notices.should == Errbit::Config.email_at_notices | 263 | @app.email_at_notices.should == Errbit::Config.email_at_notices |
@@ -320,7 +320,7 @@ describe AppsController do | @@ -320,7 +320,7 @@ describe AppsController do | ||
320 | 320 | ||
321 | describe "DELETE /apps/:id" do | 321 | describe "DELETE /apps/:id" do |
322 | before do | 322 | before do |
323 | - @app = Factory(:app) | 323 | + @app = Fabricate(:app) |
324 | App.stub(:find).with(@app.id).and_return(@app) | 324 | App.stub(:find).with(@app.id).and_return(@app) |
325 | end | 325 | end |
326 | 326 |
spec/controllers/deploys_controller_spec.rb
@@ -12,7 +12,7 @@ describe DeploysController do | @@ -12,7 +12,7 @@ describe DeploysController do | ||
12 | 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5', | 12 | 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5', |
13 | 'message' => 'johns first deploy' | 13 | 'message' => 'johns first deploy' |
14 | } | 14 | } |
15 | - @app = Factory(:app_with_watcher, :notify_on_deploys => true, :api_key => 'APIKEY') | 15 | + @app = Fabricate(:app_with_watcher, :notify_on_deploys => true, :api_key => 'APIKEY') |
16 | end | 16 | end |
17 | 17 | ||
18 | it 'finds the app via the api key' do | 18 | it 'finds the app via the api key' do |
@@ -30,7 +30,7 @@ describe DeploysController do | @@ -30,7 +30,7 @@ describe DeploysController do | ||
30 | :revision => '19d77837eef37902cf5df7e4445c85f392a8d0d5', | 30 | :revision => '19d77837eef37902cf5df7e4445c85f392a8d0d5', |
31 | :message => 'johns first deploy' | 31 | :message => 'johns first deploy' |
32 | 32 | ||
33 | - }).and_return(Factory(:deploy)) | 33 | + }).and_return(Fabricate(:deploy)) |
34 | post :create, :deploy => @params, :api_key => 'APIKEY' | 34 | post :create, :deploy => @params, :api_key => 'APIKEY' |
35 | end | 35 | end |
36 | 36 | ||
@@ -45,8 +45,8 @@ describe DeploysController do | @@ -45,8 +45,8 @@ describe DeploysController do | ||
45 | 45 | ||
46 | context "GET #index" do | 46 | context "GET #index" do |
47 | before(:each) do | 47 | before(:each) do |
48 | - @deploy = Factory :deploy | ||
49 | - sign_in Factory(:admin) | 48 | + @deploy = Fabricate :deploy |
49 | + sign_in Fabricate(:admin) | ||
50 | get :index, :app_id => @deploy.app.id | 50 | get :index, :app_id => @deploy.app.id |
51 | end | 51 | end |
52 | 52 |
spec/controllers/errs_controller_spec.rb
@@ -7,17 +7,17 @@ describe ErrsController do | @@ -7,17 +7,17 @@ describe ErrsController do | ||
7 | }, | 7 | }, |
8 | :params => {:app_id => 'dummyid', :id => 'dummyid'} | 8 | :params => {:app_id => 'dummyid', :id => 'dummyid'} |
9 | 9 | ||
10 | - let(:app) { Factory(:app) } | ||
11 | - let(:err) { Factory(:err, :problem => Factory(:problem, :app => app, :environment => "production")) } | 10 | + let(:app) { Fabricate(:app) } |
11 | + let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production")) } | ||
12 | 12 | ||
13 | 13 | ||
14 | describe "GET /errs" do | 14 | describe "GET /errs" do |
15 | render_views | 15 | render_views |
16 | context 'when logged in as an admin' do | 16 | context 'when logged in as an admin' do |
17 | before(:each) do | 17 | before(:each) do |
18 | - @user = Factory(:admin) | 18 | + @user = Fabricate(:admin) |
19 | sign_in @user | 19 | sign_in @user |
20 | - @problem = Factory(:notice, :err => Factory(:err, :problem => Factory(:problem, :app => app, :environment => "production"))).problem | 20 | + @problem = Fabricate(:notice, :err => Fabricate(:err, :problem => Fabricate(:problem, :app => app, :environment => "production"))).problem |
21 | end | 21 | end |
22 | 22 | ||
23 | it "should successfully list errs" do | 23 | it "should successfully list errs" do |
@@ -34,7 +34,7 @@ describe ErrsController do | @@ -34,7 +34,7 @@ describe ErrsController do | ||
34 | 34 | ||
35 | context "pagination" do | 35 | context "pagination" do |
36 | before(:each) do | 36 | before(:each) do |
37 | - 35.times { Factory :err } | 37 | + 35.times { Fabricate :err } |
38 | end | 38 | end |
39 | 39 | ||
40 | it "should have default per_page value for user" do | 40 | it "should have default per_page value for user" do |
@@ -53,7 +53,7 @@ describe ErrsController do | @@ -53,7 +53,7 @@ describe ErrsController do | ||
53 | before(:each) do | 53 | before(:each) do |
54 | environments = ['production', 'test', 'development', 'staging'] | 54 | environments = ['production', 'test', 'development', 'staging'] |
55 | 20.times do |i| | 55 | 20.times do |i| |
56 | - Factory(:problem, :environment => environments[i % environments.length]) | 56 | + Fabricate(:problem, :environment => environments[i % environments.length]) |
57 | end | 57 | end |
58 | end | 58 | end |
59 | 59 | ||
@@ -96,10 +96,10 @@ describe ErrsController do | @@ -96,10 +96,10 @@ describe ErrsController do | ||
96 | 96 | ||
97 | context 'when logged in as a user' do | 97 | context 'when logged in as a user' do |
98 | it 'gets a paginated list of unresolved errs for the users apps' do | 98 | it 'gets a paginated list of unresolved errs for the users apps' do |
99 | - sign_in(user = Factory(:user)) | ||
100 | - unwatched_err = Factory(:err) | ||
101 | - watched_unresolved_err = Factory(:err, :problem => Factory(:problem, :app => Factory(:user_watcher, :user => user).app, :resolved => false)) | ||
102 | - watched_resolved_err = Factory(:err, :problem => Factory(:problem, :app => Factory(:user_watcher, :user => user).app, :resolved => true)) | 99 | + sign_in(user = Fabricate(:user)) |
100 | + unwatched_err = Fabricate(:err) | ||
101 | + watched_unresolved_err = Fabricate(:err, :problem => Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => false)) | ||
102 | + watched_resolved_err = Fabricate(:err, :problem => Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => true)) | ||
103 | get :index | 103 | get :index |
104 | assigns(:problems).should include(watched_unresolved_err.problem) | 104 | assigns(:problems).should include(watched_unresolved_err.problem) |
105 | assigns(:problems).should_not include(unwatched_err.problem, watched_resolved_err.problem) | 105 | assigns(:problems).should_not include(unwatched_err.problem, watched_resolved_err.problem) |
@@ -110,10 +110,10 @@ describe ErrsController do | @@ -110,10 +110,10 @@ describe ErrsController do | ||
110 | describe "GET /errs/all" do | 110 | describe "GET /errs/all" do |
111 | context 'when logged in as an admin' do | 111 | context 'when logged in as an admin' do |
112 | it "gets a paginated list of all errs" do | 112 | it "gets a paginated list of all errs" do |
113 | - sign_in Factory(:admin) | 113 | + sign_in Fabricate(:admin) |
114 | errs = Kaminari.paginate_array((1..30).to_a) | 114 | errs = Kaminari.paginate_array((1..30).to_a) |
115 | - 3.times { errs << Factory(:err).problem } | ||
116 | - 3.times { errs << Factory(:err, :problem => Factory(:problem, :resolved => true)).problem } | 115 | + 3.times { errs << Fabricate(:err).problem } |
116 | + 3.times { errs << Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem } | ||
117 | Problem.should_receive(:ordered).and_return( | 117 | Problem.should_receive(:ordered).and_return( |
118 | mock('proxy', :page => mock('other_proxy', :per => errs)) | 118 | mock('proxy', :page => mock('other_proxy', :per => errs)) |
119 | ) | 119 | ) |
@@ -124,10 +124,10 @@ describe ErrsController do | @@ -124,10 +124,10 @@ describe ErrsController do | ||
124 | 124 | ||
125 | context 'when logged in as a user' do | 125 | context 'when logged in as a user' do |
126 | it 'gets a paginated list of all errs for the users apps' do | 126 | it 'gets a paginated list of all errs for the users apps' do |
127 | - sign_in(user = Factory(:user)) | ||
128 | - unwatched_err = Factory(:problem) | ||
129 | - watched_unresolved_err = Factory(:problem, :app => Factory(:user_watcher, :user => user).app, :resolved => false) | ||
130 | - watched_resolved_err = Factory(:problem, :app => Factory(:user_watcher, :user => user).app, :resolved => true) | 127 | + sign_in(user = Fabricate(:user)) |
128 | + unwatched_err = Fabricate(:problem) | ||
129 | + watched_unresolved_err = Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => false) | ||
130 | + watched_resolved_err = Fabricate(:problem, :app => Fabricate(:user_watcher, :user => user).app, :resolved => true) | ||
131 | get :all | 131 | get :all |
132 | assigns(:problems).should include(watched_resolved_err, watched_unresolved_err) | 132 | assigns(:problems).should include(watched_resolved_err, watched_unresolved_err) |
133 | assigns(:problems).should_not include(unwatched_err) | 133 | assigns(:problems).should_not include(unwatched_err) |
@@ -139,12 +139,12 @@ describe ErrsController do | @@ -139,12 +139,12 @@ describe ErrsController do | ||
139 | render_views | 139 | render_views |
140 | 140 | ||
141 | before do | 141 | before do |
142 | - 3.times { Factory(:notice, :err => err)} | 142 | + 3.times { Fabricate(:notice, :err => err)} |
143 | end | 143 | end |
144 | 144 | ||
145 | context 'when logged in as an admin' do | 145 | context 'when logged in as an admin' do |
146 | before do | 146 | before do |
147 | - sign_in Factory(:admin) | 147 | + sign_in Fabricate(:admin) |
148 | end | 148 | end |
149 | 149 | ||
150 | it "finds the app" do | 150 | it "finds the app" do |
@@ -166,23 +166,23 @@ describe ErrsController do | @@ -166,23 +166,23 @@ describe ErrsController do | ||
166 | let(:button_matcher) { match(/create issue/) } | 166 | let(:button_matcher) { match(/create issue/) } |
167 | 167 | ||
168 | it "should not exist for err's app without issue tracker" do | 168 | it "should not exist for err's app without issue tracker" do |
169 | - err = Factory :err | 169 | + err = Fabricate :err |
170 | get :show, :app_id => err.app.id, :id => err.problem.id | 170 | get :show, :app_id => err.app.id, :id => err.problem.id |
171 | 171 | ||
172 | response.body.should_not button_matcher | 172 | response.body.should_not button_matcher |
173 | end | 173 | end |
174 | 174 | ||
175 | it "should exist for err's app with issue tracker" do | 175 | it "should exist for err's app with issue tracker" do |
176 | - tracker = Factory(:lighthouse_tracker) | ||
177 | - err = Factory(:err, :problem => Factory(:problem, :app => tracker.app)) | 176 | + tracker = Fabricate(:lighthouse_tracker) |
177 | + err = Fabricate(:err, :problem => Fabricate(:problem, :app => tracker.app)) | ||
178 | get :show, :app_id => err.app.id, :id => err.problem.id | 178 | get :show, :app_id => err.app.id, :id => err.problem.id |
179 | 179 | ||
180 | response.body.should button_matcher | 180 | response.body.should button_matcher |
181 | end | 181 | end |
182 | 182 | ||
183 | it "should not exist for err with issue_link" do | 183 | it "should not exist for err with issue_link" do |
184 | - tracker = Factory(:lighthouse_tracker) | ||
185 | - err = Factory(:err, :problem => Factory(:problem, :app => tracker.app, :issue_link => "http://some.host")) | 184 | + tracker = Fabricate(:lighthouse_tracker) |
185 | + err = Fabricate(:err, :problem => Fabricate(:problem, :app => tracker.app, :issue_link => "http://some.host")) | ||
186 | get :show, :app_id => err.app.id, :id => err.problem.id | 186 | get :show, :app_id => err.app.id, :id => err.problem.id |
187 | 187 | ||
188 | response.body.should_not button_matcher | 188 | response.body.should_not button_matcher |
@@ -192,11 +192,11 @@ describe ErrsController do | @@ -192,11 +192,11 @@ describe ErrsController do | ||
192 | 192 | ||
193 | context 'when logged in as a user' do | 193 | context 'when logged in as a user' do |
194 | before do | 194 | before do |
195 | - sign_in(@user = Factory(:user)) | ||
196 | - @unwatched_err = Factory(:err) | ||
197 | - @watched_app = Factory(:app) | ||
198 | - @watcher = Factory(:user_watcher, :user => @user, :app => @watched_app) | ||
199 | - @watched_err = Factory(:err, :problem => Factory(:problem, :app => @watched_app)) | 195 | + sign_in(@user = Fabricate(:user)) |
196 | + @unwatched_err = Fabricate(:err) | ||
197 | + @watched_app = Fabricate(:app) | ||
198 | + @watcher = Fabricate(:user_watcher, :user => @user, :app => @watched_app) | ||
199 | + @watched_err = Fabricate(:err, :problem => Fabricate(:problem, :app => @watched_app)) | ||
200 | end | 200 | end |
201 | 201 | ||
202 | it 'finds the err if the user is watching the app' do | 202 | it 'finds the err if the user is watching the app' do |
@@ -214,9 +214,9 @@ describe ErrsController do | @@ -214,9 +214,9 @@ describe ErrsController do | ||
214 | 214 | ||
215 | describe "PUT /apps/:app_id/errs/:id/resolve" do | 215 | describe "PUT /apps/:app_id/errs/:id/resolve" do |
216 | before do | 216 | before do |
217 | - sign_in Factory(:admin) | 217 | + sign_in Fabricate(:admin) |
218 | 218 | ||
219 | - @problem = Factory(:err) | 219 | + @problem = Fabricate(:err) |
220 | App.stub(:find).with(@problem.app.id).and_return(@problem.app) | 220 | App.stub(:find).with(@problem.app.id).and_return(@problem.app) |
221 | @problem.app.problems.stub(:find).and_return(@problem.problem) | 221 | @problem.app.problems.stub(:find).and_return(@problem.problem) |
222 | @problem.problem.stub(:resolve!) | 222 | @problem.problem.stub(:resolve!) |
@@ -256,13 +256,13 @@ describe ErrsController do | @@ -256,13 +256,13 @@ describe ErrsController do | ||
256 | render_views | 256 | render_views |
257 | 257 | ||
258 | before(:each) do | 258 | before(:each) do |
259 | - sign_in Factory(:admin) | 259 | + sign_in Fabricate(:admin) |
260 | end | 260 | end |
261 | 261 | ||
262 | context "successful issue creation" do | 262 | context "successful issue creation" do |
263 | context "lighthouseapp tracker" do | 263 | context "lighthouseapp tracker" do |
264 | - let(:notice) { Factory :notice } | ||
265 | - let(:tracker) { Factory :lighthouse_tracker, :app => notice.app } | 264 | + let(:notice) { Fabricate :notice } |
265 | + let(:tracker) { Fabricate :lighthouse_tracker, :app => notice.app } | ||
266 | let(:problem) { notice.problem } | 266 | let(:problem) { notice.problem } |
267 | 267 | ||
268 | before(:each) do | 268 | before(:each) do |
@@ -283,7 +283,7 @@ describe ErrsController do | @@ -283,7 +283,7 @@ describe ErrsController do | ||
283 | end | 283 | end |
284 | 284 | ||
285 | context "absent issue tracker" do | 285 | context "absent issue tracker" do |
286 | - let(:problem) { Factory :problem } | 286 | + let(:problem) { Fabricate :problem } |
287 | 287 | ||
288 | before(:each) do | 288 | before(:each) do |
289 | post :create_issue, :app_id => problem.app.id, :id => problem.id | 289 | post :create_issue, :app_id => problem.app.id, :id => problem.id |
@@ -300,8 +300,8 @@ describe ErrsController do | @@ -300,8 +300,8 @@ describe ErrsController do | ||
300 | 300 | ||
301 | context "error during request to a tracker" do | 301 | context "error during request to a tracker" do |
302 | context "lighthouseapp tracker" do | 302 | context "lighthouseapp tracker" do |
303 | - let(:tracker) { Factory :lighthouse_tracker } | ||
304 | - let(:err) { Factory(:err, :problem => Factory(:problem, :app => tracker.app)) } | 303 | + let(:tracker) { Fabricate :lighthouse_tracker } |
304 | + let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :app => tracker.app)) } | ||
305 | 305 | ||
306 | before(:each) do | 306 | before(:each) do |
307 | stub_request(:post, "http://#{tracker.account}.lighthouseapp.com/projects/#{tracker.project_id}/tickets.xml").to_return(:status => 500) | 307 | stub_request(:post, "http://#{tracker.account}.lighthouseapp.com/projects/#{tracker.project_id}/tickets.xml").to_return(:status => 500) |
@@ -322,11 +322,11 @@ describe ErrsController do | @@ -322,11 +322,11 @@ describe ErrsController do | ||
322 | 322 | ||
323 | describe "DELETE /apps/:app_id/errs/:id/unlink_issue" do | 323 | describe "DELETE /apps/:app_id/errs/:id/unlink_issue" do |
324 | before(:each) do | 324 | before(:each) do |
325 | - sign_in Factory(:admin) | 325 | + sign_in Fabricate(:admin) |
326 | end | 326 | end |
327 | 327 | ||
328 | context "err with issue" do | 328 | context "err with issue" do |
329 | - let(:err) { Factory(:err, :problem => Factory(:problem, :issue_link => "http://some.host")) } | 329 | + let(:err) { Fabricate(:err, :problem => Fabricate(:problem, :issue_link => "http://some.host")) } |
330 | 330 | ||
331 | before(:each) do | 331 | before(:each) do |
332 | delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id | 332 | delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id |
@@ -343,7 +343,7 @@ describe ErrsController do | @@ -343,7 +343,7 @@ describe ErrsController do | ||
343 | end | 343 | end |
344 | 344 | ||
345 | context "err without issue" do | 345 | context "err without issue" do |
346 | - let(:err) { Factory :err } | 346 | + let(:err) { Fabricate :err } |
347 | 347 | ||
348 | before(:each) do | 348 | before(:each) do |
349 | delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id | 349 | delete :unlink_issue, :app_id => err.app.id, :id => err.problem.id |
@@ -361,12 +361,12 @@ describe ErrsController do | @@ -361,12 +361,12 @@ describe ErrsController do | ||
361 | render_views | 361 | render_views |
362 | 362 | ||
363 | before(:each) do | 363 | before(:each) do |
364 | - sign_in Factory(:admin) | 364 | + sign_in Fabricate(:admin) |
365 | end | 365 | end |
366 | 366 | ||
367 | context "successful comment creation" do | 367 | context "successful comment creation" do |
368 | - let(:problem) { Factory(:problem) } | ||
369 | - let(:user) { Factory(:user) } | 368 | + let(:problem) { Fabricate(:problem) } |
369 | + let(:user) { Fabricate(:user) } | ||
370 | 370 | ||
371 | before(:each) do | 371 | before(:each) do |
372 | post :create_comment, :app_id => problem.app.id, :id => problem.id, | 372 | post :create_comment, :app_id => problem.app.id, :id => problem.id, |
@@ -388,15 +388,15 @@ describe ErrsController do | @@ -388,15 +388,15 @@ describe ErrsController do | ||
388 | render_views | 388 | render_views |
389 | 389 | ||
390 | before(:each) do | 390 | before(:each) do |
391 | - sign_in Factory(:admin) | 391 | + sign_in Fabricate(:admin) |
392 | end | 392 | end |
393 | 393 | ||
394 | context "successful comment deletion" do | 394 | context "successful comment deletion" do |
395 | - let(:problem) { Factory(:problem_with_comments) } | ||
396 | - let(:comment) { problem.comments.first } | 395 | + let(:problem) { Fabricate(:problem_with_comments) } |
396 | + let(:comment) { problem.reload.comments.first } | ||
397 | 397 | ||
398 | before(:each) do | 398 | before(:each) do |
399 | - delete :destroy_comment, :app_id => problem.app.id, :id => problem.id, :comment_id => comment.id | 399 | + delete :destroy_comment, :app_id => problem.app.id, :id => problem.id, :comment_id => comment.id.to_s |
400 | problem.reload | 400 | problem.reload |
401 | end | 401 | end |
402 | 402 | ||
@@ -412,9 +412,9 @@ describe ErrsController do | @@ -412,9 +412,9 @@ describe ErrsController do | ||
412 | 412 | ||
413 | describe "Bulk Actions" do | 413 | describe "Bulk Actions" do |
414 | before(:each) do | 414 | before(:each) do |
415 | - sign_in Factory(:admin) | ||
416 | - @problem1 = Factory(:err, :problem => Factory(:problem, :resolved => true)).problem | ||
417 | - @problem2 = Factory(:err, :problem => Factory(:problem, :resolved => false)).problem | 415 | + sign_in Fabricate(:admin) |
416 | + @problem1 = Fabricate(:err, :problem => Fabricate(:problem, :resolved => true)).problem | ||
417 | + @problem2 = Fabricate(:err, :problem => Fabricate(:problem, :resolved => false)).problem | ||
418 | end | 418 | end |
419 | 419 | ||
420 | it "should apply to multiple problems" do | 420 | it "should apply to multiple problems" do |
spec/controllers/notices_controller_spec.rb
@@ -5,7 +5,7 @@ describe NoticesController do | @@ -5,7 +5,7 @@ describe NoticesController do | ||
5 | context 'notices API' do | 5 | context 'notices API' do |
6 | before do | 6 | before do |
7 | @xml = Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read | 7 | @xml = Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read |
8 | - @app = Factory(:app_with_watcher) | 8 | + @app = Fabricate(:app_with_watcher) |
9 | App.stub(:find_by_api_key!).and_return(@app) | 9 | App.stub(:find_by_api_key!).and_return(@app) |
10 | @notice = App.report_error!(@xml) | 10 | @notice = App.report_error!(@xml) |
11 | 11 |
spec/controllers/users_controller_spec.rb
@@ -14,16 +14,16 @@ describe UsersController do | @@ -14,16 +14,16 @@ describe UsersController do | ||
14 | 14 | ||
15 | context 'Signed in as a regular user' do | 15 | context 'Signed in as a regular user' do |
16 | before do | 16 | before do |
17 | - sign_in @user = Factory(:user) | 17 | + sign_in @user = Fabricate(:user) |
18 | end | 18 | end |
19 | - | 19 | + |
20 | it "should set a time zone" do | 20 | it "should set a time zone" do |
21 | Time.zone.should.to_s == @user.time_zone | 21 | Time.zone.should.to_s == @user.time_zone |
22 | end | 22 | end |
23 | 23 | ||
24 | context "GET /users/:other_id/edit" do | 24 | context "GET /users/:other_id/edit" do |
25 | it "redirects to the home page" do | 25 | it "redirects to the home page" do |
26 | - get :edit, :id => Factory(:user).id | 26 | + get :edit, :id => Fabricate(:user).id |
27 | response.should redirect_to(root_path) | 27 | response.should redirect_to(root_path) |
28 | end | 28 | end |
29 | end | 29 | end |
@@ -47,7 +47,7 @@ describe UsersController do | @@ -47,7 +47,7 @@ describe UsersController do | ||
47 | 47 | ||
48 | context "PUT /users/:other_id" do | 48 | context "PUT /users/:other_id" do |
49 | it "redirects to the home page" do | 49 | it "redirects to the home page" do |
50 | - put :update, :id => Factory(:user).id | 50 | + put :update, :id => Fabricate(:user).id |
51 | response.should redirect_to(root_path) | 51 | response.should redirect_to(root_path) |
52 | end | 52 | end |
53 | end | 53 | end |
@@ -73,7 +73,7 @@ describe UsersController do | @@ -73,7 +73,7 @@ describe UsersController do | ||
73 | put :update, :id => @user.to_param, :user => {:per_page => 555} | 73 | put :update, :id => @user.to_param, :user => {:per_page => 555} |
74 | @user.reload.per_page.should == 555 | 74 | @user.reload.per_page.should == 555 |
75 | end | 75 | end |
76 | - | 76 | + |
77 | it "should be able to set time_zone option" do | 77 | it "should be able to set time_zone option" do |
78 | put :update, :id => @user.to_param, :user => {:time_zone => "Warsaw"} | 78 | put :update, :id => @user.to_param, :user => {:time_zone => "Warsaw"} |
79 | @user.reload.time_zone.should == "Warsaw" | 79 | @user.reload.time_zone.should == "Warsaw" |
@@ -91,14 +91,14 @@ describe UsersController do | @@ -91,14 +91,14 @@ describe UsersController do | ||
91 | 91 | ||
92 | context 'Signed in as an admin' do | 92 | context 'Signed in as an admin' do |
93 | before do | 93 | before do |
94 | - @user = Factory(:admin) | 94 | + @user = Fabricate(:admin) |
95 | sign_in @user | 95 | sign_in @user |
96 | end | 96 | end |
97 | 97 | ||
98 | context "GET /users" do | 98 | context "GET /users" do |
99 | it 'paginates all users' do | 99 | it 'paginates all users' do |
100 | @user.update_attribute :per_page, 2 | 100 | @user.update_attribute :per_page, 2 |
101 | - users = 3.times { Factory(:user) } | 101 | + users = 3.times { Fabricate(:user) } |
102 | get :index | 102 | get :index |
103 | assigns(:users).to_a.size.should == 2 | 103 | assigns(:users).to_a.size.should == 2 |
104 | end | 104 | end |
@@ -106,7 +106,7 @@ describe UsersController do | @@ -106,7 +106,7 @@ describe UsersController do | ||
106 | 106 | ||
107 | context "GET /users/:id" do | 107 | context "GET /users/:id" do |
108 | it 'finds the user' do | 108 | it 'finds the user' do |
109 | - user = Factory(:user) | 109 | + user = Fabricate(:user) |
110 | get :show, :id => user.id | 110 | get :show, :id => user.id |
111 | assigns(:user).should == user | 111 | assigns(:user).should == user |
112 | end | 112 | end |
@@ -122,7 +122,7 @@ describe UsersController do | @@ -122,7 +122,7 @@ describe UsersController do | ||
122 | 122 | ||
123 | context "GET /users/:id/edit" do | 123 | context "GET /users/:id/edit" do |
124 | it 'finds the user' do | 124 | it 'finds the user' do |
125 | - user = Factory(:user) | 125 | + user = Fabricate(:user) |
126 | get :edit, :id => user.id | 126 | get :edit, :id => user.id |
127 | assigns(:user).should == user | 127 | assigns(:user).should == user |
128 | end | 128 | end |
@@ -131,7 +131,7 @@ describe UsersController do | @@ -131,7 +131,7 @@ describe UsersController do | ||
131 | context "POST /users" do | 131 | context "POST /users" do |
132 | context "when the create is successful" do | 132 | context "when the create is successful" do |
133 | before do | 133 | before do |
134 | - @attrs = {:user => Factory.attributes_for(:user)} | 134 | + @attrs = {:user => Fabricate.attributes_for(:user)} |
135 | end | 135 | end |
136 | 136 | ||
137 | it "sets a message to display" do | 137 | it "sets a message to display" do |
@@ -159,7 +159,7 @@ describe UsersController do | @@ -159,7 +159,7 @@ describe UsersController do | ||
159 | 159 | ||
160 | context "when the create is unsuccessful" do | 160 | context "when the create is unsuccessful" do |
161 | before do | 161 | before do |
162 | - @user = Factory(:user) | 162 | + @user = Fabricate(:user) |
163 | User.should_receive(:new).and_return(@user) | 163 | User.should_receive(:new).and_return(@user) |
164 | @user.should_receive(:save).and_return(false) | 164 | @user.should_receive(:save).and_return(false) |
165 | end | 165 | end |
@@ -174,7 +174,7 @@ describe UsersController do | @@ -174,7 +174,7 @@ describe UsersController do | ||
174 | context "PUT /users/:id" do | 174 | context "PUT /users/:id" do |
175 | context "when the update is successful" do | 175 | context "when the update is successful" do |
176 | before do | 176 | before do |
177 | - @user = Factory(:user) | 177 | + @user = Fabricate(:user) |
178 | end | 178 | end |
179 | 179 | ||
180 | it "sets a message to display" do | 180 | it "sets a message to display" do |
@@ -196,7 +196,7 @@ describe UsersController do | @@ -196,7 +196,7 @@ describe UsersController do | ||
196 | 196 | ||
197 | context "when the update is unsuccessful" do | 197 | context "when the update is unsuccessful" do |
198 | before do | 198 | before do |
199 | - @user = Factory(:user) | 199 | + @user = Fabricate(:user) |
200 | end | 200 | end |
201 | 201 | ||
202 | it "renders the edit page" do | 202 | it "renders the edit page" do |
@@ -208,7 +208,7 @@ describe UsersController do | @@ -208,7 +208,7 @@ describe UsersController do | ||
208 | 208 | ||
209 | context "DELETE /users/:id" do | 209 | context "DELETE /users/:id" do |
210 | before do | 210 | before do |
211 | - @user = Factory(:user) | 211 | + @user = Fabricate(:user) |
212 | end | 212 | end |
213 | 213 | ||
214 | it "destroys the user" do | 214 | it "destroys the user" do |
@@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
1 | +Fabricator(:app) do | ||
2 | + name { sequence(:app_name){|n| "App ##{n}"} } | ||
3 | +end | ||
4 | + | ||
5 | +Fabricator(:app_with_watcher, :from => :app) do | ||
6 | + watchers(:count => 1) { |parent, i| Fabricate.build(:watcher, :app => parent) } | ||
7 | +end | ||
8 | + | ||
9 | +Fabricator(:watcher) do | ||
10 | + app! | ||
11 | + watcher_type 'email' | ||
12 | + email { sequence(:email){|n| "email#{n}@example.com"} } | ||
13 | +end | ||
14 | + | ||
15 | +Fabricator(:user_watcher, :from => :watcher) do | ||
16 | + user! | ||
17 | + watcher_type 'user' | ||
18 | +end | ||
19 | + | ||
20 | +Fabricator(:deploy) do | ||
21 | + app! | ||
22 | + username 'clyde.frog' | ||
23 | + repository 'git@github.com/errbit/errbit.git' | ||
24 | + environment 'production' | ||
25 | + revision { ActiveSupport::SecureRandom.hex(10) } | ||
26 | +end | ||
27 | + |
@@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
1 | +Fabricator :err do | ||
2 | + problem! | ||
3 | + klass! { 'FooError' } | ||
4 | + component 'foo' | ||
5 | + action 'bar' | ||
6 | + environment 'production' | ||
7 | +end | ||
8 | + | ||
9 | +Fabricator :notice do | ||
10 | + err! | ||
11 | + message 'FooError: Too Much Bar' | ||
12 | + backtrace { random_backtrace } | ||
13 | + server_environment { {'environment-name' => 'production'} } | ||
14 | + request {{ 'component' => 'foo', 'action' => 'bar' }} | ||
15 | + notifier {{ 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }} | ||
16 | +end | ||
17 | + | ||
18 | +def random_backtrace | ||
19 | + backtrace = [] | ||
20 | + 99.times {|t| backtrace << { | ||
21 | + 'number' => rand(999), | ||
22 | + 'file' => "/path/to/file/#{ActiveSupport::SecureRandom.hex(4)}.rb", | ||
23 | + 'method' => ActiveSupport.methods.shuffle.first | ||
24 | + }} | ||
25 | + backtrace | ||
26 | +end | ||
27 | + |
@@ -0,0 +1,27 @@ | @@ -0,0 +1,27 @@ | ||
1 | +Fabricator :issue_tracker do | ||
2 | + app! | ||
3 | + api_token { sequence :word } | ||
4 | + project_id { sequence :word } | ||
5 | + account { sequence :word } | ||
6 | + username { sequence :word } | ||
7 | + password { sequence :word } | ||
8 | +end | ||
9 | + | ||
10 | +%w(lighthouse pivotal_labs fogbugz).each do |t| | ||
11 | + Fabricator "#{t}_tracker".to_sym, :from => :issue_tracker, :class_name => "#{t}_tracker".to_sym | ||
12 | +end | ||
13 | + | ||
14 | +Fabricator :redmine_tracker, :from => :issue_tracker, :class_name => :redmine_tracker do | ||
15 | + account 'http://redmine.example.com' | ||
16 | +end | ||
17 | + | ||
18 | +Fabricator :mingle_tracker, :from => :issue_tracker, :class_name => :mingle_tracker do | ||
19 | + account 'https://mingle.example.com' | ||
20 | + ticket_properties 'card_type = Defect, defect_status = open, priority = essential' | ||
21 | +end | ||
22 | + | ||
23 | +Fabricator :github_issues_tracker, :from => :issue_tracker, :class_name => :github_issues_tracker do | ||
24 | + project_id 'test_account/test_project' | ||
25 | + username 'test_username' | ||
26 | +end | ||
27 | + |
spec/factories.rb
spec/factories/app_factories.rb
@@ -1,29 +0,0 @@ | @@ -1,29 +0,0 @@ | ||
1 | -Factory.define(:app) do |p| | ||
2 | - p.name { Factory.next :app_name } | ||
3 | -end | ||
4 | - | ||
5 | -Factory.define(:app_with_watcher, :parent => :app) do |p| | ||
6 | - p.after_create {|app| | ||
7 | - Factory(:watcher, :app => app) | ||
8 | - } | ||
9 | -end | ||
10 | - | ||
11 | -Factory.define(:watcher) do |w| | ||
12 | - w.association :app | ||
13 | - w.watcher_type 'email' | ||
14 | - w.email { Factory.next :email } | ||
15 | -end | ||
16 | - | ||
17 | -Factory.define(:user_watcher, :parent => :watcher) do |w| | ||
18 | - w.watcher_type 'user' | ||
19 | - w.association :user | ||
20 | -end | ||
21 | - | ||
22 | -Factory.define(:deploy) do |d| | ||
23 | - d.app {|p| p.association :app} | ||
24 | - d.username 'clyde.frog' | ||
25 | - d.repository 'git@github.com/errbit/errbit.git' | ||
26 | - d.environment 'production' | ||
27 | - d.revision ActiveSupport::SecureRandom.hex(10) | ||
28 | -end | ||
29 | - |
spec/factories/comment_factories.rb
spec/factories/err_factories.rb
@@ -1,40 +0,0 @@ | @@ -1,40 +0,0 @@ | ||
1 | -Factory.define :problem do |p| | ||
2 | - p.app {|a| a.association :app} | ||
3 | - p.comments [] | ||
4 | -end | ||
5 | - | ||
6 | -Factory.define(:problem_with_comments, :parent => :problem) do |ec| | ||
7 | - ec.comments { (1..3).map { Factory(:comment) } } | ||
8 | -end | ||
9 | - | ||
10 | - | ||
11 | - | ||
12 | -Factory.define :err do |e| | ||
13 | - e.problem {|p| p.association :problem} | ||
14 | - e.klass 'FooError' | ||
15 | - e.component 'foo' | ||
16 | - e.action 'bar' | ||
17 | - e.environment 'production' | ||
18 | -end | ||
19 | - | ||
20 | - | ||
21 | - | ||
22 | -Factory.define :notice do |n| | ||
23 | - n.err {|e| e.association :err} | ||
24 | - n.message 'FooError: Too Much Bar' | ||
25 | - n.backtrace { random_backtrace } | ||
26 | - n.server_environment 'environment-name' => 'production' | ||
27 | - n.request {{ 'component' => 'foo', 'action' => 'bar' }} | ||
28 | - n.notifier 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' | ||
29 | -end | ||
30 | - | ||
31 | -def random_backtrace | ||
32 | - backtrace = [] | ||
33 | - 99.times {|t| backtrace << { | ||
34 | - 'number' => rand(999), | ||
35 | - 'file' => "/path/to/file/#{ActiveSupport::SecureRandom.hex(4)}.rb", | ||
36 | - 'method' => ActiveSupport.methods.shuffle.first | ||
37 | - }} | ||
38 | - backtrace | ||
39 | -end | ||
40 | - |
spec/factories/issue_tracker_factories.rb
@@ -1,27 +0,0 @@ | @@ -1,27 +0,0 @@ | ||
1 | -Factory.define :issue_tracker do |e| | ||
2 | - e.api_token { Factory.next :word } | ||
3 | - e.project_id { Factory.next :word } | ||
4 | - e.association :app, :factory => :app | ||
5 | - e.account { Factory.next :word } | ||
6 | - e.username { Factory.next :word } | ||
7 | - e.password { Factory.next :word } | ||
8 | -end | ||
9 | - | ||
10 | -%w(lighthouse pivotal_labs fogbugz).each do |t| | ||
11 | - Factory.define "#{t}_tracker".to_sym, :parent => :issue_tracker, :class => "#{t}_tracker".to_sym do |e|; end | ||
12 | -end | ||
13 | - | ||
14 | -Factory.define :redmine_tracker, :parent => :issue_tracker, :class => :redmine_tracker do |e| | ||
15 | - e.account 'http://redmine.example.com' | ||
16 | -end | ||
17 | - | ||
18 | -Factory.define :mingle_tracker, :parent => :issue_tracker, :class => :mingle_tracker do |e| | ||
19 | - e.account 'https://mingle.example.com' | ||
20 | - e.ticket_properties 'card_type = Defect, defect_status = open, priority = essential' | ||
21 | -end | ||
22 | - | ||
23 | -Factory.define :github_issues_tracker, :parent => :issue_tracker, :class => :github_issues_tracker do |e| | ||
24 | - e.project_id 'test_account/test_project' | ||
25 | - e.username 'test_username' | ||
26 | -end | ||
27 | - |
spec/factories/user_factories.rb
spec/mailers/mailer_spec.rb
@@ -6,7 +6,7 @@ describe Mailer do | @@ -6,7 +6,7 @@ describe Mailer do | ||
6 | include EmailSpec::Matchers | 6 | include EmailSpec::Matchers |
7 | 7 | ||
8 | before do | 8 | before do |
9 | - @notice = Factory(:notice, :message => "class < ActionController::Base") | 9 | + @notice = Fabricate(:notice, :message => "class < ActionController::Base") |
10 | @email = Mailer.err_notification(@notice).deliver | 10 | @email = Mailer.err_notification(@notice).deliver |
11 | end | 11 | end |
12 | 12 |
spec/models/app_spec.rb
@@ -3,21 +3,21 @@ require 'spec_helper' | @@ -3,21 +3,21 @@ require 'spec_helper' | ||
3 | describe App do | 3 | describe App do |
4 | context 'validations' do | 4 | context 'validations' do |
5 | it 'requires a name' do | 5 | it 'requires a name' do |
6 | - app = Factory.build(:app, :name => nil) | 6 | + app = Fabricate.build(:app, :name => nil) |
7 | app.should_not be_valid | 7 | app.should_not be_valid |
8 | app.errors[:name].should include("can't be blank") | 8 | app.errors[:name].should include("can't be blank") |
9 | end | 9 | end |
10 | 10 | ||
11 | it 'requires unique names' do | 11 | it 'requires unique names' do |
12 | - Factory(:app, :name => 'Errbit') | ||
13 | - app = Factory.build(:app, :name => 'Errbit') | 12 | + Fabricate(:app, :name => 'Errbit') |
13 | + app = Fabricate.build(:app, :name => 'Errbit') | ||
14 | app.should_not be_valid | 14 | app.should_not be_valid |
15 | app.errors[:name].should include('is already taken') | 15 | app.errors[:name].should include('is already taken') |
16 | end | 16 | end |
17 | 17 | ||
18 | it 'requires unique api_keys' do | 18 | it 'requires unique api_keys' do |
19 | - Factory(:app, :api_key => 'APIKEY') | ||
20 | - app = Factory.build(:app, :api_key => 'APIKEY') | 19 | + Fabricate(:app, :api_key => 'APIKEY') |
20 | + app = Fabricate.build(:app, :api_key => 'APIKEY') | ||
21 | app.should_not be_valid | 21 | app.should_not be_valid |
22 | app.errors[:api_key].should include('is already taken') | 22 | app.errors[:api_key].should include('is already taken') |
23 | end | 23 | end |
@@ -26,43 +26,43 @@ describe App do | @@ -26,43 +26,43 @@ describe App do | ||
26 | 26 | ||
27 | context 'being created' do | 27 | context 'being created' do |
28 | it 'generates a new api-key' do | 28 | it 'generates a new api-key' do |
29 | - app = Factory.build(:app) | 29 | + app = Fabricate.build(:app) |
30 | app.api_key.should be_nil | 30 | app.api_key.should be_nil |
31 | app.save | 31 | app.save |
32 | app.api_key.should_not be_nil | 32 | app.api_key.should_not be_nil |
33 | end | 33 | end |
34 | 34 | ||
35 | it 'generates a correct api-key' do | 35 | it 'generates a correct api-key' do |
36 | - app = Factory(:app) | 36 | + app = Fabricate(:app) |
37 | app.api_key.should match(/^[a-f0-9]{32}$/) | 37 | app.api_key.should match(/^[a-f0-9]{32}$/) |
38 | end | 38 | end |
39 | 39 | ||
40 | it 'is fine with blank github urls' do | 40 | it 'is fine with blank github urls' do |
41 | - app = Factory.build(:app, :github_url => "") | 41 | + app = Fabricate.build(:app, :github_url => "") |
42 | app.save | 42 | app.save |
43 | app.github_url.should == "" | 43 | app.github_url.should == "" |
44 | end | 44 | end |
45 | 45 | ||
46 | it 'does not touch https github urls' do | 46 | it 'does not touch https github urls' do |
47 | - app = Factory.build(:app, :github_url => "https://github.com/errbit/errbit") | 47 | + app = Fabricate.build(:app, :github_url => "https://github.com/errbit/errbit") |
48 | app.save | 48 | app.save |
49 | app.github_url.should == "https://github.com/errbit/errbit" | 49 | app.github_url.should == "https://github.com/errbit/errbit" |
50 | end | 50 | end |
51 | 51 | ||
52 | it 'normalizes http github urls' do | 52 | it 'normalizes http github urls' do |
53 | - app = Factory.build(:app, :github_url => "http://github.com/errbit/errbit") | 53 | + app = Fabricate.build(:app, :github_url => "http://github.com/errbit/errbit") |
54 | app.save | 54 | app.save |
55 | app.github_url.should == "https://github.com/errbit/errbit" | 55 | app.github_url.should == "https://github.com/errbit/errbit" |
56 | end | 56 | end |
57 | 57 | ||
58 | it 'normalizes public git repo as a github url' do | 58 | it 'normalizes public git repo as a github url' do |
59 | - app = Factory.build(:app, :github_url => "https://github.com/errbit/errbit.git") | 59 | + app = Fabricate.build(:app, :github_url => "https://github.com/errbit/errbit.git") |
60 | app.save | 60 | app.save |
61 | app.github_url.should == "https://github.com/errbit/errbit" | 61 | app.github_url.should == "https://github.com/errbit/errbit" |
62 | end | 62 | end |
63 | 63 | ||
64 | it 'normalizes private git repo as a github url' do | 64 | it 'normalizes private git repo as a github url' do |
65 | - app = Factory.build(:app, :github_url => "git@github.com:errbit/errbit.git") | 65 | + app = Fabricate.build(:app, :github_url => "git@github.com:errbit/errbit.git") |
66 | app.save | 66 | app.save |
67 | app.github_url.should == "https://github.com/errbit/errbit" | 67 | app.github_url.should == "https://github.com/errbit/errbit" |
68 | end | 68 | end |
@@ -70,28 +70,28 @@ describe App do | @@ -70,28 +70,28 @@ describe App do | ||
70 | 70 | ||
71 | context '#github_url_to_file' do | 71 | context '#github_url_to_file' do |
72 | it 'resolves to full path to file' do | 72 | it 'resolves to full path to file' do |
73 | - app = Factory(:app, :github_url => "https://github.com/errbit/errbit") | 73 | + app = Fabricate(:app, :github_url => "https://github.com/errbit/errbit") |
74 | app.github_url_to_file('/path/to/file').should == "https://github.com/errbit/errbit/blob/master/path/to/file" | 74 | app.github_url_to_file('/path/to/file').should == "https://github.com/errbit/errbit/blob/master/path/to/file" |
75 | end | 75 | end |
76 | end | 76 | end |
77 | 77 | ||
78 | context '#github_url?' do | 78 | context '#github_url?' do |
79 | it 'is true when there is a github_url' do | 79 | it 'is true when there is a github_url' do |
80 | - app = Factory(:app, :github_url => "https://github.com/errbit/errbit") | 80 | + app = Fabricate(:app, :github_url => "https://github.com/errbit/errbit") |
81 | app.github_url?.should be_true | 81 | app.github_url?.should be_true |
82 | end | 82 | end |
83 | 83 | ||
84 | it 'is false when no github_url' do | 84 | it 'is false when no github_url' do |
85 | - app = Factory(:app) | 85 | + app = Fabricate(:app) |
86 | app.github_url?.should be_false | 86 | app.github_url?.should be_false |
87 | end | 87 | end |
88 | end | 88 | end |
89 | 89 | ||
90 | context "notification recipients" do | 90 | context "notification recipients" do |
91 | it "should send notices to either all users, or the configured watchers" do | 91 | it "should send notices to either all users, or the configured watchers" do |
92 | - @app = Factory(:app) | ||
93 | - 3.times { Factory(:user) } | ||
94 | - 5.times { Factory(:watcher, :app => @app) } | 92 | + @app = Fabricate(:app) |
93 | + 3.times { Fabricate(:user) } | ||
94 | + 5.times { Fabricate(:watcher, :app => @app) } | ||
95 | @app.notify_all_users = true | 95 | @app.notify_all_users = true |
96 | @app.notification_recipients.size.should == 3 | 96 | @app.notification_recipients.size.should == 3 |
97 | @app.notify_all_users = false | 97 | @app.notify_all_users = false |
@@ -102,9 +102,9 @@ describe App do | @@ -102,9 +102,9 @@ describe App do | ||
102 | 102 | ||
103 | context "copying attributes from existing app" do | 103 | context "copying attributes from existing app" do |
104 | it "should only copy the necessary fields" do | 104 | it "should only copy the necessary fields" do |
105 | - @app, @copy_app = Factory(:app, :name => "app", :github_url => "url"), | ||
106 | - Factory(:app, :name => "copy_app", :github_url => "copy url") | ||
107 | - @copy_watcher = Factory(:watcher, :email => "copywatcher@example.com", :app => @copy_app) | 105 | + @app, @copy_app = Fabricate(:app, :name => "app", :github_url => "url"), |
106 | + Fabricate(:app, :name => "copy_app", :github_url => "copy url") | ||
107 | + @copy_watcher = Fabricate(:watcher, :email => "copywatcher@example.com", :app => @copy_app) | ||
108 | @app.copy_attributes_from(@copy_app.id) | 108 | @app.copy_attributes_from(@copy_app.id) |
109 | @app.name.should == "app" | 109 | @app.name.should == "app" |
110 | @app.github_url.should == "copy url" | 110 | @app.github_url.should == "copy url" |
@@ -115,7 +115,7 @@ describe App do | @@ -115,7 +115,7 @@ describe App do | ||
115 | 115 | ||
116 | context '#find_or_create_err!' do | 116 | context '#find_or_create_err!' do |
117 | before do | 117 | before do |
118 | - @app = Factory(:app) | 118 | + @app = Fabricate(:app) |
119 | @conditions = { | 119 | @conditions = { |
120 | :klass => 'Whoops', | 120 | :klass => 'Whoops', |
121 | :component => 'Foo', | 121 | :component => 'Foo', |
@@ -125,7 +125,7 @@ describe App do | @@ -125,7 +125,7 @@ describe App do | ||
125 | end | 125 | end |
126 | 126 | ||
127 | it 'returns the correct err if one already exists' do | 127 | it 'returns the correct err if one already exists' do |
128 | - existing = Factory(:err, @conditions.merge(:problem => Factory(:problem, :app => @app))) | 128 | + existing = Fabricate(:err, @conditions.merge(:problem => Fabricate(:problem, :app => @app))) |
129 | Err.where(@conditions).first.should == existing | 129 | Err.where(@conditions).first.should == existing |
130 | @app.find_or_create_err!(@conditions).should == existing | 130 | @app.find_or_create_err!(@conditions).should == existing |
131 | end | 131 | end |
@@ -146,7 +146,7 @@ describe App do | @@ -146,7 +146,7 @@ describe App do | ||
146 | context '#report_error!' do | 146 | context '#report_error!' do |
147 | before do | 147 | before do |
148 | @xml = Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read | 148 | @xml = Rails.root.join('spec','fixtures','hoptoad_test_notice.xml').read |
149 | - @app = Factory(:app, :api_key => 'APIKEY') | 149 | + @app = Fabricate(:app, :api_key => 'APIKEY') |
150 | ErrorReport.any_instance.stub(:fingerprint).and_return('fingerprintdigest') | 150 | ErrorReport.any_instance.stub(:fingerprint).and_return('fingerprintdigest') |
151 | end | 151 | end |
152 | 152 | ||
@@ -163,7 +163,7 @@ describe App do | @@ -163,7 +163,7 @@ describe App do | ||
163 | :action => 'verify', | 163 | :action => 'verify', |
164 | :environment => 'development', | 164 | :environment => 'development', |
165 | :fingerprint => 'fingerprintdigest' | 165 | :fingerprint => 'fingerprintdigest' |
166 | - }).and_return(err = Factory(:err)) | 166 | + }).and_return(err = Fabricate(:err)) |
167 | err.notices.stub(:create!) | 167 | err.notices.stub(:create!) |
168 | @notice = App.report_error!(@xml) | 168 | @notice = App.report_error!(@xml) |
169 | end | 169 | end |
@@ -176,7 +176,7 @@ describe App do | @@ -176,7 +176,7 @@ describe App do | ||
176 | :action => 'verify', | 176 | :action => 'verify', |
177 | :environment => 'development', | 177 | :environment => 'development', |
178 | :fingerprint => 'fingerprintdigest' | 178 | :fingerprint => 'fingerprintdigest' |
179 | - }).and_return(err = Factory(:err, :problem => Factory(:problem, :resolved => true))) | 179 | + }).and_return(err = Fabricate(:err, :problem => Fabricate(:problem, :resolved => true))) |
180 | err.should be_resolved | 180 | err.should be_resolved |
181 | @notice = App.report_error!(@xml) | 181 | @notice = App.report_error!(@xml) |
182 | @notice.err.should == err | 182 | @notice.err.should == err |
spec/models/comment_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper' | @@ -3,7 +3,7 @@ require 'spec_helper' | ||
3 | describe Comment do | 3 | describe Comment do |
4 | context 'validations' do | 4 | context 'validations' do |
5 | it 'should require a body' do | 5 | it 'should require a body' do |
6 | - comment = Factory.build(:comment, :body => nil) | 6 | + comment = Fabricate.build(:comment, :body => nil) |
7 | comment.should_not be_valid | 7 | comment.should_not be_valid |
8 | comment.errors[:body].should include("can't be blank") | 8 | comment.errors[:body].should include("can't be blank") |
9 | end | 9 | end |
spec/models/deploy_spec.rb
@@ -4,13 +4,13 @@ describe Deploy do | @@ -4,13 +4,13 @@ describe Deploy do | ||
4 | 4 | ||
5 | context 'validations' do | 5 | context 'validations' do |
6 | it 'requires a username' do | 6 | it 'requires a username' do |
7 | - deploy = Factory.build(:deploy, :username => nil) | 7 | + deploy = Fabricate.build(:deploy, :username => nil) |
8 | deploy.should_not be_valid | 8 | deploy.should_not be_valid |
9 | deploy.errors[:username].should include("can't be blank") | 9 | deploy.errors[:username].should include("can't be blank") |
10 | end | 10 | end |
11 | 11 | ||
12 | it 'requires an environment' do | 12 | it 'requires an environment' do |
13 | - deploy = Factory.build(:deploy, :environment => nil) | 13 | + deploy = Fabricate.build(:deploy, :environment => nil) |
14 | deploy.should_not be_valid | 14 | deploy.should_not be_valid |
15 | deploy.errors[:environment].should include("can't be blank") | 15 | deploy.errors[:environment].should include("can't be blank") |
16 | end | 16 | end |
@@ -20,24 +20,24 @@ describe Deploy do | @@ -20,24 +20,24 @@ describe Deploy do | ||
20 | it 'should send an email notification' do | 20 | it 'should send an email notification' do |
21 | Mailer.should_receive(:deploy_notification). | 21 | Mailer.should_receive(:deploy_notification). |
22 | and_return(mock('email', :deliver => true)) | 22 | and_return(mock('email', :deliver => true)) |
23 | - Factory(:deploy, :app => Factory(:app_with_watcher, :notify_on_deploys => true)) | 23 | + Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => true)) |
24 | end | 24 | end |
25 | 25 | ||
26 | context 'when the app has resolve_errs_on_deploy set to false' do | 26 | context 'when the app has resolve_errs_on_deploy set to false' do |
27 | it 'should not resolve the apps errs' do | 27 | it 'should not resolve the apps errs' do |
28 | - app = Factory(:app, :resolve_errs_on_deploy => false) | ||
29 | - @problems = 3.times.map{Factory(:err, :problem => Factory(:problem, :resolved => false, :app => app))} | ||
30 | - Factory(:deploy, :app => app) | 28 | + app = Fabricate(:app, :resolve_errs_on_deploy => false) |
29 | + @problems = 3.times.map{Fabricate(:err, :problem => Fabricate(:problem, :resolved => false, :app => app))} | ||
30 | + Fabricate(:deploy, :app => app) | ||
31 | app.reload.problems.none?{|problem| problem.resolved?}.should == true | 31 | app.reload.problems.none?{|problem| problem.resolved?}.should == true |
32 | end | 32 | end |
33 | end | 33 | end |
34 | 34 | ||
35 | context 'when the app has resolve_errs_on_deploy set to true' do | 35 | context 'when the app has resolve_errs_on_deploy set to true' do |
36 | it 'should resolve the apps errs that were in the same environment' do | 36 | it 'should resolve the apps errs that were in the same environment' do |
37 | - app = Factory(:app, :resolve_errs_on_deploy => true) | ||
38 | - @prod_errs = 3.times.map{Factory(:problem, :resolved => false, :app => app, :environment => 'production')} | ||
39 | - @staging_errs = 3.times.map{Factory(:problem, :resolved => false, :app => app, :environment => 'staging')} | ||
40 | - Factory(:deploy, :app => app, :environment => 'production') | 37 | + app = Fabricate(:app, :resolve_errs_on_deploy => true) |
38 | + @prod_errs = 3.times.map{Fabricate(:problem, :resolved => false, :app => app, :environment => 'production')} | ||
39 | + @staging_errs = 3.times.map{Fabricate(:problem, :resolved => false, :app => app, :environment => 'staging')} | ||
40 | + Fabricate(:deploy, :app => app, :environment => 'production') | ||
41 | @prod_errs.all?{|problem| problem.reload.resolved?}.should == true | 41 | @prod_errs.all?{|problem| problem.reload.resolved?}.should == true |
42 | @staging_errs.all?{|problem| problem.reload.resolved?}.should == false | 42 | @staging_errs.all?{|problem| problem.reload.resolved?}.should == false |
43 | end | 43 | end |
@@ -46,7 +46,7 @@ describe Deploy do | @@ -46,7 +46,7 @@ describe Deploy do | ||
46 | context 'when the app has deploy notifications set to false' do | 46 | context 'when the app has deploy notifications set to false' do |
47 | it 'should not send an email notification' do | 47 | it 'should not send an email notification' do |
48 | Mailer.should_not_receive(:deploy_notification) | 48 | Mailer.should_not_receive(:deploy_notification) |
49 | - Factory(:deploy, :app => Factory(:app_with_watcher, :notify_on_deploys => false)) | 49 | + Fabricate(:deploy, :app => Fabricate(:app_with_watcher, :notify_on_deploys => false)) |
50 | end | 50 | end |
51 | end | 51 | end |
52 | end | 52 | end |
spec/models/err_spec.rb
@@ -4,13 +4,13 @@ describe Err do | @@ -4,13 +4,13 @@ describe Err do | ||
4 | 4 | ||
5 | context 'validations' do | 5 | context 'validations' do |
6 | it 'requires a klass' do | 6 | it 'requires a klass' do |
7 | - err = Factory.build(:err, :klass => nil) | 7 | + err = Fabricate.build(:err, :klass => nil) |
8 | err.should_not be_valid | 8 | err.should_not be_valid |
9 | err.errors[:klass].should include("can't be blank") | 9 | err.errors[:klass].should include("can't be blank") |
10 | end | 10 | end |
11 | 11 | ||
12 | it 'requires an environment' do | 12 | it 'requires an environment' do |
13 | - err = Factory.build(:err, :environment => nil) | 13 | + err = Fabricate.build(:err, :environment => nil) |
14 | err.should_not be_valid | 14 | err.should_not be_valid |
15 | err.errors[:environment].should include("can't be blank") | 15 | err.errors[:environment].should include("can't be blank") |
16 | end | 16 | end |
spec/models/issue_trackers/fogbugz_tracker_spec.rb
@@ -2,8 +2,8 @@ require 'spec_helper' | @@ -2,8 +2,8 @@ require 'spec_helper' | ||
2 | 2 | ||
3 | describe FogbugzTracker do | 3 | describe FogbugzTracker do |
4 | it "should create an issue on Fogbugz with problem params, and set issue link for problem" do | 4 | it "should create an issue on Fogbugz with problem params, and set issue link for problem" do |
5 | - notice = Factory :notice | ||
6 | - tracker = Factory :fogbugz_tracker, :app => notice.app | 5 | + notice = Fabricate :notice |
6 | + tracker = Fabricate :fogbugz_tracker, :app => notice.app | ||
7 | problem = notice.problem | 7 | problem = notice.problem |
8 | 8 | ||
9 | number = 123 | 9 | number = 123 |
spec/models/issue_trackers/github_issues_tracker_spec.rb
@@ -2,8 +2,8 @@ require 'spec_helper' | @@ -2,8 +2,8 @@ require 'spec_helper' | ||
2 | 2 | ||
3 | describe GithubIssuesTracker do | 3 | describe GithubIssuesTracker do |
4 | it "should create an issue on Github Issues with problem params, and set issue link for problem" do | 4 | it "should create an issue on Github Issues with problem params, and set issue link for problem" do |
5 | - notice = Factory :notice | ||
6 | - tracker = Factory :github_issues_tracker, :app => notice.app | 5 | + notice = Fabricate :notice |
6 | + tracker = Fabricate :github_issues_tracker, :app => notice.app | ||
7 | problem = notice.problem | 7 | problem = notice.problem |
8 | 8 | ||
9 | number = 5 | 9 | number = 5 |
spec/models/issue_trackers/lighthouse_tracker_spec.rb
@@ -2,8 +2,8 @@ require 'spec_helper' | @@ -2,8 +2,8 @@ require 'spec_helper' | ||
2 | 2 | ||
3 | describe LighthouseTracker do | 3 | describe LighthouseTracker do |
4 | it "should create an issue on Lighthouse with problem params, and set issue link for problem" do | 4 | it "should create an issue on Lighthouse with problem params, and set issue link for problem" do |
5 | - notice = Factory :notice | ||
6 | - tracker = Factory :lighthouse_tracker, :app => notice.app | 5 | + notice = Fabricate :notice |
6 | + tracker = Fabricate :lighthouse_tracker, :app => notice.app | ||
7 | problem = notice.problem | 7 | problem = notice.problem |
8 | 8 | ||
9 | number = 5 | 9 | number = 5 |
spec/models/issue_trackers/mingle_tracker_spec.rb
@@ -2,8 +2,8 @@ require 'spec_helper' | @@ -2,8 +2,8 @@ require 'spec_helper' | ||
2 | 2 | ||
3 | describe MingleTracker do | 3 | describe MingleTracker do |
4 | it "should create an issue on Mingle with problem params, and set issue link for problem" do | 4 | it "should create an issue on Mingle with problem params, and set issue link for problem" do |
5 | - notice = Factory :notice | ||
6 | - tracker = Factory :mingle_tracker, :app => notice.app | 5 | + notice = Fabricate :notice |
6 | + tracker = Fabricate :mingle_tracker, :app => notice.app | ||
7 | problem = notice.problem | 7 | problem = notice.problem |
8 | 8 | ||
9 | number = 5 | 9 | number = 5 |
spec/models/issue_trackers/pivotal_labs_tracker_spec.rb
@@ -2,8 +2,8 @@ require 'spec_helper' | @@ -2,8 +2,8 @@ require 'spec_helper' | ||
2 | 2 | ||
3 | describe PivotalLabsTracker do | 3 | describe PivotalLabsTracker do |
4 | it "should create an issue on Pivotal Tracker with problem params, and set issue link for problem" do | 4 | it "should create an issue on Pivotal Tracker with problem params, and set issue link for problem" do |
5 | - notice = Factory :notice | ||
6 | - tracker = Factory :pivotal_labs_tracker, :app => notice.app, :project_id => 10 | 5 | + notice = Fabricate :notice |
6 | + tracker = Fabricate :pivotal_labs_tracker, :app => notice.app, :project_id => 10 | ||
7 | problem = notice.problem | 7 | problem = notice.problem |
8 | 8 | ||
9 | story_id = 5 | 9 | story_id = 5 |
spec/models/issue_trackers/redmine_tracker_spec.rb
@@ -2,8 +2,8 @@ require 'spec_helper' | @@ -2,8 +2,8 @@ require 'spec_helper' | ||
2 | 2 | ||
3 | describe RedmineTracker do | 3 | describe RedmineTracker do |
4 | it "should create an issue on Redmine with problem params, and set issue link for problem" do | 4 | it "should create an issue on Redmine with problem params, and set issue link for problem" do |
5 | - notice = Factory(:notice) | ||
6 | - tracker = Factory(:redmine_tracker, :app => notice.app, :project_id => 10) | 5 | + notice = Fabricate(:notice) |
6 | + tracker = Fabricate(:redmine_tracker, :app => notice.app, :project_id => 10) | ||
7 | problem = notice.problem | 7 | problem = notice.problem |
8 | number = 5 | 8 | number = 5 |
9 | @issue_link = "#{tracker.account}/issues/#{number}.xml?project_id=#{tracker.project_id}" | 9 | @issue_link = "#{tracker.account}/issues/#{number}.xml?project_id=#{tracker.project_id}" |
@@ -24,7 +24,7 @@ describe RedmineTracker do | @@ -24,7 +24,7 @@ describe RedmineTracker do | ||
24 | end | 24 | end |
25 | 25 | ||
26 | it "should generate a url where a file with line number can be viewed" do | 26 | it "should generate a url where a file with line number can be viewed" do |
27 | - t = Factory(:redmine_tracker, :account => 'http://redmine.example.com', :project_id => "errbit") | 27 | + t = Fabricate(:redmine_tracker, :account => 'http://redmine.example.com', :project_id => "errbit") |
28 | t.url_to_file("/example/file").should == | 28 | t.url_to_file("/example/file").should == |
29 | 'http://redmine.example.com/projects/errbit/repository/annotate/example/file' | 29 | 'http://redmine.example.com/projects/errbit/repository/annotate/example/file' |
30 | t.url_to_file("/example/file", 25).should == | 30 | t.url_to_file("/example/file", 25).should == |
@@ -32,7 +32,7 @@ describe RedmineTracker do | @@ -32,7 +32,7 @@ describe RedmineTracker do | ||
32 | end | 32 | end |
33 | 33 | ||
34 | it "should use the alt_project_id to generate a file/linenumber url, if given" do | 34 | it "should use the alt_project_id to generate a file/linenumber url, if given" do |
35 | - t = Factory(:redmine_tracker, :account => 'http://redmine.example.com', | 35 | + t = Fabricate(:redmine_tracker, :account => 'http://redmine.example.com', |
36 | :project_id => "errbit", | 36 | :project_id => "errbit", |
37 | :alt_project_id => "actual_project") | 37 | :alt_project_id => "actual_project") |
38 | t.url_to_file("/example/file", 25).should == | 38 | t.url_to_file("/example/file", 25).should == |
spec/models/notice_spec.rb
@@ -5,19 +5,19 @@ describe Notice do | @@ -5,19 +5,19 @@ describe Notice do | ||
5 | 5 | ||
6 | context 'validations' do | 6 | context 'validations' do |
7 | it 'requires a backtrace' do | 7 | it 'requires a backtrace' do |
8 | - notice = Factory.build(:notice, :backtrace => nil) | 8 | + notice = Fabricate.build(:notice, :backtrace => nil) |
9 | notice.should_not be_valid | 9 | notice.should_not be_valid |
10 | notice.errors[:backtrace].should include("can't be blank") | 10 | notice.errors[:backtrace].should include("can't be blank") |
11 | end | 11 | end |
12 | 12 | ||
13 | it 'requires the server_environment' do | 13 | it 'requires the server_environment' do |
14 | - notice = Factory.build(:notice, :server_environment => nil) | 14 | + notice = Fabricate.build(:notice, :server_environment => nil) |
15 | notice.should_not be_valid | 15 | notice.should_not be_valid |
16 | notice.errors[:server_environment].should include("can't be blank") | 16 | notice.errors[:server_environment].should include("can't be blank") |
17 | end | 17 | end |
18 | 18 | ||
19 | it 'requires the notifier' do | 19 | it 'requires the notifier' do |
20 | - notice = Factory.build(:notice, :notifier => nil) | 20 | + notice = Fabricate.build(:notice, :notifier => nil) |
21 | notice.should_not be_valid | 21 | notice.should_not be_valid |
22 | notice.errors[:notifier].should include("can't be blank") | 22 | notice.errors[:notifier].should include("can't be blank") |
23 | end | 23 | end |
@@ -61,8 +61,8 @@ describe Notice do | @@ -61,8 +61,8 @@ describe Notice do | ||
61 | end | 61 | end |
62 | [:server_environment, :request, :notifier].each do |key| | 62 | [:server_environment, :request, :notifier].each do |key| |
63 | it "replaces . with . and $ with $ in keys used in #{key}" do | 63 | it "replaces . with . and $ with $ in keys used in #{key}" do |
64 | - err = Factory(:err) | ||
65 | - notice = Factory(:notice, :err => err, key => @hash) | 64 | + err = Fabricate(:err) |
65 | + notice = Fabricate(:notice, :err => err, key => @hash) | ||
66 | notice.send(key).should == @hash_sanitized | 66 | notice.send(key).should == @hash_sanitized |
67 | end | 67 | end |
68 | end | 68 | end |
@@ -71,42 +71,42 @@ describe Notice do | @@ -71,42 +71,42 @@ describe Notice do | ||
71 | 71 | ||
72 | describe "user agent" do | 72 | describe "user agent" do |
73 | it "should be parsed and human-readable" do | 73 | it "should be parsed and human-readable" do |
74 | - notice = Factory.build(:notice, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}}) | 74 | + notice = Fabricate.build(:notice, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}}) |
75 | notice.user_agent.browser.should == 'Chrome' | 75 | notice.user_agent.browser.should == 'Chrome' |
76 | notice.user_agent.version.to_s.should =~ /^10\.0/ | 76 | notice.user_agent.version.to_s.should =~ /^10\.0/ |
77 | end | 77 | end |
78 | 78 | ||
79 | it "should be nil if HTTP_USER_AGENT is blank" do | 79 | it "should be nil if HTTP_USER_AGENT is blank" do |
80 | - notice = Factory.build(:notice) | 80 | + notice = Fabricate.build(:notice) |
81 | notice.user_agent.should == nil | 81 | notice.user_agent.should == nil |
82 | end | 82 | end |
83 | end | 83 | end |
84 | 84 | ||
85 | describe "user agent string" do | 85 | describe "user agent string" do |
86 | it "should be parsed and human-readable" do | 86 | it "should be parsed and human-readable" do |
87 | - notice = Factory.build(:notice, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}}) | 87 | + notice = Fabricate.build(:notice, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}}) |
88 | notice.user_agent_string.should == 'Chrome 10.0.648.204' | 88 | notice.user_agent_string.should == 'Chrome 10.0.648.204' |
89 | end | 89 | end |
90 | 90 | ||
91 | it "should be nil if HTTP_USER_AGENT is blank" do | 91 | it "should be nil if HTTP_USER_AGENT is blank" do |
92 | - notice = Factory.build(:notice) | 92 | + notice = Fabricate.build(:notice) |
93 | notice.user_agent_string.should == "N/A" | 93 | notice.user_agent_string.should == "N/A" |
94 | end | 94 | end |
95 | end | 95 | end |
96 | 96 | ||
97 | describe "host" do | 97 | describe "host" do |
98 | it "returns host if url is valid" do | 98 | it "returns host if url is valid" do |
99 | - notice = Factory.build(:notice, :request => {'url' => "http://example.com/resource/12"}) | 99 | + notice = Fabricate.build(:notice, :request => {'url' => "http://example.com/resource/12"}) |
100 | notice.host.should == 'example.com' | 100 | notice.host.should == 'example.com' |
101 | end | 101 | end |
102 | - | 102 | + |
103 | it "returns 'N/A' when url is not valid" do | 103 | it "returns 'N/A' when url is not valid" do |
104 | - notice = Factory.build(:notice, :request => {'url' => "some string"}) | 104 | + notice = Fabricate.build(:notice, :request => {'url' => "some string"}) |
105 | notice.host.should == 'N/A' | 105 | notice.host.should == 'N/A' |
106 | end | 106 | end |
107 | 107 | ||
108 | it "returns 'N/A' when url is empty" do | 108 | it "returns 'N/A' when url is empty" do |
109 | - notice = Factory.build(:notice, :request => {}) | 109 | + notice = Fabricate.build(:notice, :request => {}) |
110 | notice.host.should == 'N/A' | 110 | notice.host.should == 'N/A' |
111 | end | 111 | end |
112 | 112 | ||
@@ -118,8 +118,8 @@ describe Notice do | @@ -118,8 +118,8 @@ describe Notice do | ||
118 | 118 | ||
119 | before do | 119 | before do |
120 | Errbit::Config.per_app_email_at_notices = true | 120 | Errbit::Config.per_app_email_at_notices = true |
121 | - @app = Factory(:app_with_watcher, :email_at_notices => custom_thresholds) | ||
122 | - @err = Factory(:err, :problem => Factory(:problem, :app => @app)) | 121 | + @app = Fabricate(:app_with_watcher, :email_at_notices => custom_thresholds) |
122 | + @err = Fabricate(:err, :problem => Fabricate(:problem, :app => @app)) | ||
123 | end | 123 | end |
124 | 124 | ||
125 | after do | 125 | after do |
@@ -131,7 +131,7 @@ describe Notice do | @@ -131,7 +131,7 @@ describe Notice do | ||
131 | @err.problem.stub(:notices_count).and_return(threshold) | 131 | @err.problem.stub(:notices_count).and_return(threshold) |
132 | Mailer.should_receive(:err_notification). | 132 | Mailer.should_receive(:err_notification). |
133 | and_return(mock('email', :deliver => true)) | 133 | and_return(mock('email', :deliver => true)) |
134 | - Factory(:notice, :err => @err) | 134 | + Fabricate(:notice, :err => @err) |
135 | end | 135 | end |
136 | end | 136 | end |
137 | end | 137 | end |
@@ -140,8 +140,8 @@ describe Notice do | @@ -140,8 +140,8 @@ describe Notice do | ||
140 | 140 | ||
141 | before do | 141 | before do |
142 | Errbit::Config.per_app_email_at_notices = true | 142 | Errbit::Config.per_app_email_at_notices = true |
143 | - @app = Factory(:app_with_watcher, :email_at_notices => [1]) | ||
144 | - @err = Factory(:err, :problem => Factory(:problem, :app => @app, :notices_count => 100)) | 143 | + @app = Fabricate(:app_with_watcher, :email_at_notices => [1]) |
144 | + @err = Fabricate(:err, :problem => Fabricate(:problem, :app => @app, :notices_count => 100)) | ||
145 | end | 145 | end |
146 | 146 | ||
147 | after do | 147 | after do |
@@ -152,7 +152,7 @@ describe Notice do | @@ -152,7 +152,7 @@ describe Notice do | ||
152 | @err.problem.resolve! | 152 | @err.problem.resolve! |
153 | Mailer.should_receive(:err_notification). | 153 | Mailer.should_receive(:err_notification). |
154 | and_return(mock('email', :deliver => true)) | 154 | and_return(mock('email', :deliver => true)) |
155 | - Factory(:notice, :err => @err) | 155 | + Fabricate(:notice, :err => @err) |
156 | end | 156 | end |
157 | end | 157 | end |
158 | end | 158 | end |
spec/models/problem_spec.rb
1 | require 'spec_helper' | 1 | require 'spec_helper' |
2 | 2 | ||
3 | describe Problem do | 3 | describe Problem do |
4 | + describe "Fabrication" do | ||
5 | + context "Fabricate(:problem)" do | ||
6 | + it 'should be valid' do | ||
7 | + Fabricate.build(:problem).should be_valid | ||
8 | + end | ||
9 | + it 'should have no comment' do | ||
10 | + lambda do | ||
11 | + Fabricate(:problem) | ||
12 | + end.should_not change(Comment, :count) | ||
13 | + end | ||
14 | + end | ||
15 | + | ||
16 | + context "Fabricate(:problem_with_comments)" do | ||
17 | + it 'should be valid' do | ||
18 | + Fabricate.build(:problem_with_comments).should be_valid | ||
19 | + end | ||
20 | + it 'should have 3 comments' do | ||
21 | + lambda do | ||
22 | + Fabricate(:problem_with_comments) | ||
23 | + end.should change(Comment, :count).by(3) | ||
24 | + end | ||
25 | + end | ||
26 | + end | ||
4 | context '#last_notice_at' do | 27 | context '#last_notice_at' do |
5 | it "returns the created_at timestamp of the latest notice" do | 28 | it "returns the created_at timestamp of the latest notice" do |
6 | - err = Factory(:err) | 29 | + err = Fabricate(:err) |
7 | problem = err.problem | 30 | problem = err.problem |
8 | problem.should_not be_nil | 31 | problem.should_not be_nil |
9 | 32 | ||
10 | problem.last_notice_at.should be_nil | 33 | problem.last_notice_at.should be_nil |
11 | 34 | ||
12 | - notice1 = Factory(:notice, :err => err) | 35 | + notice1 = Fabricate(:notice, :err => err) |
13 | problem.last_notice_at.should == notice1.created_at | 36 | problem.last_notice_at.should == notice1.created_at |
14 | 37 | ||
15 | - notice2 = Factory(:notice, :err => err) | 38 | + notice2 = Fabricate(:notice, :err => err) |
16 | problem.last_notice_at.should == notice2.created_at | 39 | problem.last_notice_at.should == notice2.created_at |
17 | end | 40 | end |
18 | end | 41 | end |
@@ -20,10 +43,10 @@ describe Problem do | @@ -20,10 +43,10 @@ describe Problem do | ||
20 | 43 | ||
21 | context '#message' do | 44 | context '#message' do |
22 | it "adding a notice caches its message" do | 45 | it "adding a notice caches its message" do |
23 | - err = Factory(:err) | 46 | + err = Fabricate(:err) |
24 | problem = err.problem | 47 | problem = err.problem |
25 | lambda { | 48 | lambda { |
26 | - Factory(:notice, :err => err, :message => 'ERR 1') | 49 | + Fabricate(:notice, :err => err, :message => 'ERR 1') |
27 | }.should change(problem, :message).from(nil).to('ERR 1') | 50 | }.should change(problem, :message).from(nil).to('ERR 1') |
28 | end | 51 | end |
29 | end | 52 | end |
@@ -32,9 +55,9 @@ describe Problem do | @@ -32,9 +55,9 @@ describe Problem do | ||
32 | context 'being created' do | 55 | context 'being created' do |
33 | context 'when the app has err notifications set to false' do | 56 | context 'when the app has err notifications set to false' do |
34 | it 'should not send an email notification' do | 57 | it 'should not send an email notification' do |
35 | - app = Factory(:app_with_watcher, :notify_on_errs => false) | 58 | + app = Fabricate(:app_with_watcher, :notify_on_errs => false) |
36 | Mailer.should_not_receive(:err_notification) | 59 | Mailer.should_not_receive(:err_notification) |
37 | - Factory(:problem, :app => app) | 60 | + Fabricate(:problem, :app => app) |
38 | end | 61 | end |
39 | end | 62 | end |
40 | end | 63 | end |
@@ -48,7 +71,7 @@ describe Problem do | @@ -48,7 +71,7 @@ describe Problem do | ||
48 | end | 71 | end |
49 | 72 | ||
50 | it "should be able to be resolved" do | 73 | it "should be able to be resolved" do |
51 | - problem = Factory(:problem) | 74 | + problem = Fabricate(:problem) |
52 | problem.should_not be_resolved | 75 | problem.should_not be_resolved |
53 | problem.resolve! | 76 | problem.resolve! |
54 | problem.reload.should be_resolved | 77 | problem.reload.should be_resolved |
@@ -58,14 +81,14 @@ describe Problem do | @@ -58,14 +81,14 @@ describe Problem do | ||
58 | 81 | ||
59 | context "resolve!" do | 82 | context "resolve!" do |
60 | it "marks the problem as resolved" do | 83 | it "marks the problem as resolved" do |
61 | - problem = Factory(:problem) | 84 | + problem = Fabricate(:problem) |
62 | problem.should_not be_resolved | 85 | problem.should_not be_resolved |
63 | problem.resolve! | 86 | problem.resolve! |
64 | problem.should be_resolved | 87 | problem.should be_resolved |
65 | end | 88 | end |
66 | 89 | ||
67 | it "should throw an err if it's not successful" do | 90 | it "should throw an err if it's not successful" do |
68 | - problem = Factory(:problem) | 91 | + problem = Fabricate(:problem) |
69 | problem.should_not be_resolved | 92 | problem.should_not be_resolved |
70 | problem.stub!(:valid?).and_return(false) | 93 | problem.stub!(:valid?).and_return(false) |
71 | problem.should_not be_valid | 94 | problem.should_not be_valid |
@@ -78,8 +101,8 @@ describe Problem do | @@ -78,8 +101,8 @@ describe Problem do | ||
78 | 101 | ||
79 | context ".merge!" do | 102 | context ".merge!" do |
80 | it "collects the Errs from several problems into one and deletes the other problems" do | 103 | it "collects the Errs from several problems into one and deletes the other problems" do |
81 | - problem1 = Factory(:err).problem | ||
82 | - problem2 = Factory(:err).problem | 104 | + problem1 = Fabricate(:err).problem |
105 | + problem2 = Fabricate(:err).problem | ||
83 | problem1.errs.length.should == 1 | 106 | problem1.errs.length.should == 1 |
84 | problem2.errs.length.should == 1 | 107 | problem2.errs.length.should == 1 |
85 | 108 | ||
@@ -93,8 +116,8 @@ describe Problem do | @@ -93,8 +116,8 @@ describe Problem do | ||
93 | 116 | ||
94 | context "#unmerge!" do | 117 | context "#unmerge!" do |
95 | it "creates a separate problem for each err" do | 118 | it "creates a separate problem for each err" do |
96 | - problem1 = Factory(:notice).problem | ||
97 | - problem2 = Factory(:notice).problem | 119 | + problem1 = Fabricate(:notice).problem |
120 | + problem2 = Fabricate(:notice).problem | ||
98 | merged_problem = Problem.merge!(problem1, problem2) | 121 | merged_problem = Problem.merge!(problem1, problem2) |
99 | merged_problem.errs.length.should == 2 | 122 | merged_problem.errs.length.should == 2 |
100 | 123 | ||
@@ -103,7 +126,7 @@ describe Problem do | @@ -103,7 +126,7 @@ describe Problem do | ||
103 | end | 126 | end |
104 | 127 | ||
105 | it "runs smoothly for problem without errs" do | 128 | it "runs smoothly for problem without errs" do |
106 | - expect { Factory(:problem).unmerge! }.not_to raise_error | 129 | + expect { Fabricate(:problem).unmerge! }.not_to raise_error |
107 | end | 130 | end |
108 | end | 131 | end |
109 | 132 | ||
@@ -111,8 +134,8 @@ describe Problem do | @@ -111,8 +134,8 @@ describe Problem do | ||
111 | context "Scopes" do | 134 | context "Scopes" do |
112 | context "resolved" do | 135 | context "resolved" do |
113 | it 'only finds resolved Problems' do | 136 | it 'only finds resolved Problems' do |
114 | - resolved = Factory(:problem, :resolved => true) | ||
115 | - unresolved = Factory(:problem, :resolved => false) | 137 | + resolved = Fabricate(:problem, :resolved => true) |
138 | + unresolved = Fabricate(:problem, :resolved => false) | ||
116 | Problem.resolved.all.should include(resolved) | 139 | Problem.resolved.all.should include(resolved) |
117 | Problem.resolved.all.should_not include(unresolved) | 140 | Problem.resolved.all.should_not include(unresolved) |
118 | end | 141 | end |
@@ -120,8 +143,8 @@ describe Problem do | @@ -120,8 +143,8 @@ describe Problem do | ||
120 | 143 | ||
121 | context "unresolved" do | 144 | context "unresolved" do |
122 | it 'only finds unresolved Problems' do | 145 | it 'only finds unresolved Problems' do |
123 | - resolved = Factory(:problem, :resolved => true) | ||
124 | - unresolved = Factory(:problem, :resolved => false) | 146 | + resolved = Fabricate(:problem, :resolved => true) |
147 | + unresolved = Fabricate(:problem, :resolved => false) | ||
125 | Problem.unresolved.all.should_not include(resolved) | 148 | Problem.unresolved.all.should_not include(resolved) |
126 | Problem.unresolved.all.should include(unresolved) | 149 | Problem.unresolved.all.should include(unresolved) |
127 | end | 150 | end |
@@ -131,9 +154,9 @@ describe Problem do | @@ -131,9 +154,9 @@ describe Problem do | ||
131 | 154 | ||
132 | context "notice counter cache" do | 155 | context "notice counter cache" do |
133 | before do | 156 | before do |
134 | - @app = Factory(:app) | ||
135 | - @problem = Factory(:problem, :app => @app) | ||
136 | - @err = Factory(:err, :problem => @problem) | 157 | + @app = Fabricate(:app) |
158 | + @problem = Fabricate(:problem, :app => @app) | ||
159 | + @err = Fabricate(:err, :problem => @problem) | ||
137 | end | 160 | end |
138 | 161 | ||
139 | it "#notices_count returns 0 by default" do | 162 | it "#notices_count returns 0 by default" do |
@@ -142,12 +165,12 @@ describe Problem do | @@ -142,12 +165,12 @@ describe Problem do | ||
142 | 165 | ||
143 | it "adding a notice increases #notices_count by 1" do | 166 | it "adding a notice increases #notices_count by 1" do |
144 | lambda { | 167 | lambda { |
145 | - Factory(:notice, :err => @err, :message => 'ERR 1') | 168 | + Fabricate(:notice, :err => @err, :message => 'ERR 1') |
146 | }.should change(@problem, :notices_count).from(0).to(1) | 169 | }.should change(@problem, :notices_count).from(0).to(1) |
147 | end | 170 | end |
148 | 171 | ||
149 | it "removing a notice decreases #notices_count by 1" do | 172 | it "removing a notice decreases #notices_count by 1" do |
150 | - notice1 = Factory(:notice, :err => @err, :message => 'ERR 1') | 173 | + notice1 = Fabricate(:notice, :err => @err, :message => 'ERR 1') |
151 | lambda { | 174 | lambda { |
152 | @err.notices.first.destroy | 175 | @err.notices.first.destroy |
153 | @problem.reload | 176 | @problem.reload |
@@ -157,19 +180,18 @@ describe Problem do | @@ -157,19 +180,18 @@ describe Problem do | ||
157 | 180 | ||
158 | 181 | ||
159 | context "#app_name" do | 182 | context "#app_name" do |
160 | - before do | ||
161 | - @app = Factory(:app) | ||
162 | - end | 183 | + let!(:app) { Fabricate(:app) } |
184 | + let!(:problem) { Fabricate(:problem, :app => app) } | ||
185 | + | ||
186 | + before { app.reload } | ||
163 | 187 | ||
164 | it "is set when a problem is created" do | 188 | it "is set when a problem is created" do |
165 | - problem = Factory(:problem, :app => @app) | ||
166 | - assert_equal @app.name, problem.app_name | 189 | + assert_equal app.name, problem.app_name |
167 | end | 190 | end |
168 | 191 | ||
169 | it "is updated when an app is updated" do | 192 | it "is updated when an app is updated" do |
170 | - problem = Factory(:problem, :app => @app) | ||
171 | lambda { | 193 | lambda { |
172 | - @app.update_attributes!(:name => "Bar App") | 194 | + app.update_attributes!(:name => "Bar App") |
173 | problem.reload | 195 | problem.reload |
174 | }.should change(problem, :app_name).to("Bar App") | 196 | }.should change(problem, :app_name).to("Bar App") |
175 | end | 197 | end |
@@ -178,21 +200,21 @@ describe Problem do | @@ -178,21 +200,21 @@ describe Problem do | ||
178 | 200 | ||
179 | context "#last_deploy_at" do | 201 | context "#last_deploy_at" do |
180 | before do | 202 | before do |
181 | - @app = Factory(:app) | 203 | + @app = Fabricate(:app) |
182 | @last_deploy = 10.days.ago.localtime.round(0) | 204 | @last_deploy = 10.days.ago.localtime.round(0) |
183 | - deploy = Factory(:deploy, :app => @app, :created_at => @last_deploy, :environment => "production") | 205 | + deploy = Fabricate(:deploy, :app => @app, :created_at => @last_deploy, :environment => "production") |
184 | end | 206 | end |
185 | 207 | ||
186 | it "is set when a problem is created" do | 208 | it "is set when a problem is created" do |
187 | - problem = Factory(:problem, :app => @app, :environment => "production") | 209 | + problem = Fabricate(:problem, :app => @app, :environment => "production") |
188 | assert_equal @last_deploy, problem.last_deploy_at | 210 | assert_equal @last_deploy, problem.last_deploy_at |
189 | end | 211 | end |
190 | 212 | ||
191 | it "is updated when a deploy is created" do | 213 | it "is updated when a deploy is created" do |
192 | - problem = Factory(:problem, :app => @app, :environment => "production") | 214 | + problem = Fabricate(:problem, :app => @app, :environment => "production") |
193 | next_deploy = 5.minutes.ago.localtime.round(0) | 215 | next_deploy = 5.minutes.ago.localtime.round(0) |
194 | lambda { | 216 | lambda { |
195 | - @deploy = Factory(:deploy, :app => @app, :created_at => next_deploy) | 217 | + @deploy = Fabricate(:deploy, :app => @app, :created_at => next_deploy) |
196 | problem.reload | 218 | problem.reload |
197 | }.should change(problem, :last_deploy_at).from(@last_deploy).to(next_deploy) | 219 | }.should change(problem, :last_deploy_at).from(@last_deploy).to(next_deploy) |
198 | end | 220 | end |
@@ -200,9 +222,9 @@ describe Problem do | @@ -200,9 +222,9 @@ describe Problem do | ||
200 | 222 | ||
201 | context "notice messages cache" do | 223 | context "notice messages cache" do |
202 | before do | 224 | before do |
203 | - @app = Factory(:app) | ||
204 | - @problem = Factory(:problem, :app => @app) | ||
205 | - @err = Factory(:err, :problem => @problem) | 225 | + @app = Fabricate(:app) |
226 | + @problem = Fabricate(:problem, :app => @app) | ||
227 | + @err = Fabricate(:err, :problem => @problem) | ||
206 | end | 228 | end |
207 | 229 | ||
208 | it "#messages should be empty by default" do | 230 | it "#messages should be empty by default" do |
@@ -211,12 +233,12 @@ describe Problem do | @@ -211,12 +233,12 @@ describe Problem do | ||
211 | 233 | ||
212 | it "adding a notice adds a string to #messages" do | 234 | it "adding a notice adds a string to #messages" do |
213 | lambda { | 235 | lambda { |
214 | - Factory(:notice, :err => @err, :message => 'ERR 1') | 236 | + Fabricate(:notice, :err => @err, :message => 'ERR 1') |
215 | }.should change(@problem, :messages).from({}).to({Digest::MD5.hexdigest('ERR 1') => {'value' => 'ERR 1', 'count' => 1}}) | 237 | }.should change(@problem, :messages).from({}).to({Digest::MD5.hexdigest('ERR 1') => {'value' => 'ERR 1', 'count' => 1}}) |
216 | end | 238 | end |
217 | 239 | ||
218 | it "removing a notice removes string from #messages" do | 240 | it "removing a notice removes string from #messages" do |
219 | - notice1 = Factory(:notice, :err => @err, :message => 'ERR 1') | 241 | + notice1 = Fabricate(:notice, :err => @err, :message => 'ERR 1') |
220 | lambda { | 242 | lambda { |
221 | @err.notices.first.destroy | 243 | @err.notices.first.destroy |
222 | @problem.reload | 244 | @problem.reload |
@@ -226,9 +248,9 @@ describe Problem do | @@ -226,9 +248,9 @@ describe Problem do | ||
226 | 248 | ||
227 | context "notice hosts cache" do | 249 | context "notice hosts cache" do |
228 | before do | 250 | before do |
229 | - @app = Factory(:app) | ||
230 | - @problem = Factory(:problem, :app => @app) | ||
231 | - @err = Factory(:err, :problem => @problem) | 251 | + @app = Fabricate(:app) |
252 | + @problem = Fabricate(:problem, :app => @app) | ||
253 | + @err = Fabricate(:err, :problem => @problem) | ||
232 | end | 254 | end |
233 | 255 | ||
234 | it "#hosts should be empty by default" do | 256 | it "#hosts should be empty by default" do |
@@ -237,12 +259,12 @@ describe Problem do | @@ -237,12 +259,12 @@ describe Problem do | ||
237 | 259 | ||
238 | it "adding a notice adds a string to #hosts" do | 260 | it "adding a notice adds a string to #hosts" do |
239 | lambda { | 261 | lambda { |
240 | - Factory(:notice, :err => @err, :request => {'url' => "http://example.com/resource/12"}) | 262 | + Fabricate(:notice, :err => @err, :request => {'url' => "http://example.com/resource/12"}) |
241 | }.should change(@problem, :hosts).from({}).to({Digest::MD5.hexdigest('example.com') => {'value' => 'example.com', 'count' => 1}}) | 263 | }.should change(@problem, :hosts).from({}).to({Digest::MD5.hexdigest('example.com') => {'value' => 'example.com', 'count' => 1}}) |
242 | end | 264 | end |
243 | 265 | ||
244 | it "removing a notice removes string from #hosts" do | 266 | it "removing a notice removes string from #hosts" do |
245 | - notice1 = Factory(:notice, :err => @err, :request => {'url' => "http://example.com/resource/12"}) | 267 | + notice1 = Fabricate(:notice, :err => @err, :request => {'url' => "http://example.com/resource/12"}) |
246 | lambda { | 268 | lambda { |
247 | @err.notices.first.destroy | 269 | @err.notices.first.destroy |
248 | @problem.reload | 270 | @problem.reload |
@@ -252,9 +274,9 @@ describe Problem do | @@ -252,9 +274,9 @@ describe Problem do | ||
252 | 274 | ||
253 | context "notice user_agents cache" do | 275 | context "notice user_agents cache" do |
254 | before do | 276 | before do |
255 | - @app = Factory(:app) | ||
256 | - @problem = Factory(:problem, :app => @app) | ||
257 | - @err = Factory(:err, :problem => @problem) | 277 | + @app = Fabricate(:app) |
278 | + @problem = Fabricate(:problem, :app => @app) | ||
279 | + @err = Fabricate(:err, :problem => @problem) | ||
258 | end | 280 | end |
259 | 281 | ||
260 | it "#user_agents should be empty by default" do | 282 | it "#user_agents should be empty by default" do |
@@ -263,12 +285,12 @@ describe Problem do | @@ -263,12 +285,12 @@ describe Problem do | ||
263 | 285 | ||
264 | it "adding a notice adds a string to #user_agents" do | 286 | it "adding a notice adds a string to #user_agents" do |
265 | lambda { | 287 | lambda { |
266 | - Factory(:notice, :err => @err, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}}) | 288 | + Fabricate(:notice, :err => @err, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}}) |
267 | }.should change(@problem, :user_agents).from({}).to({Digest::MD5.hexdigest('Chrome 10.0.648.204') => {'value' => 'Chrome 10.0.648.204', 'count' => 1}}) | 289 | }.should change(@problem, :user_agents).from({}).to({Digest::MD5.hexdigest('Chrome 10.0.648.204') => {'value' => 'Chrome 10.0.648.204', 'count' => 1}}) |
268 | end | 290 | end |
269 | 291 | ||
270 | it "removing a notice removes string from #user_agents" do | 292 | it "removing a notice removes string from #user_agents" do |
271 | - notice1 = Factory(:notice, :err => @err, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}}) | 293 | + notice1 = Fabricate(:notice, :err => @err, :request => {'cgi-data' => {'HTTP_USER_AGENT' => 'Mozilla/5.0 (Macintosh; U; Intel Mac OS X 10_6_7; en-US) AppleWebKit/534.16 (KHTML, like Gecko) Chrome/10.0.648.204 Safari/534.16'}}) |
272 | lambda { | 294 | lambda { |
273 | @err.notices.first.destroy | 295 | @err.notices.first.destroy |
274 | @problem.reload | 296 | @problem.reload |
@@ -278,8 +300,8 @@ describe Problem do | @@ -278,8 +300,8 @@ describe Problem do | ||
278 | 300 | ||
279 | context "comment counter cache" do | 301 | context "comment counter cache" do |
280 | before do | 302 | before do |
281 | - @app = Factory(:app) | ||
282 | - @problem = Factory(:problem, :app => @app) | 303 | + @app = Fabricate(:app) |
304 | + @problem = Fabricate(:problem, :app => @app) | ||
283 | end | 305 | end |
284 | 306 | ||
285 | it "#comments_count returns 0 by default" do | 307 | it "#comments_count returns 0 by default" do |
@@ -288,12 +310,12 @@ describe Problem do | @@ -288,12 +310,12 @@ describe Problem do | ||
288 | 310 | ||
289 | it "adding a comment increases #comments_count by 1" do | 311 | it "adding a comment increases #comments_count by 1" do |
290 | lambda { | 312 | lambda { |
291 | - Factory(:comment, :err => @problem) | 313 | + Fabricate(:comment, :err => @problem) |
292 | }.should change(@problem, :comments_count).from(0).to(1) | 314 | }.should change(@problem, :comments_count).from(0).to(1) |
293 | end | 315 | end |
294 | 316 | ||
295 | it "removing a comment decreases #comments_count by 1" do | 317 | it "removing a comment decreases #comments_count by 1" do |
296 | - comment1 = Factory(:comment, :err => @problem) | 318 | + comment1 = Fabricate(:comment, :err => @problem) |
297 | lambda { | 319 | lambda { |
298 | @problem.reload.comments.first.destroy | 320 | @problem.reload.comments.first.destroy |
299 | @problem.reload | 321 | @problem.reload |
spec/models/user_spec.rb
@@ -4,7 +4,7 @@ describe User do | @@ -4,7 +4,7 @@ describe User do | ||
4 | 4 | ||
5 | context 'validations' do | 5 | context 'validations' do |
6 | it 'require that a name is present' do | 6 | it 'require that a name is present' do |
7 | - user = Factory.build(:user, :name => nil) | 7 | + user = Fabricate.build(:user, :name => nil) |
8 | user.should_not be_valid | 8 | user.should_not be_valid |
9 | user.errors[:name].should include("can't be blank") | 9 | user.errors[:name].should include("can't be blank") |
10 | end | 10 | end |
@@ -13,26 +13,26 @@ describe User do | @@ -13,26 +13,26 @@ describe User do | ||
13 | context 'Watchers' do | 13 | context 'Watchers' do |
14 | 14 | ||
15 | it 'has many watchers' do | 15 | it 'has many watchers' do |
16 | - user = Factory(:user) | ||
17 | - watcher = Factory(:user_watcher, :user => user) | 16 | + user = Fabricate(:user) |
17 | + watcher = Fabricate(:user_watcher, :user => user) | ||
18 | user.watchers.should_not be_empty | 18 | user.watchers.should_not be_empty |
19 | user.watchers.should include(watcher) | 19 | user.watchers.should include(watcher) |
20 | end | 20 | end |
21 | 21 | ||
22 | it "destroys any related watchers when it is destroyed" do | 22 | it "destroys any related watchers when it is destroyed" do |
23 | - user = Factory(:user) | ||
24 | - app = Factory(:app) | ||
25 | - watcher = Factory(:user_watcher, :app => app, :user => user) | 23 | + user = Fabricate(:user) |
24 | + app = Fabricate(:app) | ||
25 | + watcher = Fabricate(:user_watcher, :app => app, :user => user) | ||
26 | user.watchers.should_not be_empty | 26 | user.watchers.should_not be_empty |
27 | user.destroy | 27 | user.destroy |
28 | app.reload.watchers.should_not include(watcher) | 28 | app.reload.watchers.should_not include(watcher) |
29 | end | 29 | end |
30 | 30 | ||
31 | it "has many apps through watchers" do | 31 | it "has many apps through watchers" do |
32 | - user = Factory(:user) | ||
33 | - watched_app = Factory(:app) | ||
34 | - unwatched_app = Factory(:app) | ||
35 | - watcher = Factory(:user_watcher, :app => watched_app, :user => user) | 32 | + user = Fabricate(:user) |
33 | + watched_app = Fabricate(:app) | ||
34 | + unwatched_app = Fabricate(:app) | ||
35 | + watcher = Fabricate(:user_watcher, :app => watched_app, :user => user) | ||
36 | user.apps.all.should include(watched_app) | 36 | user.apps.all.should include(watched_app) |
37 | user.apps.all.should_not include(unwatched_app) | 37 | user.apps.all.should_not include(unwatched_app) |
38 | end | 38 | end |
spec/models/watcher_spec.rb
@@ -4,7 +4,7 @@ describe Watcher do | @@ -4,7 +4,7 @@ describe Watcher do | ||
4 | 4 | ||
5 | context 'validations' do | 5 | context 'validations' do |
6 | it 'requires an email address or an associated user' do | 6 | it 'requires an email address or an associated user' do |
7 | - watcher = Factory.build(:watcher, :email => nil, :user => nil) | 7 | + watcher = Fabricate.build(:watcher, :email => nil, :user => nil) |
8 | watcher.should_not be_valid | 8 | watcher.should_not be_valid |
9 | watcher.errors[:base].should include("You must specify either a user or an email address") | 9 | watcher.errors[:base].should include("You must specify either a user or an email address") |
10 | 10 | ||
@@ -14,7 +14,7 @@ describe Watcher do | @@ -14,7 +14,7 @@ describe Watcher do | ||
14 | watcher.email = nil | 14 | watcher.email = nil |
15 | watcher.should_not be_valid | 15 | watcher.should_not be_valid |
16 | 16 | ||
17 | - watcher.user = Factory(:user) | 17 | + watcher.user = Fabricate(:user) |
18 | watcher.watcher_type = 'user' | 18 | watcher.watcher_type = 'user' |
19 | watcher.should be_valid | 19 | watcher.should be_valid |
20 | end | 20 | end |
@@ -22,13 +22,13 @@ describe Watcher do | @@ -22,13 +22,13 @@ describe Watcher do | ||
22 | 22 | ||
23 | context 'address' do | 23 | context 'address' do |
24 | it "returns the user's email address if there is a user" do | 24 | it "returns the user's email address if there is a user" do |
25 | - user = Factory(:user, :email => 'foo@bar.com') | ||
26 | - watcher = Factory(:user_watcher, :user => user) | 25 | + user = Fabricate(:user, :email => 'foo@bar.com') |
26 | + watcher = Fabricate(:user_watcher, :user => user) | ||
27 | watcher.address.should == 'foo@bar.com' | 27 | watcher.address.should == 'foo@bar.com' |
28 | end | 28 | end |
29 | 29 | ||
30 | it "returns the email if there is no user" do | 30 | it "returns the email if there is no user" do |
31 | - watcher = Factory(:watcher, :email => 'widgets@acme.com') | 31 | + watcher = Fabricate(:watcher, :email => 'widgets@acme.com') |
32 | watcher.address.should == 'widgets@acme.com' | 32 | watcher.address.should == 'widgets@acme.com' |
33 | end | 33 | end |
34 | end | 34 | end |
spec/spec_helper.rb
@@ -10,6 +10,10 @@ require 'webmock/rspec' | @@ -10,6 +10,10 @@ require 'webmock/rspec' | ||
10 | # in ./support/ and its subdirectories. | 10 | # in ./support/ and its subdirectories. |
11 | Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} | 11 | Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each {|f| require f} |
12 | 12 | ||
13 | +Fabrication.configure do |config| | ||
14 | + fabricator_dir = "spec/fabricators" | ||
15 | +end | ||
16 | + | ||
13 | RSpec.configure do |config| | 17 | RSpec.configure do |config| |
14 | config.mock_with :rspec | 18 | config.mock_with :rspec |
15 | config.include Devise::TestHelpers, :type => :controller | 19 | config.include Devise::TestHelpers, :type => :controller |
spec/support/macros.rb
@@ -45,7 +45,7 @@ def it_requires_admin_privileges(options = {}) | @@ -45,7 +45,7 @@ def it_requires_admin_privileges(options = {}) | ||
45 | context 'when signed in as a regular user' do | 45 | context 'when signed in as a regular user' do |
46 | before do | 46 | before do |
47 | sign_out :user | 47 | sign_out :user |
48 | - sign_in Factory(:user) | 48 | + sign_in Fabricate(:user) |
49 | end | 49 | end |
50 | 50 | ||
51 | options[:for].each do |action, method| | 51 | options[:for].each do |action, method| |
spec/views/apps/index.html.haml_spec.rb
@@ -2,9 +2,9 @@ require 'spec_helper' | @@ -2,9 +2,9 @@ require 'spec_helper' | ||
2 | 2 | ||
3 | describe "apps/index.html.haml" do | 3 | describe "apps/index.html.haml" do |
4 | before do | 4 | before do |
5 | - app = Factory(:app, :deploys => [Factory(:deploy, :revision => "123456789abcdef")]) | 5 | + app = Fabricate(:app, :deploys => [Fabricate(:deploy, :revision => "123456789abcdef")]) |
6 | assign :apps, [app] | 6 | assign :apps, [app] |
7 | - controller.stub(:current_user) { Factory(:user) } | 7 | + controller.stub(:current_user) { Fabricate(:user) } |
8 | end | 8 | end |
9 | 9 | ||
10 | describe "deploy column" do | 10 | describe "deploy column" do |
spec/views/errs/show.html.haml_spec.rb
@@ -2,15 +2,15 @@ require 'spec_helper' | @@ -2,15 +2,15 @@ require 'spec_helper' | ||
2 | 2 | ||
3 | describe "errs/show.html.haml" do | 3 | describe "errs/show.html.haml" do |
4 | before do | 4 | before do |
5 | - err = Factory(:err) | 5 | + err = Fabricate(:err) |
6 | problem = err.problem | 6 | problem = err.problem |
7 | - comment = Factory(:comment) | 7 | + comment = Fabricate(:comment) |
8 | assign :problem, problem | 8 | assign :problem, problem |
9 | assign :comment, comment | 9 | assign :comment, comment |
10 | assign :app, problem.app | 10 | assign :app, problem.app |
11 | assign :notices, err.notices.page(1).per(1) | 11 | assign :notices, err.notices.page(1).per(1) |
12 | assign :notice, err.notices.first | 12 | assign :notice, err.notices.first |
13 | - controller.stub(:current_user) { Factory(:user) } | 13 | + controller.stub(:current_user) { Fabricate(:user) } |
14 | end | 14 | end |
15 | 15 | ||
16 | describe "content_for :action_bar" do | 16 | describe "content_for :action_bar" do |
@@ -46,7 +46,7 @@ describe "errs/show.html.haml" do | @@ -46,7 +46,7 @@ describe "errs/show.html.haml" do | ||
46 | end | 46 | end |
47 | 47 | ||
48 | it 'should display comments and new comment form when no issue tracker' do | 48 | it 'should display comments and new comment form when no issue tracker' do |
49 | - problem = Factory(:problem_with_comments) | 49 | + problem = Fabricate(:problem_with_comments) |
50 | assign :problem, problem | 50 | assign :problem, problem |
51 | assign :app, problem.app | 51 | assign :app, problem.app |
52 | render | 52 | render |
@@ -63,14 +63,15 @@ describe "errs/show.html.haml" do | @@ -63,14 +63,15 @@ describe "errs/show.html.haml" do | ||
63 | end | 63 | end |
64 | 64 | ||
65 | it 'should not display the comments section' do | 65 | it 'should not display the comments section' do |
66 | - problem = Factory(:problem) | 66 | + problem = Fabricate(:problem) |
67 | with_issue_tracker(problem) | 67 | with_issue_tracker(problem) |
68 | render | 68 | render |
69 | view.instance_variable_get(:@_content_for)[:comments].should be_blank | 69 | view.instance_variable_get(:@_content_for)[:comments].should be_blank |
70 | end | 70 | end |
71 | 71 | ||
72 | it 'should display existing comments' do | 72 | it 'should display existing comments' do |
73 | - problem = Factory(:problem_with_comments) | 73 | + problem = Fabricate(:problem_with_comments) |
74 | + problem.reload | ||
74 | with_issue_tracker(problem) | 75 | with_issue_tracker(problem) |
75 | render | 76 | render |
76 | comments_section = String.new(view.instance_variable_get(:@_content_for)[:comments]) | 77 | comments_section = String.new(view.instance_variable_get(:@_content_for)[:comments]) |
spec/views/notices/_backtrace.html.haml_spec.rb
@@ -3,7 +3,7 @@ require 'spec_helper' | @@ -3,7 +3,7 @@ require 'spec_helper' | ||
3 | describe "notices/_backtrace.html.haml" do | 3 | describe "notices/_backtrace.html.haml" do |
4 | describe 'missing file in backtrace' do | 4 | describe 'missing file in backtrace' do |
5 | before do | 5 | before do |
6 | - @notice = Factory(:notice, :backtrace => [{ | 6 | + @notice = Fabricate(:notice, :backtrace => [{ |
7 | 'number' => rand(999), | 7 | 'number' => rand(999), |
8 | 'file' => nil, | 8 | 'file' => nil, |
9 | 'method' => ActiveSupport.methods.shuffle.first | 9 | 'method' => ActiveSupport.methods.shuffle.first |