From 1c9fab7e91a2bcee251ba05fa55758dc4e2d0523 Mon Sep 17 00:00:00 2001 From: Cyril Mougel Date: Wed, 25 Sep 2013 18:03:39 +0200 Subject: [PATCH] Upgrade fabrication gem to 2.8.1 version --- Gemfile | 3 +-- Gemfile.lock | 4 ++-- app/models/backtrace.rb | 2 +- spec/fabricators/app_fabricator.rb | 6 +++--- spec/fabricators/comment_fabricator.rb | 4 ++-- spec/fabricators/err_fabricator.rb | 7 +++---- spec/fabricators/issue_tracker_fabricator.rb | 2 +- spec/fabricators/notification_service_fabricator.rb | 2 +- spec/fabricators/problem_fabricator.rb | 2 +- spec/models/app_spec.rb | 7 +++++-- spec/models/backtrace_spec.rb | 7 ++++++- spec/models/err_spec.rb | 2 +- spec/models/fabricators_spec.rb | 4 ++-- 13 files changed, 29 insertions(+), 23 deletions(-) diff --git a/Gemfile b/Gemfile index 03b24b518..12a46f1a5 100644 --- a/Gemfile +++ b/Gemfile @@ -20,8 +20,7 @@ gem 'strong_parameters' gem 'actionmailer_inline_css' gem 'kaminari', '>= 0.14.1' gem 'rack-ssl-enforcer', :require => false -# fabrication 1.3.0 is last supporting ruby 1.8. Update when stop supporting this version too -gem 'fabrication', "~> 1.3.0" # Used for both tests and demo data +gem 'fabrication' gem 'rails_autolink' # Please don't update hoptoad_notifier to airbrake. # It's for internal use only, and we monkeypatch certain methods diff --git a/Gemfile.lock b/Gemfile.lock index a197490dc..55c21bf84 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -109,7 +109,7 @@ GEM mail (~> 2.2) erubis (2.7.0) execjs (2.0.1) - fabrication (1.3.2) + fabrication (2.8.1) faraday (0.8.8) multipart-post (~> 1.2.0) faraday_middleware (0.9.0) @@ -404,7 +404,7 @@ DEPENDENCIES devise (~> 2.2.1) email_spec execjs - fabrication (~> 1.3.0) + fabrication flowdock foreman gitlab! diff --git a/app/models/backtrace.rb b/app/models/backtrace.rb index b417aa17d..bdebee793 100644 --- a/app/models/backtrace.rb +++ b/app/models/backtrace.rb @@ -19,7 +19,7 @@ def self.find_or_create(attributes = {}) end def similar - Backtrace.find_by(:fingerprint => fingerprint) rescue nil + Backtrace.where(:fingerprint => fingerprint).first end def raw=(raw) diff --git a/spec/fabricators/app_fabricator.rb b/spec/fabricators/app_fabricator.rb index 59acba861..fe2b8590e 100644 --- a/spec/fabricators/app_fabricator.rb +++ b/spec/fabricators/app_fabricator.rb @@ -10,18 +10,18 @@ end Fabricator(:watcher) do - app! + app watcher_type 'email' email { sequence(:email){|n| "email#{n}@example.com"} } end Fabricator(:user_watcher, :from => :watcher) do - user! + user watcher_type 'user' end Fabricator(:deploy) do - app! + app username 'clyde.frog' repository 'git@github.com/errbit/errbit.git' environment 'production' diff --git a/spec/fabricators/comment_fabricator.rb b/spec/fabricators/comment_fabricator.rb index b8d496f8f..e96d1dede 100644 --- a/spec/fabricators/comment_fabricator.rb +++ b/spec/fabricators/comment_fabricator.rb @@ -1,6 +1,6 @@ Fabricator :comment do - user! + user body 'Test comment' - err!(:fabricator => :problem) + err(:fabricator => :problem) end diff --git a/spec/fabricators/err_fabricator.rb b/spec/fabricators/err_fabricator.rb index e1d87d347..c50e392d1 100644 --- a/spec/fabricators/err_fabricator.rb +++ b/spec/fabricators/err_fabricator.rb @@ -1,19 +1,18 @@ Fabricator :err do - problem! + problem fingerprint 'some-finger-print' end Fabricator :notice do - err! + err message 'FooError: Too Much Bar' - backtrace! + backtrace server_environment { {'environment-name' => 'production'} } request {{ 'component' => 'foo', 'action' => 'bar' }} notifier {{ 'name' => 'Notifier', 'version' => '1', 'url' => 'http://toad.com' }} end Fabricator :backtrace do - fingerprint "fingerprint" lines(:count => 99) { Fabricate.build(:backtrace_line) } end diff --git a/spec/fabricators/issue_tracker_fabricator.rb b/spec/fabricators/issue_tracker_fabricator.rb index 425087bbd..8b752ae82 100644 --- a/spec/fabricators/issue_tracker_fabricator.rb +++ b/spec/fabricators/issue_tracker_fabricator.rb @@ -1,5 +1,5 @@ Fabricator :issue_tracker do - app! + app api_token { sequence :word } project_id { sequence :word } account { sequence :word } diff --git a/spec/fabricators/notification_service_fabricator.rb b/spec/fabricators/notification_service_fabricator.rb index 5814d482e..bf11b6d52 100644 --- a/spec/fabricators/notification_service_fabricator.rb +++ b/spec/fabricators/notification_service_fabricator.rb @@ -1,5 +1,5 @@ Fabricator :notification_service do - app! + app room_id { sequence :word } api_token { sequence :word } subdomain { sequence :word } diff --git a/spec/fabricators/problem_fabricator.rb b/spec/fabricators/problem_fabricator.rb index 6cba73840..4ef1de0b0 100644 --- a/spec/fabricators/problem_fabricator.rb +++ b/spec/fabricators/problem_fabricator.rb @@ -1,5 +1,5 @@ Fabricator(:problem) do - app! { Fabricate(:app) } + app { Fabricate(:app) } comments { [] } error_class 'FooError' environment 'production' diff --git a/spec/models/app_spec.rb b/spec/models/app_spec.rb index ab766fe19..b145731c1 100644 --- a/spec/models/app_spec.rb +++ b/spec/models/app_spec.rb @@ -174,8 +174,11 @@ } it 'returns the correct err if one already exists' do - existing = Fabricate(:err, conditions.merge(:problem => Fabricate(:problem, :app => app))) - Err.where(conditions).first.should == existing + existing = Fabricate(:err, { + :problem => Fabricate(:problem, :app => app), + :fingerprint => conditions[:fingerprint] + }) + Err.where(:fingerprint => conditions[:fingerprint]).first.should == existing app.find_or_create_err!(conditions).should == existing end diff --git a/spec/models/backtrace_spec.rb b/spec/models/backtrace_spec.rb index 3bffda399..737002d82 100644 --- a/spec/models/backtrace_spec.rb +++ b/spec/models/backtrace_spec.rb @@ -11,7 +11,12 @@ end context "similar backtrace exist" do - let!(:similar_backtrace) { Fabricate(:backtrace, :fingerprint => fingerprint) } + let!(:similar_backtrace) { + b = Fabricate(:backtrace) + b.fingerprint = fingerprint + b.save! + b + } let(:fingerprint) { "fingerprint" } before { subject.stub(:fingerprint => fingerprint) } diff --git a/spec/models/err_spec.rb b/spec/models/err_spec.rb index 39b237c73..283e954f6 100644 --- a/spec/models/err_spec.rb +++ b/spec/models/err_spec.rb @@ -10,7 +10,7 @@ end it 'requires a problem' do - err = Fabricate.build(:err, :problem_id => nil) + err = Fabricate.build(:err, :problem_id => nil, :problem => nil) err.should_not be_valid err.errors[:problem_id].should include("can't be blank") end diff --git a/spec/models/fabricators_spec.rb b/spec/models/fabricators_spec.rb index 9032b2f71..9cf15eced 100644 --- a/spec/models/fabricators_spec.rb +++ b/spec/models/fabricators_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -Fabrication::Config.fabricator_dir.each do |folder| +Fabrication::Config.fabricator_path.each do |folder| Dir.glob(File.join(Rails.root, folder, '**', '*.rb')).each do |file| require file end @@ -8,7 +8,7 @@ describe "Fabrication" do #TODO : when 1.8.7 drop support se directly Symbol#sort - Fabrication::Fabricator.schematics.keys.sort_by(&:to_s).each do |fabricator_name| + Fabrication.manager.schematics.keys.sort.each do |fabricator_name| context "Fabricate(:#{fabricator_name})" do subject { Fabricate.build(fabricator_name) }