Commit 1c9fab7e91a2bcee251ba05fa55758dc4e2d0523

Authored by Cyril Mougel
1 parent 396c3388
Exists in master and in 1 other branch production

Upgrade fabrication gem to 2.8.1 version

Gemfile
... ... @@ -20,8 +20,7 @@ gem 'strong_parameters'
20 20 gem 'actionmailer_inline_css'
21 21 gem 'kaminari', '>= 0.14.1'
22 22 gem 'rack-ssl-enforcer', :require => false
23   -# fabrication 1.3.0 is last supporting ruby 1.8. Update when stop supporting this version too
24   -gem 'fabrication', "~> 1.3.0" # Used for both tests and demo data
  23 +gem 'fabrication'
25 24 gem 'rails_autolink'
26 25 # Please don't update hoptoad_notifier to airbrake.
27 26 # It's for internal use only, and we monkeypatch certain methods
... ...
Gemfile.lock
... ... @@ -109,7 +109,7 @@ GEM
109 109 mail (~> 2.2)
110 110 erubis (2.7.0)
111 111 execjs (2.0.1)
112   - fabrication (1.3.2)
  112 + fabrication (2.8.1)
113 113 faraday (0.8.8)
114 114 multipart-post (~> 1.2.0)
115 115 faraday_middleware (0.9.0)
... ... @@ -404,7 +404,7 @@ DEPENDENCIES
404 404 devise (~> 2.2.1)
405 405 email_spec
406 406 execjs
407   - fabrication (~> 1.3.0)
  407 + fabrication
408 408 flowdock
409 409 foreman
410 410 gitlab!
... ...
app/models/backtrace.rb
... ... @@ -19,7 +19,7 @@ class Backtrace
19 19 end
20 20  
21 21 def similar
22   - Backtrace.find_by(:fingerprint => fingerprint) rescue nil
  22 + Backtrace.where(:fingerprint => fingerprint).first
23 23 end
24 24  
25 25 def raw=(raw)
... ...
spec/fabricators/app_fabricator.rb
... ... @@ -10,18 +10,18 @@ Fabricator(:app_with_watcher, :from => :app) do
10 10 end
11 11  
12 12 Fabricator(:watcher) do
13   - app!
  13 + app
14 14 watcher_type 'email'
15 15 email { sequence(:email){|n| "email#{n}@example.com"} }
16 16 end
17 17  
18 18 Fabricator(:user_watcher, :from => :watcher) do
19   - user!
  19 + user
20 20 watcher_type 'user'
21 21 end
22 22  
23 23 Fabricator(:deploy) do
24   - app!
  24 + app
25 25 username 'clyde.frog'
26 26 repository 'git@github.com/errbit/errbit.git'
27 27 environment 'production'
... ...
spec/fabricators/comment_fabricator.rb
1 1 Fabricator :comment do
2   - user!
  2 + user
3 3 body 'Test comment'
4   - err!(:fabricator => :problem)
  4 + err(:fabricator => :problem)
5 5 end
6 6  
... ...
spec/fabricators/err_fabricator.rb
1 1 Fabricator :err do
2   - problem!
  2 + problem
3 3 fingerprint 'some-finger-print'
4 4 end
5 5  
6 6 Fabricator :notice do
7   - err!
  7 + err
8 8 message 'FooError: Too Much Bar'
9   - backtrace!
  9 + backtrace
10 10 server_environment { {'environment-name' => 'production'} }
11 11 request {{ 'component' => 'foo', 'action' => 'bar' }}
12 12 notifier {{ 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }}
13 13 end
14 14  
15 15 Fabricator :backtrace do
16   - fingerprint "fingerprint"
17 16 lines(:count => 99) { Fabricate.build(:backtrace_line) }
18 17 end
19 18  
... ...
spec/fabricators/issue_tracker_fabricator.rb
1 1 Fabricator :issue_tracker do
2   - app!
  2 + app
3 3 api_token { sequence :word }
4 4 project_id { sequence :word }
5 5 account { sequence :word }
... ...
spec/fabricators/notification_service_fabricator.rb
1 1 Fabricator :notification_service do
2   - app!
  2 + app
3 3 room_id { sequence :word }
4 4 api_token { sequence :word }
5 5 subdomain { sequence :word }
... ...
spec/fabricators/problem_fabricator.rb
1 1 Fabricator(:problem) do
2   - app! { Fabricate(:app) }
  2 + app { Fabricate(:app) }
3 3 comments { [] }
4 4 error_class 'FooError'
5 5 environment 'production'
... ...
spec/models/app_spec.rb
... ... @@ -174,8 +174,11 @@ describe App do
174 174 }
175 175  
176 176 it 'returns the correct err if one already exists' do
177   - existing = Fabricate(:err, conditions.merge(:problem => Fabricate(:problem, :app => app)))
178   - Err.where(conditions).first.should == existing
  177 + existing = Fabricate(:err, {
  178 + :problem => Fabricate(:problem, :app => app),
  179 + :fingerprint => conditions[:fingerprint]
  180 + })
  181 + Err.where(:fingerprint => conditions[:fingerprint]).first.should == existing
179 182 app.find_or_create_err!(conditions).should == existing
180 183 end
181 184  
... ...
spec/models/backtrace_spec.rb
... ... @@ -11,7 +11,12 @@ describe Backtrace do
11 11 end
12 12  
13 13 context "similar backtrace exist" do
14   - let!(:similar_backtrace) { Fabricate(:backtrace, :fingerprint => fingerprint) }
  14 + let!(:similar_backtrace) {
  15 + b = Fabricate(:backtrace)
  16 + b.fingerprint = fingerprint
  17 + b.save!
  18 + b
  19 + }
15 20 let(:fingerprint) { "fingerprint" }
16 21  
17 22 before { subject.stub(:fingerprint => fingerprint) }
... ...
spec/models/err_spec.rb
... ... @@ -10,7 +10,7 @@ describe Err do
10 10 end
11 11  
12 12 it 'requires a problem' do
13   - err = Fabricate.build(:err, :problem_id => nil)
  13 + err = Fabricate.build(:err, :problem_id => nil, :problem => nil)
14 14 err.should_not be_valid
15 15 err.errors[:problem_id].should include("can't be blank")
16 16 end
... ...
spec/models/fabricators_spec.rb
1 1 require 'spec_helper'
2 2  
3   -Fabrication::Config.fabricator_dir.each do |folder|
  3 +Fabrication::Config.fabricator_path.each do |folder|
4 4 Dir.glob(File.join(Rails.root, folder, '**', '*.rb')).each do |file|
5 5 require file
6 6 end
... ... @@ -8,7 +8,7 @@ end
8 8  
9 9 describe "Fabrication" do
10 10 #TODO : when 1.8.7 drop support se directly Symbol#sort
11   - Fabrication::Fabricator.schematics.keys.sort_by(&:to_s).each do |fabricator_name|
  11 + Fabrication.manager.schematics.keys.sort.each do |fabricator_name|
12 12 context "Fabricate(:#{fabricator_name})" do
13 13 subject { Fabricate.build(fabricator_name) }
14 14  
... ...