cucumber_factory 1.11.8 → 1.11.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 2474f1242ac52bc7d8ed0e36fcf51f5fea0301c9
4
- data.tar.gz: 3cbeb16d2fe2cd2038bc22e937046af0f0743e53
3
+ metadata.gz: cf308118b2098c3650288d2da08549d6f1f51c07
4
+ data.tar.gz: 8325e52892d5331e2c5d9a0670ad8883e8519783
5
5
  SHA512:
6
- metadata.gz: 0cea20126d458263a37d369acefc48855cf156d92a81d6b6776373d0c7fdcc4982646166c747afdbd17cdb0428da6cf39114f19c3d535cc25014ed5b349ef0f1
7
- data.tar.gz: 47f468e206ea8fc20ef02ae343cc048bf47e794f4e9549cf5e474f9919f9bcbbf45007200fa957e8dfd966003b3e79a34c85e454c50e5c7ba707c40fe533cbd1
6
+ metadata.gz: d4111f40061523a16fb4845487beadc7ea8580e9bc47b7e701fadd8ced980cc4444b02fbdcc3b55c4f825b1dc7e7494988ef48f8b121c108ef0e31b31820cae5
7
+ data.tar.gz: '0186bd34d5f8325d5bd355d6eedc927f66f1c685b9166990af20a282f12394c340aed9d378c31fbdddcca99f1ac462762a5a6bc9b1c3bdb619a57e94733ef7b6'
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- cucumber_factory (1.11.7)
4
+ cucumber_factory (1.11.8)
5
5
  activerecord
6
6
  activesupport
7
7
  cucumber
@@ -50,4 +50,4 @@ DEPENDENCIES
50
50
  rspec (~> 1.0)
51
51
 
52
52
  BUNDLED WITH
53
- 1.13.7
53
+ 1.16.0
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- cucumber_factory (1.11.7)
4
+ cucumber_factory (1.11.9)
5
5
  activerecord
6
6
  activesupport
7
7
  cucumber
@@ -81,4 +81,4 @@ DEPENDENCIES
81
81
  rspec (~> 3.0)
82
82
 
83
83
  BUNDLED WITH
84
- 1.13.7
84
+ 1.14.6
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: ..
3
3
  specs:
4
- cucumber_factory (1.11.7)
4
+ cucumber_factory (1.11.9)
5
5
  activerecord
6
6
  activesupport
7
7
  cucumber
@@ -81,4 +81,4 @@ DEPENDENCIES
81
81
  rspec (~> 3.0)
82
82
 
83
83
  BUNDLED WITH
84
- 1.13.7
84
+ 1.14.6
@@ -5,7 +5,13 @@ module CucumberFactory
5
5
  def find_last(klass)
6
6
  # Don't use class.last, in sqlite that is not always the last inserted element
7
7
  # If created_at is available prefer it over id as column for ordering so that we can handle UUIDs
8
- order_column = klass.column_names.include?('created_at') ? 'created_at, id' : 'id'
8
+ primary_key = klass.primary_key
9
+ has_numeric_primary_key = klass.columns_hash[primary_key].type == :integer
10
+ order_column = if has_numeric_primary_key || !klass.column_names.include?('created_at')
11
+ primary_key
12
+ else
13
+ "created_at, #{primary_key}"
14
+ end
9
15
  if active_record_version < 4
10
16
  klass.find(:last, :order => order_column)
11
17
  else
@@ -1,3 +1,3 @@
1
1
  module CucumberFactory
2
- VERSION = '1.11.8'
2
+ VERSION = '1.11.9'
3
3
  end
@@ -171,16 +171,22 @@ describe 'steps provided by cucumber_factory' do
171
171
  before_sunset.reviewer.should == user
172
172
  end
173
173
 
174
- it "should give created_at precedence over id when saying 'above' so that records with UUIDs are handled correctly" do
174
+ it "should give created_at precedence over id when saying 'above' if the primary key is not numeric" do
175
+ invoke_cucumber_step('there is a uuid user with the name "Jane" and the id "jane"')
176
+ invoke_cucumber_step('there is a uuid user with the name "John" and the id "john"')
177
+ UuidUser.find_by_name("John").update_attributes!(:created_at => 1.day.ago)
178
+ invoke_cucumber_step('there is a movie with the title "Before Sunset" and the uuid reviewer above')
179
+ before_sunset = Movie.find_by_title!("Before Sunset")
180
+ before_sunset.uuid_reviewer.name.should == "Jane"
181
+ end
182
+
183
+ it "should ignore created_at if the primary key is numeric" do
175
184
  invoke_cucumber_step('there is a user with the name "Jane"')
176
185
  invoke_cucumber_step('there is a user with the name "John"')
177
186
  User.find_by_name("John").update_attributes!(:created_at => 1.day.ago)
178
- invoke_cucumber_step('there is a movie with the title "Limitless"')
179
- invoke_cucumber_step('there is a movie with the title "Before Sunrise"')
180
- invoke_cucumber_step('there is a movie with the title "Before Sunset" and the reviewer above and the prequel above')
187
+ invoke_cucumber_step('there is a movie with the title "Before Sunset" and the reviewer above')
181
188
  before_sunset = Movie.find_by_title!("Before Sunset")
182
- before_sunset.prequel.title.should == "Before Sunrise"
183
- before_sunset.reviewer.name.should == "Jane"
189
+ before_sunset.reviewer.name.should == "John"
184
190
  end
185
191
 
186
192
  it "should raise a proper error if there is no previous record when saying 'above'" do
@@ -5,6 +5,7 @@ Gemika::Database.new.rewrite_schema! do
5
5
  t.integer :year
6
6
  t.integer :prequel_id
7
7
  t.integer :reviewer_id
8
+ t.string :uuid_reviewer_id
8
9
  t.integer :box_office_result
9
10
  end
10
11
 
@@ -19,6 +20,13 @@ Gemika::Database.new.rewrite_schema! do
19
20
  t.datetime :created_at
20
21
  end
21
22
 
23
+ create_table :uuid_users, :id => false do |t|
24
+ t.string :id
25
+ t.string :email
26
+ t.string :name
27
+ t.datetime :created_at
28
+ end
29
+
22
30
  create_table :payments do |t|
23
31
  t.text :comment
24
32
  t.integer :amount
@@ -2,6 +2,7 @@ class Movie < ActiveRecord::Base
2
2
 
3
3
  belongs_to :prequel, :class_name => "Movie"
4
4
  belongs_to :reviewer, :class_name => "User"
5
+ belongs_to :uuid_reviewer, :class_name => "UuidUser"
5
6
 
6
7
  validate do |record|
7
8
  record.errors.add(:reviewer, 'may not be deleted') if record.reviewer and record.reviewer.deleted?
@@ -0,0 +1,5 @@
1
+ class UuidUser < ActiveRecord::Base
2
+
3
+ self.primary_key = 'id'
4
+
5
+ end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: cucumber_factory
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.11.8
4
+ version: 1.11.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Henning Koch
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-10-27 00:00:00.000000000 Z
11
+ date: 2017-12-05 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: cucumber
@@ -110,6 +110,7 @@ files:
110
110
  - spec/support/models/people/actor.rb
111
111
  - spec/support/models/plain_ruby_class.rb
112
112
  - spec/support/models/user.rb
113
+ - spec/support/models/uuid_user.rb
113
114
  homepage: http://github.com/makandra/cucumber_factory
114
115
  licenses:
115
116
  - MIT