ffaker 2.1 (was 1.31)

This commit is contained in:
Jared Beck 2015-12-19 19:01:58 -05:00
parent 10abe56b6f
commit 86f8c5dd33
17 changed files with 51 additions and 51 deletions

View File

@ -8,7 +8,7 @@ group :development, :test do
gem 'rake', '~> 10.1.1'
gem 'rubocop', '~> 0.35.1'
gem 'shoulda', '~> 3.5'
gem 'ffaker', '<= 1.31.0'
gem 'ffaker', '~> 2.1.0'
gem 'timecop'
# Testing of Rails

View File

@ -26,7 +26,7 @@ Gem::Specification.new do |s|
s.add_development_dependency 'rake', '~> 10.1.1'
s.add_development_dependency 'shoulda', '~> 3.5'
s.add_development_dependency 'ffaker', '<= 1.31.0'
s.add_development_dependency 'ffaker', '~> 2.1.0'
s.add_development_dependency 'railties', ['>= 3.0', '< 5.0']
s.add_development_dependency 'sinatra', '~> 1.0'
s.add_development_dependency 'rack-test', '>= 0.6'

View File

@ -10,7 +10,7 @@ describe Boolit, :type => :model do
describe "Versioning", :versioning => true do
subject { Boolit.create! }
before { subject.update_attributes!(:name => Faker::Name.name) }
before { subject.update_attributes!(:name => FFaker::Name.name) }
it "should have versions" do
expect(subject.versions.size).to eq(2)
@ -35,7 +35,7 @@ describe Boolit, :type => :model do
before do
PaperTrail.serializer = CustomJsonSerializer
subject.update_attributes!(:name => nil)
subject.update_attributes!(:name => Faker::Name.name)
subject.update_attributes!(:name => FFaker::Name.name)
end
after { PaperTrail.serializer = PaperTrail::Serializers::YAML }

View File

@ -5,13 +5,13 @@ describe CallbackModifier, :type => :model do
describe 'callback-methods', :versioning => true do
describe 'paper_trail_on_destroy' do
it 'should add :destroy to paper_trail_options[:on]' do
modifier = NoArgDestroyModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = NoArgDestroyModifier.create!(:some_content => FFaker::Lorem.sentence)
expect(modifier.paper_trail_options[:on]).to eq [:destroy]
end
context 'when :before' do
it 'should create the version before destroy' do
modifier = BeforeDestroyModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = BeforeDestroyModifier.create!(:some_content => FFaker::Lorem.sentence)
modifier.test_destroy
expect(modifier.versions.last.reify).not_to be_flagged_deleted
end
@ -19,7 +19,7 @@ describe CallbackModifier, :type => :model do
context 'when :after' do
it 'should create the version after destroy' do
modifier = AfterDestroyModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = AfterDestroyModifier.create!(:some_content => FFaker::Lorem.sentence)
modifier.test_destroy
expect(modifier.versions.last.reify).to be_flagged_deleted
end
@ -27,7 +27,7 @@ describe CallbackModifier, :type => :model do
context 'when no argument' do
it 'should default to after destroy' do
modifier = NoArgDestroyModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = NoArgDestroyModifier.create!(:some_content => FFaker::Lorem.sentence)
modifier.test_destroy
expect(modifier.versions.last.reify).to be_flagged_deleted
end
@ -36,12 +36,12 @@ describe CallbackModifier, :type => :model do
describe 'paper_trail_on_update' do
it 'should add :update to paper_trail_options[:on]' do
modifier = UpdateModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = UpdateModifier.create!(:some_content => FFaker::Lorem.sentence)
expect(modifier.paper_trail_options[:on]).to eq [:update]
end
it 'should create a version' do
modifier = UpdateModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = UpdateModifier.create!(:some_content => FFaker::Lorem.sentence)
modifier.update_attributes! :some_content => 'modified'
expect(modifier.versions.last.event).to eq 'update'
end
@ -49,43 +49,43 @@ describe CallbackModifier, :type => :model do
describe 'paper_trail_on_create' do
it 'should add :create to paper_trail_options[:on]' do
modifier = CreateModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = CreateModifier.create!(:some_content => FFaker::Lorem.sentence)
expect(modifier.paper_trail_options[:on]).to eq [:create]
end
it 'should create a version' do
modifier = CreateModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = CreateModifier.create!(:some_content => FFaker::Lorem.sentence)
expect(modifier.versions.last.event).to eq 'create'
end
end
context 'when no callback-method used' do
it 'should set paper_trail_options[:on] to [:create, :update, :destroy]' do
modifier = DefaultModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = DefaultModifier.create!(:some_content => FFaker::Lorem.sentence)
expect(modifier.paper_trail_options[:on]).to eq [:create, :update, :destroy]
end
it 'should default to track destroy' do
modifier = DefaultModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = DefaultModifier.create!(:some_content => FFaker::Lorem.sentence)
modifier.destroy
expect(modifier.versions.last.event).to eq 'destroy'
end
it 'should default to track update' do
modifier = DefaultModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = DefaultModifier.create!(:some_content => FFaker::Lorem.sentence)
modifier.update_attributes! :some_content => 'modified'
expect(modifier.versions.last.event).to eq 'update'
end
it 'should default to track create' do
modifier = DefaultModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = DefaultModifier.create!(:some_content => FFaker::Lorem.sentence)
expect(modifier.versions.last.event).to eq 'create'
end
end
context 'when only one callback-method' do
it 'does only track the corresponding event' do
modifier = CreateModifier.create!(:some_content => Faker::Lorem.sentence)
modifier = CreateModifier.create!(:some_content => FFaker::Lorem.sentence)
modifier.update_attributes!(:some_content => 'modified')
modifier.test_destroy
expect(modifier.versions.collect(&:event)).to eq ['create']

View File

@ -3,7 +3,7 @@ require 'rails_helper'
describe JoinedVersion, :type => :model, :versioning => true do
it { expect(JoinedVersion.superclass).to be PaperTrail::Version }
let(:widget) { Widget.create!(:name => Faker::Name.name) }
let(:widget) { Widget.create!(:name => FFaker::Name.name) }
let(:version) { JoinedVersion.first }
describe "Scopes" do

View File

@ -26,12 +26,12 @@ if JsonVersion.table_exists?
let(:fruit_names) { %w(apple orange lemon banana lime coconut strawberry blueberry) }
let(:fruit) { Fruit.new }
let(:name) { 'pomegranate' }
let(:color) { Faker::Color.name }
let(:color) { FFaker::Color.name }
before do
fruit.update_attributes!(:name => name)
fruit.update_attributes!(:name => fruit_names.sample, :color => color)
fruit.update_attributes!(:name => fruit_names.sample, :color => Faker::Color.name)
fruit.update_attributes!(:name => fruit_names.sample, :color => FFaker::Color.name)
end
it "should be able to locate versions according to their `object` contents" do
@ -56,12 +56,12 @@ if JsonVersion.table_exists?
let(:tropical_fruit_names) { %w(coconut pineapple kiwi mango melon) }
let(:fruit) { Fruit.new }
let(:name) { 'pomegranate' }
let(:color) { Faker::Color.name }
let(:color) { FFaker::Color.name }
before do
fruit.update_attributes!(:name => name)
fruit.update_attributes!(:name => tropical_fruit_names.sample, :color => color)
fruit.update_attributes!(:name => fruit_names.sample, :color => Faker::Color.name)
fruit.update_attributes!(:name => fruit_names.sample, :color => FFaker::Color.name)
end
it "should be able to locate versions according to their `object_changes` contents" do

View File

@ -57,11 +57,11 @@ describe PaperTrail::Version, :type => :model do
end
context "Has previous version", :versioning => true do
let(:name) { Faker::Name.name }
let(:widget) { Widget.create!(:name => Faker::Name.name) }
let(:name) { FFaker::Name.name }
let(:widget) { Widget.create!(:name => FFaker::Name.name) }
before do
widget.versions.first.update_attributes!(:whodunnit => name)
widget.update_attributes!(:name => Faker::Name.first_name)
widget.update_attributes!(:name => FFaker::Name.first_name)
end
subject { widget.versions.last }
@ -92,7 +92,7 @@ describe PaperTrail::Version, :type => :model do
describe '#terminator' do
it { is_expected.to respond_to(:terminator) }
let(:attributes) { {:whodunnit => Faker::Name.first_name} }
let(:attributes) { {:whodunnit => FFaker::Name.first_name} }
it "is an alias for the `whodunnit` attribute" do
expect(subject.terminator).to eq(attributes[:whodunnit])
@ -147,13 +147,13 @@ describe PaperTrail::Version, :type => :model do
context "valid arguments", :versioning => true do
let(:widget) { Widget.new }
let(:name) { Faker::Name.first_name }
let(:name) { FFaker::Name.first_name }
let(:int) { rand(10) + 1 }
before do
widget.update_attributes!(:name => name, :an_integer => int)
widget.update_attributes!(:name => 'foobar', :an_integer => 100)
widget.update_attributes!(:name => Faker::Name.last_name, :an_integer => 15)
widget.update_attributes!(:name => FFaker::Name.last_name, :an_integer => 15)
end
context "`serializer == YAML`" do
@ -191,13 +191,13 @@ describe PaperTrail::Version, :type => :model do
context "valid arguments", :versioning => true do
let(:widget) { Widget.new }
let(:name) { Faker::Name.first_name }
let(:name) { FFaker::Name.first_name }
let(:int) { rand(5) + 2 }
before do
widget.update_attributes!(:name => name, :an_integer => 0)
widget.update_attributes!(:name => 'foobar', :an_integer => 77)
widget.update_attributes!(:name => Faker::Name.last_name, :an_integer => int)
widget.update_attributes!(:name => FFaker::Name.last_name, :an_integer => int)
end
context "`serializer == YAML`" do

View File

@ -125,8 +125,8 @@ describe Widget, :type => :model do
it { is_expected.to respond_to(:paper_trail_originator) }
describe "return value" do
let(:orig_name) { Faker::Name.name }
let(:new_name) { Faker::Name.name }
let(:orig_name) { FFaker::Name.name }
let(:new_name) { FFaker::Name.name }
before { PaperTrail.whodunnit = orig_name }
context "accessed from live model instance" do
@ -216,8 +216,8 @@ describe Widget, :type => :model do
end
context "block given" do
let(:orig_name) { Faker::Name.name }
let(:new_name) { Faker::Name.name }
let(:orig_name) { FFaker::Name.name }
let(:new_name) { FFaker::Name.name }
before do
PaperTrail.whodunnit = orig_name

View File

@ -1,7 +1,7 @@
require 'rails_helper'
describe "Articles management", :type => :request, :order => :defined do
let(:valid_params) { { :article => { :title => 'Doh', :content => Faker::Lorem.sentence } } }
let(:valid_params) { { :article => { :title => 'Doh', :content => FFaker::Lorem.sentence } } }
context "versioning disabled" do
specify { expect(PaperTrail).not_to be_enabled }

View File

@ -6,7 +6,7 @@ class EnabledForControllerTest < ActionController::TestCase
context "`PaperTrail.enabled? == true`" do
should 'enabled_for_controller?.should == true' do
assert PaperTrail.enabled?
post :create, :article => { :title => 'Doh', :content => Faker::Lorem.sentence }
post :create, :article => { :title => 'Doh', :content => FFaker::Lorem.sentence }
assert_not_nil assigns(:article)
assert PaperTrail.enabled_for_controller?
assert_equal 1, assigns(:article).versions.length
@ -15,10 +15,10 @@ class EnabledForControllerTest < ActionController::TestCase
context "`PaperTrail.enabled? == false`" do
setup { PaperTrail.enabled = false }
should 'enabled_for_controller?.should == false' do
assert !PaperTrail.enabled?
post :create, :article => { :title => 'Doh', :content => Faker::Lorem.sentence }
post :create, :article => { :title => 'Doh', :content => FFaker::Lorem.sentence }
assert !PaperTrail.enabled_for_controller?
assert_equal 0, assigns(:article).versions.length
end

View File

@ -5,7 +5,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
def populate_db!
@animals = [@animal = Animal.new, @dog = Dog.new, @cat = Cat.new]
@animals.each do |animal|
3.times { animal.update_attribute(:name, Faker::Name.name) }
3.times { animal.update_attribute(:name, FFaker::Name.name) }
end
end
@ -47,7 +47,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
setup do
@animal.versions.each { |ver| ver.update_attribute(:created_at, ver.created_at - 1.day) }
@date = @animal.versions.first.created_at.to_date
@animal.update_attribute(:name, Faker::Name.name)
@animal.update_attribute(:name, FFaker::Name.name)
end
should 'restrict the versions destroyed to those that were created on the date provided' do
@ -86,7 +86,7 @@ class PaperTrailCleanerTest < ActiveSupport::TestCase
setup do
[@animal, @dog].each do |animal|
animal.versions.each { |ver| ver.update_attribute(:created_at, ver.created_at - 1.day) }
animal.update_attribute(:name, Faker::Name.name)
animal.update_attribute(:name, FFaker::Name.name)
end
@date = @animal.versions.first.created_at.to_date
end

View File

@ -1366,7 +1366,7 @@ class HasPaperTrailModelTest < ActiveSupport::TestCase
setup do
PaperTrail.config.version_limit = 2
@widget = Widget.create! :name => 'Henry'
6.times { @widget.update_attribute(:name, Faker::Lorem.word) }
6.times { @widget.update_attribute(:name, FFaker::Lorem.word) }
end
teardown { PaperTrail.config.version_limit = nil }

View File

@ -6,12 +6,12 @@ class JSONTest < ActiveSupport::TestCase
# Setup a hash with random values
@hash = {}
(1..4).each do |i|
@hash["key#{i}"] = Faker::Lorem.word
@hash["key#{i}"] = FFaker::Lorem.word
end
@hash_as_json = @hash.to_json
# Setup an array of random words
@array = []
(rand(5) + 4).times { @array << Faker::Lorem.word }
(rand(5) + 4).times { @array << FFaker::Lorem.word }
@array_as_json = @array.to_json
end
@ -73,7 +73,7 @@ class JSONTest < ActiveSupport::TestCase
assert grouping.instance_of?(Arel::Nodes::Grouping)
matches = grouping.select { |v| v.instance_of?(Arel::Nodes::Matches) }
# Numeric arguments need to ensure that they match for only the number, not the beginning
# Numeric arguments need to ensure that they match for only the number, not the beginning
# of a #, so it uses an Grouping matcher (See notes on `PaperTrail::Serializers::JSON`)
if Arel::VERSION >= '6'
assert_equal matches.first.right.val, "%\"arg1\":-3.5,%"

View File

@ -7,7 +7,7 @@ class MixinJsonTest < ActiveSupport::TestCase
# Setup a hash with random values, ensuring some values are nil
@hash = {}
(1..4).each do |i|
@hash["key#{i}"] = [Faker::Lorem.word, nil].sample
@hash["key#{i}"] = [FFaker::Lorem.word, nil].sample
end
@hash['tkey'] = nil
@hash[''] = 'foo'

View File

@ -19,7 +19,7 @@ class MixinYamlTest < ActiveSupport::TestCase
# Setup a hash with random values, ensuring some values are nil
@hash = {}
(1..4).each do |i|
@hash["key#{i}"] = [Faker::Lorem.word, nil].sample
@hash["key#{i}"] = [FFaker::Lorem.word, nil].sample
end
@hash['tkey'] = nil
@hash[''] = 'foo'

View File

@ -6,12 +6,12 @@ class YamlTest < ActiveSupport::TestCase
# Setup a hash with random values
@hash = {}
(1..4).each do |i|
@hash["key#{i}".to_sym] = Faker::Lorem.word
@hash["key#{i}".to_sym] = FFaker::Lorem.word
end
@hash_as_yaml = @hash.to_yaml
# Setup an array of random words
@array = []
(rand(5) + 4).times { @array << Faker::Lorem.word }
(rand(5) + 4).times { @array << FFaker::Lorem.word }
@array_as_yaml = @array.to_yaml
end

View File

@ -65,7 +65,7 @@ module PaperTrail
context ".subsequent" do
setup do
2.times do
@animal.update_attributes(name: Faker::Lorem.word)
@animal.update_attributes(name: FFaker::Lorem.word)
end
end
@ -92,7 +92,7 @@ module PaperTrail
context ".preceding" do
setup do
2.times do
@animal.update_attributes(name: Faker::Lorem.word)
@animal.update_attributes(name: FFaker::Lorem.word)
end
end