Skip to content

Commit

Permalink
Upgrade fabrication gem to 2.8.1 version
Browse files Browse the repository at this point in the history
  • Loading branch information
shingara committed Sep 25, 2013
1 parent 396c338 commit 1c9fab7
Show file tree
Hide file tree
Showing 13 changed files with 29 additions and 23 deletions.
3 changes: 1 addition & 2 deletions Gemfile
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions Gemfile.lock
Expand Up @@ -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)
Expand Down Expand Up @@ -404,7 +404,7 @@ DEPENDENCIES
devise (~> 2.2.1)
email_spec
execjs
fabrication (~> 1.3.0)
fabrication
flowdock
foreman
gitlab!
Expand Down
2 changes: 1 addition & 1 deletion app/models/backtrace.rb
Expand Up @@ -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)
Expand Down
6 changes: 3 additions & 3 deletions spec/fabricators/app_fabricator.rb
Expand Up @@ -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'
Expand Down
4 changes: 2 additions & 2 deletions spec/fabricators/comment_fabricator.rb
@@ -1,6 +1,6 @@
Fabricator :comment do
user!
user
body 'Test comment'
err!(:fabricator => :problem)
err(:fabricator => :problem)
end

7 changes: 3 additions & 4 deletions 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

Expand Down
2 changes: 1 addition & 1 deletion 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 }
Expand Down
2 changes: 1 addition & 1 deletion 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 }
Expand Down
2 changes: 1 addition & 1 deletion spec/fabricators/problem_fabricator.rb
@@ -1,5 +1,5 @@
Fabricator(:problem) do
app! { Fabricate(:app) }
app { Fabricate(:app) }
comments { [] }
error_class 'FooError'
environment 'production'
Expand Down
7 changes: 5 additions & 2 deletions spec/models/app_spec.rb
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion spec/models/backtrace_spec.rb
Expand Up @@ -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) }
Expand Down
2 changes: 1 addition & 1 deletion spec/models/err_spec.rb
Expand Up @@ -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
Expand Down
4 changes: 2 additions & 2 deletions spec/models/fabricators_spec.rb
@@ -1,14 +1,14 @@
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
end

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) }

Expand Down

0 comments on commit 1c9fab7

Please sign in to comment.