ranked-model 0.4.4 → 0.4.5
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.gitignore +1 -0
- data/.rspec +1 -0
- data/.travis.yml +11 -25
- data/Appraisals +26 -36
- data/Gemfile +12 -0
- data/Readme.mkd +2 -2
- data/gemfiles/rails_4_2.gemfile +7 -7
- data/gemfiles/rails_5_0.gemfile +8 -8
- data/gemfiles/rails_5_1.gemfile +8 -8
- data/gemfiles/rails_5_2.gemfile +7 -4
- data/gemfiles/rails_6_0.gemfile +22 -0
- data/lib/ranked-model.rb +1 -1
- data/lib/ranked-model/ranker.rb +8 -11
- data/lib/ranked-model/version.rb +1 -1
- data/ranked-model.gemspec +3 -3
- data/spec/duck-model/column_default_ducks_spec.rb +1 -1
- data/spec/duck-model/duck_spec.rb +76 -46
- data/spec/duck-model/lots_of_ducks_spec.rb +15 -15
- data/spec/ego-model/ego_spec.rb +3 -3
- data/spec/number-model/number_spec.rb +2 -2
- data/spec/player-model/records_already_exist_spec.rb +1 -1
- data/spec/sti-model/element_spec.rb +24 -24
- data/spec/sti-model/vehicle_spec.rb +4 -4
- data/spec/support/active_record.rb +5 -5
- metadata +8 -9
- data/gemfiles/rails_4_1.gemfile +0 -22
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
|
-
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
2
|
+
SHA256:
|
3
|
+
metadata.gz: c342543b3341c81d62ceca340fc0966a3386a6115fc2ee36f309582995f8af52
|
4
|
+
data.tar.gz: 25408af509201219ce0539dbfe3324c8b3806bce367d3e00b80a2f15dc6e7dc4
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 139bcf7c985b68e017e03bb3718a4377ec878ec7b249ac32ad20900d1467e5026a093e82725f8e39e1d8a378a7db0959f6a37f7571d1bccae40e9b8f70244a55
|
7
|
+
data.tar.gz: ca739746fb067e6de9ae52bcb08f352fcdf676a02063e04f5d3b5f3b8a54d773ff57227d5dc5fca7c6d402155920b3da39c73d83d495680ff988f67248fac321
|
data/.gitignore
CHANGED
data/.rspec
CHANGED
data/.travis.yml
CHANGED
@@ -1,49 +1,35 @@
|
|
1
|
-
sudo: false # use newer travis infrastructure
|
2
1
|
language: ruby
|
3
2
|
cache: bundler
|
3
|
+
sudo: false
|
4
4
|
before_install:
|
5
|
-
- gem
|
5
|
+
- gem update --system
|
6
|
+
- gem install bundler
|
6
7
|
before_script:
|
7
8
|
- mysql -e 'create database ranked_model_test;'
|
8
9
|
- psql -c 'create database ranked_model_test;' -U postgres
|
9
10
|
rvm:
|
10
|
-
- 1.9.3
|
11
|
-
- 2.1.10
|
12
|
-
- 2.2.10
|
13
|
-
- 2.3.7
|
14
11
|
- 2.4.4
|
15
12
|
- 2.5.1
|
13
|
+
- 2.6.4
|
16
14
|
- jruby-9.1.17.0
|
17
|
-
- rbx-3.107
|
18
15
|
env:
|
19
16
|
- DB=sqlite
|
20
17
|
- DB=mysql
|
21
18
|
- DB=postgresql
|
19
|
+
services:
|
20
|
+
- mysql
|
21
|
+
- postgresql
|
22
22
|
gemfile:
|
23
|
-
- gemfiles/rails_4_1.gemfile
|
24
23
|
- gemfiles/rails_4_2.gemfile
|
25
24
|
- gemfiles/rails_5_0.gemfile
|
26
25
|
- gemfiles/rails_5_1.gemfile
|
27
26
|
- gemfiles/rails_5_2.gemfile
|
27
|
+
- gemfiles/rails_6_0.gemfile
|
28
28
|
matrix:
|
29
29
|
exclude:
|
30
|
-
- rvm: 1.9.3
|
31
|
-
gemfile: gemfiles/rails_5_0.gemfile
|
32
|
-
- rvm: 1.9.3
|
33
|
-
gemfile: gemfiles/rails_5_1.gemfile
|
34
|
-
- rvm: 1.9.3
|
35
|
-
gemfile: gemfiles/rails_5_2.gemfile
|
36
|
-
- rvm: 2.1.10
|
37
|
-
gemfile: gemfiles/rails_5_0.gemfile
|
38
|
-
- rvm: 2.1.10
|
39
|
-
gemfile: gemfiles/rails_5_1.gemfile
|
40
|
-
- rvm: 2.1.10
|
41
|
-
gemfile: gemfiles/rails_5_2.gemfile
|
42
30
|
- rvm: jruby-9.1.17.0
|
43
31
|
gemfile: gemfiles/rails_5_2.gemfile
|
44
32
|
- rvm: 2.4.4
|
45
|
-
gemfile: gemfiles/
|
46
|
-
- rvm:
|
47
|
-
gemfile: gemfiles/
|
48
|
-
- rvm: rbx-3.107
|
49
|
-
gemfile: gemfiles/rails_5_2.gemfile
|
33
|
+
gemfile: gemfiles/rails_6_0.gemfile
|
34
|
+
- rvm: jruby-9.1.17.0
|
35
|
+
gemfile: gemfiles/rails_6_0.gemfile
|
data/Appraisals
CHANGED
@@ -1,81 +1,71 @@
|
|
1
|
-
appraise "rails-4-
|
1
|
+
appraise "rails-4-2" do
|
2
2
|
group :sqlite do
|
3
|
-
gem "sqlite3", "~> 1.3.13", platform: :ruby
|
4
3
|
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.24", platform: :jruby
|
5
4
|
end
|
6
5
|
group :mysql do
|
7
|
-
gem "mysql2", "~> 0.
|
6
|
+
gem "mysql2", "~> 0.4.0", platform: :ruby
|
8
7
|
gem "activerecord-jdbcmysql-adapter", "~> 1.3.24", platform: :jruby
|
9
8
|
end
|
10
9
|
group :postgresql do
|
11
|
-
gem "pg", "~> 0.18.
|
10
|
+
gem "pg", "~> 0.18.4", platform: :ruby
|
12
11
|
gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.24", platform: :jruby
|
13
12
|
end
|
14
13
|
|
15
|
-
gem "activerecord", "~> 4.
|
14
|
+
gem "activerecord", "~> 4.2.0"
|
16
15
|
end
|
17
16
|
|
18
|
-
appraise "rails-
|
17
|
+
appraise "rails-5-0" do
|
19
18
|
group :sqlite do
|
20
|
-
gem "
|
21
|
-
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.24", platform: :jruby
|
19
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 50.0", platform: :jruby
|
22
20
|
end
|
23
21
|
group :mysql do
|
24
|
-
gem "
|
25
|
-
gem "activerecord-jdbcmysql-adapter", "~> 1.3.24", platform: :jruby
|
22
|
+
gem "activerecord-jdbcmysql-adapter", "~> 50.0", platform: :jruby
|
26
23
|
end
|
27
24
|
group :postgresql do
|
28
|
-
gem "
|
29
|
-
gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.24", platform: :jruby
|
25
|
+
gem "activerecord-jdbcpostgresql-adapter", "~> 50.0", platform: :jruby
|
30
26
|
end
|
31
27
|
|
32
|
-
gem "activerecord", "~>
|
28
|
+
gem "activerecord", "~> 5.0.0"
|
33
29
|
end
|
34
30
|
|
35
|
-
appraise "rails-5-
|
31
|
+
appraise "rails-5-1" do
|
36
32
|
group :sqlite do
|
37
|
-
gem "
|
38
|
-
gem "activerecord-jdbcsqlite3-adapter", "~> 50.1", platform: :jruby
|
33
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 51.0", platform: :jruby
|
39
34
|
end
|
40
35
|
group :mysql do
|
41
|
-
gem "
|
42
|
-
gem "activerecord-jdbcmysql-adapter", "~> 50.1", platform: :jruby
|
36
|
+
gem "activerecord-jdbcmysql-adapter", "~> 51.0", platform: :jruby
|
43
37
|
end
|
44
38
|
group :postgresql do
|
45
|
-
gem "
|
46
|
-
gem "activerecord-jdbcpostgresql-adapter", "~> 50.1", platform: :jruby
|
39
|
+
gem "activerecord-jdbcpostgresql-adapter", "~> 51.0", platform: :jruby
|
47
40
|
end
|
48
41
|
|
49
|
-
gem "activerecord", "~> 5.0
|
42
|
+
gem "activerecord", "~> 5.1.0"
|
50
43
|
end
|
51
44
|
|
52
|
-
appraise "rails-5-
|
45
|
+
appraise "rails-5-2" do
|
53
46
|
group :sqlite do
|
54
|
-
gem "
|
55
|
-
gem "activerecord-jdbcsqlite3-adapter", "~> 51.1", platform: :jruby
|
47
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 52.0", platform: :jruby
|
56
48
|
end
|
57
49
|
group :mysql do
|
58
|
-
gem "
|
59
|
-
gem "activerecord-jdbcmysql-adapter", "~> 51.1", platform: :jruby
|
50
|
+
gem "activerecord-jdbcmysql-adapter", "~> 52.0", platform: :jruby
|
60
51
|
end
|
61
52
|
group :postgresql do
|
62
|
-
gem "
|
63
|
-
gem "activerecord-jdbcpostgresql-adapter", "~> 51.1", platform: :jruby
|
53
|
+
gem "activerecord-jdbcpostgresql-adapter", "~> 52.0", platform: :jruby
|
64
54
|
end
|
65
55
|
|
66
|
-
gem "activerecord", "~> 5.
|
56
|
+
gem "activerecord", "~> 5.2.0"
|
67
57
|
end
|
68
58
|
|
69
|
-
appraise "rails-
|
59
|
+
appraise "rails-6-0" do
|
70
60
|
group :sqlite do
|
71
|
-
gem "sqlite3", "~> 1.
|
61
|
+
gem "sqlite3", "~> 1.4", platform: :ruby
|
62
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 60.0", platform: :jruby
|
72
63
|
end
|
73
64
|
group :mysql do
|
74
|
-
gem "
|
65
|
+
gem "activerecord-jdbcmysql-adapter", "~> 60.0", platform: :jruby
|
75
66
|
end
|
76
67
|
group :postgresql do
|
77
|
-
gem "
|
68
|
+
gem "activerecord-jdbcpostgresql-adapter", "~> 60.0", platform: :jruby
|
78
69
|
end
|
79
|
-
|
80
|
-
|
81
|
-
end
|
70
|
+
gem "activerecord", "~> 6.0.0"
|
71
|
+
end
|
data/Gemfile
CHANGED
@@ -2,3 +2,15 @@ source "https://rubygems.org"
|
|
2
2
|
|
3
3
|
# Specify your gem's dependencies in ranked-model.gemspec
|
4
4
|
gemspec
|
5
|
+
|
6
|
+
group :sqlite do
|
7
|
+
gem "sqlite3", "~> 1.3.13", platform: :ruby
|
8
|
+
end
|
9
|
+
|
10
|
+
group :postgresql do
|
11
|
+
gem "pg", "~> 1.1.4", platform: :ruby
|
12
|
+
end
|
13
|
+
|
14
|
+
group :mysql do
|
15
|
+
gem "mysql2", "~> 0.5.0", platform: :ruby
|
16
|
+
end
|
data/Readme.mkd
CHANGED
@@ -5,7 +5,7 @@
|
|
5
5
|
Installation
|
6
6
|
------------
|
7
7
|
|
8
|
-
ranked-model passes specs with Rails 4.
|
8
|
+
ranked-model passes specs with Rails 4.2, 5.0, 5.1, 5.2, 6.0 for MySQL, Postgres, and SQLite on Ruby 2.4 through 2.6, and jruby-9.1.17.0 where Rails supports the platform. This is with the exception of Postgres before Rails 4.0 on all platforms, which is unsupported by `ranked-model`. Note that the `pg` gem has pulled support for rbx (Rubinius) from version 1 onward.
|
9
9
|
|
10
10
|
TL;DR, if you are using Rails 4 and up you are 100% good to go. Before Rails 4, be wary of Postgres.
|
11
11
|
|
@@ -52,7 +52,7 @@ The ranking integers stored in the `row_order` column will be big and spaced apa
|
|
52
52
|
implement a sorting UI, just update the resource by appending the column name with `_position` and indicating the desired position:
|
53
53
|
|
54
54
|
``` ruby
|
55
|
-
@duck.
|
55
|
+
@duck.update :row_order_position => 0 # or 1, 2, 37. :first, :last, :up and :down are also valid
|
56
56
|
```
|
57
57
|
|
58
58
|
**IMPORTANT: Note that you MUST append _position to the column name when setting a new position on an instance. This is a fake column that can take relative as well as absolute index-based values for position.**
|
data/gemfiles/rails_4_2.gemfile
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "activerecord", "~> 4.2.
|
5
|
+
gem "activerecord", "~> 4.2.0"
|
6
6
|
|
7
7
|
group :sqlite do
|
8
8
|
gem "sqlite3", "~> 1.3.13", platform: :ruby
|
9
9
|
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.24", platform: :jruby
|
10
10
|
end
|
11
11
|
|
12
|
-
group :mysql do
|
13
|
-
gem "mysql2", "~> 0.4.10", platform: :ruby
|
14
|
-
gem "activerecord-jdbcmysql-adapter", "~> 1.3.24", platform: :jruby
|
15
|
-
end
|
16
|
-
|
17
12
|
group :postgresql do
|
18
|
-
gem "pg", "~> 0.18.
|
13
|
+
gem "pg", "~> 0.18.4", platform: :ruby
|
19
14
|
gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.24", platform: :jruby
|
20
15
|
end
|
21
16
|
|
17
|
+
group :mysql do
|
18
|
+
gem "mysql2", "~> 0.4.0", platform: :ruby
|
19
|
+
gem "activerecord-jdbcmysql-adapter", "~> 1.3.24", platform: :jruby
|
20
|
+
end
|
21
|
+
|
22
22
|
gemspec path: "../"
|
data/gemfiles/rails_5_0.gemfile
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "activerecord", "~> 5.0.
|
5
|
+
gem "activerecord", "~> 5.0.0"
|
6
6
|
|
7
7
|
group :sqlite do
|
8
8
|
gem "sqlite3", "~> 1.3.13", platform: :ruby
|
9
|
-
gem "activerecord-jdbcsqlite3-adapter", "~> 50.
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 50.0", platform: :jruby
|
10
10
|
end
|
11
11
|
|
12
|
-
group :
|
13
|
-
gem "
|
14
|
-
gem "activerecord-
|
12
|
+
group :postgresql do
|
13
|
+
gem "pg", "~> 1.1.4", platform: :ruby
|
14
|
+
gem "activerecord-jdbcpostgresql-adapter", "~> 50.0", platform: :jruby
|
15
15
|
end
|
16
16
|
|
17
|
-
group :
|
18
|
-
gem "
|
19
|
-
gem "activerecord-
|
17
|
+
group :mysql do
|
18
|
+
gem "mysql2", "~> 0.5.0", platform: :ruby
|
19
|
+
gem "activerecord-jdbcmysql-adapter", "~> 50.0", platform: :jruby
|
20
20
|
end
|
21
21
|
|
22
22
|
gemspec path: "../"
|
data/gemfiles/rails_5_1.gemfile
CHANGED
@@ -2,21 +2,21 @@
|
|
2
2
|
|
3
3
|
source "https://rubygems.org"
|
4
4
|
|
5
|
-
gem "activerecord", "~> 5.1.
|
5
|
+
gem "activerecord", "~> 5.1.0"
|
6
6
|
|
7
7
|
group :sqlite do
|
8
8
|
gem "sqlite3", "~> 1.3.13", platform: :ruby
|
9
|
-
gem "activerecord-jdbcsqlite3-adapter", "~> 51.
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 51.0", platform: :jruby
|
10
10
|
end
|
11
11
|
|
12
|
-
group :
|
13
|
-
gem "
|
14
|
-
gem "activerecord-
|
12
|
+
group :postgresql do
|
13
|
+
gem "pg", "~> 1.1.4", platform: :ruby
|
14
|
+
gem "activerecord-jdbcpostgresql-adapter", "~> 51.0", platform: :jruby
|
15
15
|
end
|
16
16
|
|
17
|
-
group :
|
18
|
-
gem "
|
19
|
-
gem "activerecord-
|
17
|
+
group :mysql do
|
18
|
+
gem "mysql2", "~> 0.5.0", platform: :ruby
|
19
|
+
gem "activerecord-jdbcmysql-adapter", "~> 51.0", platform: :jruby
|
20
20
|
end
|
21
21
|
|
22
22
|
gemspec path: "../"
|
data/gemfiles/rails_5_2.gemfile
CHANGED
@@ -6,14 +6,17 @@ gem "activerecord", "~> 5.2.0"
|
|
6
6
|
|
7
7
|
group :sqlite do
|
8
8
|
gem "sqlite3", "~> 1.3.13", platform: :ruby
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 52.0", platform: :jruby
|
9
10
|
end
|
10
11
|
|
11
|
-
group :
|
12
|
-
gem "
|
12
|
+
group :postgresql do
|
13
|
+
gem "pg", "~> 1.1.4", platform: :ruby
|
14
|
+
gem "activerecord-jdbcpostgresql-adapter", "~> 52.0", platform: :jruby
|
13
15
|
end
|
14
16
|
|
15
|
-
group :
|
16
|
-
gem "
|
17
|
+
group :mysql do
|
18
|
+
gem "mysql2", "~> 0.5.0", platform: :ruby
|
19
|
+
gem "activerecord-jdbcmysql-adapter", "~> 52.0", platform: :jruby
|
17
20
|
end
|
18
21
|
|
19
22
|
gemspec path: "../"
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# This file was generated by Appraisal
|
2
|
+
|
3
|
+
source "https://rubygems.org"
|
4
|
+
|
5
|
+
gem "activerecord", "~> 6.0.0"
|
6
|
+
|
7
|
+
group :sqlite do
|
8
|
+
gem "sqlite3", "~> 1.4", platform: :ruby
|
9
|
+
gem "activerecord-jdbcsqlite3-adapter", "~> 60.0", platform: :jruby
|
10
|
+
end
|
11
|
+
|
12
|
+
group :postgresql do
|
13
|
+
gem "pg", "~> 1.1.4", platform: :ruby
|
14
|
+
gem "activerecord-jdbcpostgresql-adapter", "~> 60.0", platform: :jruby
|
15
|
+
end
|
16
|
+
|
17
|
+
group :mysql do
|
18
|
+
gem "mysql2", "~> 0.5.0", platform: :ruby
|
19
|
+
gem "activerecord-jdbcmysql-adapter", "~> 60.0", platform: :jruby
|
20
|
+
end
|
21
|
+
|
22
|
+
gemspec path: "../"
|
data/lib/ranked-model.rb
CHANGED
data/lib/ranked-model/ranker.rb
CHANGED
@@ -175,7 +175,7 @@ module RankedModel
|
|
175
175
|
|
176
176
|
def assure_unique_position
|
177
177
|
if ( new_record? || rank_changed? )
|
178
|
-
if (rank > RankedModel::MAX_RANK_VALUE) ||
|
178
|
+
if (rank > RankedModel::MAX_RANK_VALUE) || rank_taken?
|
179
179
|
rearrange_ranks
|
180
180
|
end
|
181
181
|
end
|
@@ -211,10 +211,12 @@ module RankedModel
|
|
211
211
|
def rebalance_ranks
|
212
212
|
if rank && instance.persisted?
|
213
213
|
origin = current_order.index { |item| item.instance.id == instance.id }
|
214
|
-
|
215
|
-
|
214
|
+
if origin
|
215
|
+
destination = current_order.index { |item| rank <= item.rank }
|
216
|
+
destination -= 1 if origin < destination
|
216
217
|
|
217
|
-
|
218
|
+
current_order.insert destination, current_order.delete_at(origin)
|
219
|
+
end
|
218
220
|
end
|
219
221
|
|
220
222
|
gaps = current_order.size + 1
|
@@ -290,13 +292,8 @@ module RankedModel
|
|
290
292
|
end
|
291
293
|
end
|
292
294
|
|
293
|
-
def
|
294
|
-
|
295
|
-
except( :order ).
|
296
|
-
where( ranker.column => _rank ).
|
297
|
-
first)
|
298
|
-
RankedModel::Ranker::Mapper.new ranker, ordered_instance
|
299
|
-
end
|
295
|
+
def rank_taken?
|
296
|
+
finder.except(:order).where(ranker.column => rank).exists?
|
300
297
|
end
|
301
298
|
|
302
299
|
def neighbors_at_position _pos
|
data/lib/ranked-model/version.rb
CHANGED
data/ranked-model.gemspec
CHANGED
@@ -9,11 +9,11 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.authors = ["Matthew Beale"]
|
10
10
|
s.email = ["matt.beale@madhatted.com"]
|
11
11
|
s.homepage = "https://github.com/mixonic/ranked-model"
|
12
|
-
s.summary = %q{An acts_as_sortable replacement built for Rails
|
13
|
-
s.description = %q{ranked-model is a modern row sorting library built for Rails
|
12
|
+
s.summary = %q{An acts_as_sortable replacement built for Rails 4.2+}
|
13
|
+
s.description = %q{ranked-model is a modern row sorting library built for Rails 4.2+. It uses ARel aggressively and is better optimized than most other libraries.}
|
14
14
|
s.license = 'MIT'
|
15
15
|
|
16
|
-
s.add_dependency "activerecord", ">= 4.
|
16
|
+
s.add_dependency "activerecord", ">= 4.2"
|
17
17
|
s.add_development_dependency "rspec", "~> 3"
|
18
18
|
s.add_development_dependency "rspec-its"
|
19
19
|
s.add_development_dependency "mocha"
|
@@ -48,9 +48,9 @@ describe Duck do
|
|
48
48
|
}
|
49
49
|
@ducks.each { |name, duck|
|
50
50
|
duck.reload
|
51
|
-
duck.
|
52
|
-
duck.
|
53
|
-
duck.
|
51
|
+
duck.update :row_position => 0
|
52
|
+
duck.update :size_position => 0
|
53
|
+
duck.update :age_position => 0
|
54
54
|
duck.save!
|
55
55
|
}
|
56
56
|
@ducks.each {|name, duck| duck.reload }
|
@@ -59,8 +59,8 @@ describe Duck do
|
|
59
59
|
describe "sorting by size on in_shin_pond" do
|
60
60
|
|
61
61
|
before {
|
62
|
-
@ducks[:quacky].
|
63
|
-
@ducks[:wingy].
|
62
|
+
@ducks[:quacky].update :size_position => 0
|
63
|
+
@ducks[:wingy].update :size_position => 2
|
64
64
|
}
|
65
65
|
|
66
66
|
subject { Duck.in_shin_pond.rank(:size).to_a }
|
@@ -76,8 +76,8 @@ describe Duck do
|
|
76
76
|
describe "sorting by age on Shin pond" do
|
77
77
|
|
78
78
|
before {
|
79
|
-
@ducks[:feathers].
|
80
|
-
@ducks[:wingy].
|
79
|
+
@ducks[:feathers].update :age_position => 0
|
80
|
+
@ducks[:wingy].update :age_position => 0
|
81
81
|
}
|
82
82
|
|
83
83
|
subject { Duck.where(:pond => 'Shin').rank(:age).to_a }
|
@@ -93,10 +93,10 @@ describe Duck do
|
|
93
93
|
describe "sorting by row" do
|
94
94
|
|
95
95
|
before {
|
96
|
-
@ducks[:beaky].
|
97
|
-
@ducks[:webby].
|
98
|
-
@ducks[:waddly].
|
99
|
-
@ducks[:wingy].
|
96
|
+
@ducks[:beaky].update :row_position => 0
|
97
|
+
@ducks[:webby].update :row_position => 2
|
98
|
+
@ducks[:waddly].update :row_position => 2
|
99
|
+
@ducks[:wingy].update :row_position => 6
|
100
100
|
}
|
101
101
|
|
102
102
|
subject { Duck.rank(:row).to_a }
|
@@ -112,13 +112,13 @@ describe Duck do
|
|
112
112
|
describe "mixed sorting by" do
|
113
113
|
|
114
114
|
before {
|
115
|
-
@ducks[:quacky].
|
116
|
-
@ducks[:beaky].
|
117
|
-
@ducks[:webby].
|
118
|
-
@ducks[:wingy].
|
119
|
-
@ducks[:waddly].
|
120
|
-
@ducks[:wingy].
|
121
|
-
@ducks[:webby].
|
115
|
+
@ducks[:quacky].update :size_position => 0
|
116
|
+
@ducks[:beaky].update :row_position => 0
|
117
|
+
@ducks[:webby].update :row_position => 2
|
118
|
+
@ducks[:wingy].update :size_position => 1
|
119
|
+
@ducks[:waddly].update :row_position => 2
|
120
|
+
@ducks[:wingy].update :row_position => 6
|
121
|
+
@ducks[:webby].update :row_position => 6
|
122
122
|
}
|
123
123
|
|
124
124
|
describe "row" do
|
@@ -153,7 +153,7 @@ describe Duck do
|
|
153
153
|
# puts Duck.rank(:age).collect {|duck| "#{duck.name} #{duck.age}" }
|
154
154
|
duck = Duck.rank(:age)[2]
|
155
155
|
expect(->{
|
156
|
-
duck.
|
156
|
+
duck.update :name => 'New Name'
|
157
157
|
}).to_not change(duck.reload, :age)
|
158
158
|
# puts Duck.rank(:age).collect {|duck| "#{duck.name} #{duck.age}" }
|
159
159
|
end
|
@@ -187,7 +187,7 @@ describe Duck do
|
|
187
187
|
|
188
188
|
before {
|
189
189
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:wingy].id).collect {|duck| duck.id }
|
190
|
-
@ducks[:wingy].
|
190
|
+
@ducks[:wingy].update :row_position => 2
|
191
191
|
}
|
192
192
|
|
193
193
|
context {
|
@@ -214,7 +214,7 @@ describe Duck do
|
|
214
214
|
|
215
215
|
before {
|
216
216
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:wingy].id).collect {|duck| duck.id }
|
217
|
-
@ducks[:wingy].
|
217
|
+
@ducks[:wingy].update :row_position => 0
|
218
218
|
}
|
219
219
|
|
220
220
|
context {
|
@@ -254,7 +254,7 @@ describe Duck do
|
|
254
254
|
|
255
255
|
context {
|
256
256
|
|
257
|
-
before { @ducks[:wingy].
|
257
|
+
before { @ducks[:wingy].update :row_position => (@ducks.size - 2) }
|
258
258
|
|
259
259
|
subject { Duck.ranker(:row).with(Duck.new).current_at_position(@ducks.size - 2).instance }
|
260
260
|
|
@@ -264,7 +264,7 @@ describe Duck do
|
|
264
264
|
|
265
265
|
context {
|
266
266
|
|
267
|
-
before { @ducks[:wingy].
|
267
|
+
before { @ducks[:wingy].update :row_position => :down }
|
268
268
|
|
269
269
|
subject { Duck.ranker(:row).with(Duck.new).current_at_position(@ducks.size - 2).instance }
|
270
270
|
|
@@ -278,7 +278,7 @@ describe Duck do
|
|
278
278
|
|
279
279
|
before {
|
280
280
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:wingy].id).collect {|duck| duck.id }
|
281
|
-
@ducks[:wingy].
|
281
|
+
@ducks[:wingy].update :row_position => (@ducks.size - 1)
|
282
282
|
}
|
283
283
|
|
284
284
|
context {
|
@@ -319,7 +319,7 @@ describe Duck do
|
|
319
319
|
|
320
320
|
before {
|
321
321
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:wingy].id).collect {|duck| duck.id }
|
322
|
-
@ducks[:wingy].
|
322
|
+
@ducks[:wingy].update :row_position => :last
|
323
323
|
}
|
324
324
|
|
325
325
|
context {
|
@@ -360,7 +360,7 @@ describe Duck do
|
|
360
360
|
|
361
361
|
before {
|
362
362
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:wingy].id).collect {|duck| duck.id }
|
363
|
-
@ducks[:wingy].
|
363
|
+
@ducks[:wingy].update :row_position => 'last'
|
364
364
|
}
|
365
365
|
|
366
366
|
context {
|
@@ -403,7 +403,7 @@ describe Duck do
|
|
403
403
|
|
404
404
|
before {
|
405
405
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:wingy].id).collect { |duck| duck.id }
|
406
|
-
@ducks[:wingy].
|
406
|
+
@ducks[:wingy].update :row_position => :down
|
407
407
|
}
|
408
408
|
|
409
409
|
context {
|
@@ -430,7 +430,7 @@ describe Duck do
|
|
430
430
|
|
431
431
|
before {
|
432
432
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:quacky].id).collect { |duck| duck.id }
|
433
|
-
@ducks[:quacky].
|
433
|
+
@ducks[:quacky].update :row_position => :down
|
434
434
|
}
|
435
435
|
|
436
436
|
context {
|
@@ -455,7 +455,7 @@ describe Duck do
|
|
455
455
|
|
456
456
|
before {
|
457
457
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:feathers].id).collect { |duck| duck.id }
|
458
|
-
@ducks[:feathers].
|
458
|
+
@ducks[:feathers].update :row_position => :down
|
459
459
|
}
|
460
460
|
|
461
461
|
context {
|
@@ -484,7 +484,7 @@ describe Duck do
|
|
484
484
|
|
485
485
|
before {
|
486
486
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:wingy].id).collect { |duck| duck.id }
|
487
|
-
@ducks[:wingy].
|
487
|
+
@ducks[:wingy].update :row_position => 'down'
|
488
488
|
}
|
489
489
|
|
490
490
|
context {
|
@@ -511,7 +511,7 @@ describe Duck do
|
|
511
511
|
|
512
512
|
before {
|
513
513
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:quacky].id).collect { |duck| duck.id }
|
514
|
-
@ducks[:quacky].
|
514
|
+
@ducks[:quacky].update :row_position => 'down'
|
515
515
|
}
|
516
516
|
|
517
517
|
context {
|
@@ -536,7 +536,7 @@ describe Duck do
|
|
536
536
|
|
537
537
|
before {
|
538
538
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:feathers].id).collect { |duck| duck.id }
|
539
|
-
@ducks[:feathers].
|
539
|
+
@ducks[:feathers].update :row_position => 'down'
|
540
540
|
}
|
541
541
|
|
542
542
|
context {
|
@@ -565,7 +565,7 @@ describe Duck do
|
|
565
565
|
|
566
566
|
before {
|
567
567
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:wingy].id).collect { |duck| duck.id }
|
568
|
-
@ducks[:wingy].
|
568
|
+
@ducks[:wingy].update :row_position => :up
|
569
569
|
}
|
570
570
|
|
571
571
|
context {
|
@@ -592,7 +592,7 @@ describe Duck do
|
|
592
592
|
|
593
593
|
before {
|
594
594
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:beaky].id).collect { |duck| duck.id }
|
595
|
-
@ducks[:beaky].
|
595
|
+
@ducks[:beaky].update :row_position => :up
|
596
596
|
}
|
597
597
|
|
598
598
|
context {
|
@@ -617,7 +617,7 @@ describe Duck do
|
|
617
617
|
|
618
618
|
before {
|
619
619
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:waddly].id).collect { |duck| duck.id }
|
620
|
-
@ducks[:waddly].
|
620
|
+
@ducks[:waddly].update :row_position => :up
|
621
621
|
}
|
622
622
|
|
623
623
|
context {
|
@@ -645,7 +645,7 @@ describe Duck do
|
|
645
645
|
Duck.where(id: @ducks[name].id).update_all(row: i)
|
646
646
|
@ducks[name].reload
|
647
647
|
end
|
648
|
-
@ducks[:wingy].
|
648
|
+
@ducks[:wingy].update :row_position => :up
|
649
649
|
}
|
650
650
|
|
651
651
|
context {
|
@@ -675,7 +675,7 @@ describe Duck do
|
|
675
675
|
|
676
676
|
before {
|
677
677
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:wingy].id).collect { |duck| duck.id }
|
678
|
-
@ducks[:wingy].
|
678
|
+
@ducks[:wingy].update :row_position => 'up'
|
679
679
|
}
|
680
680
|
|
681
681
|
context {
|
@@ -702,7 +702,7 @@ describe Duck do
|
|
702
702
|
|
703
703
|
before {
|
704
704
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:beaky].id).collect { |duck| duck.id }
|
705
|
-
@ducks[:beaky].
|
705
|
+
@ducks[:beaky].update :row_position => 'up'
|
706
706
|
}
|
707
707
|
|
708
708
|
context {
|
@@ -727,7 +727,7 @@ describe Duck do
|
|
727
727
|
|
728
728
|
before {
|
729
729
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_eq @ducks[:waddly].id).collect { |duck| duck.id }
|
730
|
-
@ducks[:waddly].
|
730
|
+
@ducks[:waddly].update :row_position => 'up'
|
731
731
|
}
|
732
732
|
|
733
733
|
context {
|
@@ -779,6 +779,36 @@ describe Duck do
|
|
779
779
|
}
|
780
780
|
end
|
781
781
|
|
782
|
+
describe "when moving between ponds should work when rebalancing" do
|
783
|
+
|
784
|
+
before {
|
785
|
+
[:feathers, :wingy, :webby, :waddly, :beaky].each_with_index do |name, i|
|
786
|
+
Duck.where(id: @ducks[name].id).update_all(age: RankedModel::MIN_RANK_VALUE + i, pond: "Boyden")
|
787
|
+
@ducks[name].reload
|
788
|
+
end
|
789
|
+
|
790
|
+
Duck.find_by(id: @ducks[:quacky]).update!(age_position: 2, pond: "Boyden")
|
791
|
+
}
|
792
|
+
|
793
|
+
context {
|
794
|
+
subject { Duck.find_by(id: @ducks[:feathers]).age_rank }
|
795
|
+
|
796
|
+
it { should == 0 }
|
797
|
+
}
|
798
|
+
|
799
|
+
context {
|
800
|
+
subject { Duck.find_by(id: @ducks[:quacky]).age_rank }
|
801
|
+
|
802
|
+
it { should == 2 }
|
803
|
+
}
|
804
|
+
|
805
|
+
context {
|
806
|
+
subject { Duck.find_by(id: @ducks[:beaky]).age_rank }
|
807
|
+
|
808
|
+
it { should == 5 }
|
809
|
+
}
|
810
|
+
end
|
811
|
+
|
782
812
|
end
|
783
813
|
|
784
814
|
describe Duck do
|
@@ -812,7 +842,7 @@ describe Duck do
|
|
812
842
|
}
|
813
843
|
@ducks.each { |name, duck|
|
814
844
|
duck.reload
|
815
|
-
duck.
|
845
|
+
duck.update :landing_order_position => 0
|
816
846
|
duck.save!
|
817
847
|
}
|
818
848
|
@ducks.each {|name, duck| duck.reload }
|
@@ -821,8 +851,8 @@ describe Duck do
|
|
821
851
|
describe "sorting by landing_order" do
|
822
852
|
|
823
853
|
before {
|
824
|
-
@ducks[:quacky].
|
825
|
-
@ducks[:wingy].
|
854
|
+
@ducks[:quacky].update :landing_order_position => 0
|
855
|
+
@ducks[:wingy].update :landing_order_position => 1
|
826
856
|
}
|
827
857
|
|
828
858
|
subject { Duck.in_lake_and_flock(0,0).rank(:landing_order).to_a }
|
@@ -846,10 +876,10 @@ describe Duck do
|
|
846
876
|
|
847
877
|
@previous_ranks = @untouchable_ranks.call
|
848
878
|
|
849
|
-
@ducks[:quacky].
|
850
|
-
@ducks[:wingy].
|
851
|
-
@ducks[:feathers].
|
852
|
-
@ducks[:wingy].
|
879
|
+
@ducks[:quacky].update :landing_order_position => 0
|
880
|
+
@ducks[:wingy].update :landing_order_position => 1
|
881
|
+
@ducks[:feathers].update :landing_order_position => 0
|
882
|
+
@ducks[:wingy].update :landing_order_position => 1
|
853
883
|
}
|
854
884
|
|
855
885
|
subject { @untouchable_ranks.call }
|
@@ -29,7 +29,7 @@ describe Duck do
|
|
29
29
|
|
30
30
|
before {
|
31
31
|
@last = Duck.last
|
32
|
-
@last.
|
32
|
+
@last.update :row_position => 137
|
33
33
|
}
|
34
34
|
|
35
35
|
subject { Duck.ranker(:row).with(Duck.new).current_at_position(137).instance }
|
@@ -42,7 +42,7 @@ describe Duck do
|
|
42
42
|
|
43
43
|
before {
|
44
44
|
@last = Duck.last
|
45
|
-
@last.
|
45
|
+
@last.update :row_position => 2
|
46
46
|
}
|
47
47
|
|
48
48
|
subject { Duck.ranker(:row).with(Duck.new).current_at_position(2).instance }
|
@@ -55,7 +55,7 @@ describe Duck do
|
|
55
55
|
|
56
56
|
before {
|
57
57
|
@last = Duck.last
|
58
|
-
@last.
|
58
|
+
@last.update :row_position => :last
|
59
59
|
}
|
60
60
|
|
61
61
|
subject { Duck.rank(:row).last }
|
@@ -68,7 +68,7 @@ describe Duck do
|
|
68
68
|
|
69
69
|
before {
|
70
70
|
@last = Duck.last
|
71
|
-
@last.
|
71
|
+
@last.update :row_position => :first
|
72
72
|
}
|
73
73
|
|
74
74
|
subject { Duck.rank(:row).first }
|
@@ -87,8 +87,8 @@ describe Duck do
|
|
87
87
|
@first = Duck.first
|
88
88
|
@second = Duck.offset(1).first
|
89
89
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_in([@first.id, @second.id])).collect {|d| d.id }
|
90
|
-
@first.
|
91
|
-
@second.
|
90
|
+
@first.update :row => RankedModel::MAX_RANK_VALUE
|
91
|
+
@second.update :row => RankedModel::MAX_RANK_VALUE
|
92
92
|
}
|
93
93
|
|
94
94
|
context {
|
@@ -105,13 +105,13 @@ describe Duck do
|
|
105
105
|
|
106
106
|
before {
|
107
107
|
Duck.first(50).each_with_index do |d, index|
|
108
|
-
d.
|
108
|
+
d.update :age => index % 10, :pond => "Pond #{index / 10}"
|
109
109
|
end
|
110
110
|
@duck_11 = Duck.where(:pond => 'Pond 1').rank(:age).first
|
111
111
|
@duck_12 = Duck.where(:pond => 'Pond 1').rank(:age).second
|
112
112
|
@ordered = Duck.where(:pond => 'Pond 1').rank(:age).where(Duck.arel_table[:id].not_in([@duck_11.id, @duck_12.id])).collect {|d| d.id }
|
113
|
-
@duck_11.
|
114
|
-
@duck_12.
|
113
|
+
@duck_11.update :age => RankedModel::MAX_RANK_VALUE
|
114
|
+
@duck_12.update :age => RankedModel::MAX_RANK_VALUE
|
115
115
|
}
|
116
116
|
|
117
117
|
context {
|
@@ -133,8 +133,8 @@ describe Duck do
|
|
133
133
|
@first = Duck.first
|
134
134
|
@second = Duck.offset(1).first
|
135
135
|
@ordered = Duck.rank(:row).where(Duck.arel_table[:id].not_in([@first.id, @second.id])).collect {|d| d.id }
|
136
|
-
@first.
|
137
|
-
@second.
|
136
|
+
@first.update :row => RankedModel::MIN_RANK_VALUE
|
137
|
+
@second.update :row => RankedModel::MIN_RANK_VALUE
|
138
138
|
}
|
139
139
|
|
140
140
|
context {
|
@@ -163,11 +163,11 @@ describe Duck do
|
|
163
163
|
where(Duck.arel_table[:id].not_in([@first.id, @second.id, @third.id, @fourth.id, @fifth.id])).
|
164
164
|
where(Duck.arel_table[:row].gteq(RankedModel::MAX_RANK_VALUE / 2)).
|
165
165
|
collect {|d| d.id }
|
166
|
-
@first.
|
167
|
-
@second.
|
168
|
-
@third.
|
166
|
+
@first.update :row => RankedModel::MIN_RANK_VALUE
|
167
|
+
@second.update :row => RankedModel::MAX_RANK_VALUE
|
168
|
+
@third.update :row => (RankedModel::MAX_RANK_VALUE / 2)
|
169
169
|
Duck.where(id: @fifth.id).update_all row: @third.row
|
170
|
-
@fourth.
|
170
|
+
@fourth.update :row => @third.row
|
171
171
|
}
|
172
172
|
|
173
173
|
context {
|
data/spec/ego-model/ego_spec.rb
CHANGED
@@ -10,7 +10,7 @@ describe Ego do
|
|
10
10
|
}
|
11
11
|
@egos.each { |name, ego|
|
12
12
|
ego.reload
|
13
|
-
ego.
|
13
|
+
ego.update :size_position => 0
|
14
14
|
ego.save!
|
15
15
|
}
|
16
16
|
@egos.each {|name, ego| ego.reload }
|
@@ -19,8 +19,8 @@ describe Ego do
|
|
19
19
|
describe "sorting on size alternative primary key" do
|
20
20
|
|
21
21
|
before {
|
22
|
-
@egos[:nick].
|
23
|
-
@egos[:sally].
|
22
|
+
@egos[:nick].update :size_position => 0
|
23
|
+
@egos[:sally].update :size_position => 2
|
24
24
|
}
|
25
25
|
|
26
26
|
subject { Ego.rank(:size).to_a }
|
@@ -14,8 +14,8 @@ describe Number do
|
|
14
14
|
@first = Number.first
|
15
15
|
@second = Number.offset(1).first
|
16
16
|
@ordered = Number.rank(:order).where(Number.arel_table[:id].not_in([@first.id, @second.id])).collect {|d| d.id }
|
17
|
-
@first.
|
18
|
-
@second.
|
17
|
+
@first.update :order => RankedModel::MAX_RANK_VALUE
|
18
|
+
@second.update :order => RankedModel::MAX_RANK_VALUE
|
19
19
|
}
|
20
20
|
|
21
21
|
context {
|
@@ -16,7 +16,7 @@ describe Player do
|
|
16
16
|
|
17
17
|
describe "setting the position of a record that already exists" do
|
18
18
|
it "sets the rank without error" do
|
19
|
-
expect{@players[:bob].
|
19
|
+
expect{@players[:bob].update! :score_position => 1}.to_not raise_error
|
20
20
|
end
|
21
21
|
end
|
22
22
|
end
|
@@ -12,7 +12,7 @@ describe Element do
|
|
12
12
|
}
|
13
13
|
@elements.each { |name, element|
|
14
14
|
element.reload
|
15
|
-
element.
|
15
|
+
element.update :combination_order_position => 0
|
16
16
|
}
|
17
17
|
@elements.each {|name, element| element.reload }
|
18
18
|
}
|
@@ -20,9 +20,9 @@ describe Element do
|
|
20
20
|
describe "rebalancing on an STI class should not affect the other class" do
|
21
21
|
|
22
22
|
before {
|
23
|
-
@elements[:helium].
|
24
|
-
@elements[:xenon].
|
25
|
-
@elements[:argon].
|
23
|
+
@elements[:helium].update :combination_order_position => :first
|
24
|
+
@elements[:xenon].update :combination_order_position => :first
|
25
|
+
@elements[:argon].update :combination_order_position => :last
|
26
26
|
|
27
27
|
TransitionMetal.ranker(:combination_order).with(@elements[:chromium]).instance_eval { rebalance_ranks }
|
28
28
|
}
|
@@ -40,16 +40,16 @@ describe Element do
|
|
40
40
|
describe "setting positions on STI classes" do
|
41
41
|
|
42
42
|
before {
|
43
|
-
@elements[:helium].
|
44
|
-
@elements[:xenon].
|
45
|
-
@elements[:argon].
|
46
|
-
|
47
|
-
@elements[:chromium].
|
48
|
-
@elements[:manganese].
|
49
|
-
@elements[:manganese].
|
50
|
-
@elements[:chromium].
|
51
|
-
@elements[:manganese].
|
52
|
-
@elements[:chromium].
|
43
|
+
@elements[:helium].update :combination_order_position => :first
|
44
|
+
@elements[:xenon].update :combination_order_position => :first
|
45
|
+
@elements[:argon].update :combination_order_position => :first
|
46
|
+
|
47
|
+
@elements[:chromium].update :combination_order_position => 1
|
48
|
+
@elements[:manganese].update :combination_order_position => 1
|
49
|
+
@elements[:manganese].update :combination_order_position => 0
|
50
|
+
@elements[:chromium].update :combination_order_position => 0
|
51
|
+
@elements[:manganese].update :combination_order_position => 0
|
52
|
+
@elements[:chromium].update :combination_order_position => 0
|
53
53
|
}
|
54
54
|
|
55
55
|
describe "NobleGas" do
|
@@ -81,16 +81,16 @@ describe Element do
|
|
81
81
|
describe "setting positions on STI classes" do
|
82
82
|
|
83
83
|
before {
|
84
|
-
@elements[:helium].
|
85
|
-
@elements[:xenon].
|
86
|
-
@elements[:argon].
|
87
|
-
|
88
|
-
@elements[:chromium].
|
89
|
-
@elements[:manganese].
|
90
|
-
@elements[:manganese].
|
91
|
-
@elements[:chromium].
|
92
|
-
@elements[:manganese].
|
93
|
-
@elements[:chromium].
|
84
|
+
@elements[:helium].update :combination_order_position => :first
|
85
|
+
@elements[:xenon].update :combination_order_position => :first
|
86
|
+
@elements[:argon].update :combination_order_position => :first
|
87
|
+
|
88
|
+
@elements[:chromium].update :combination_order_position => 1
|
89
|
+
@elements[:manganese].update :combination_order_position => 1
|
90
|
+
@elements[:manganese].update :combination_order_position => 0
|
91
|
+
@elements[:chromium].update :combination_order_position => 0
|
92
|
+
@elements[:manganese].update :combination_order_position => 0
|
93
|
+
@elements[:chromium].update :combination_order_position => 0
|
94
94
|
}
|
95
95
|
|
96
96
|
describe "NobleGas" do
|
@@ -12,7 +12,7 @@ describe Vehicle do
|
|
12
12
|
}
|
13
13
|
@vehicles.each { |name, vehicle|
|
14
14
|
vehicle.reload
|
15
|
-
vehicle.
|
15
|
+
vehicle.update :parking_order_position => 0
|
16
16
|
}
|
17
17
|
@vehicles.each {|name, vehicle| vehicle.reload }
|
18
18
|
}
|
@@ -20,8 +20,8 @@ describe Vehicle do
|
|
20
20
|
describe "ranking by STI parent" do
|
21
21
|
|
22
22
|
before {
|
23
|
-
@vehicles[:volvo].
|
24
|
-
@vehicles[:ford].
|
23
|
+
@vehicles[:volvo].update :parking_order_position => :first
|
24
|
+
@vehicles[:ford].update :parking_order_position => :first
|
25
25
|
}
|
26
26
|
|
27
27
|
describe "Vehicle" do
|
@@ -72,4 +72,4 @@ describe Vehicle do
|
|
72
72
|
|
73
73
|
end
|
74
74
|
|
75
|
-
end
|
75
|
+
end
|
@@ -1,13 +1,13 @@
|
|
1
1
|
require 'active_record'
|
2
2
|
require 'logger'
|
3
3
|
|
4
|
-
|
5
|
-
|
6
|
-
|
4
|
+
unless ENV['DB']
|
5
|
+
ENV['DB'] = 'sqlite'
|
6
|
+
end
|
7
7
|
|
8
8
|
ActiveRecord::Base.logger = Logger.new('tmp/ar_debug.log')
|
9
9
|
ActiveRecord::Base.configurations = YAML::load(IO.read('spec/support/database.yml'))
|
10
|
-
ActiveRecord::Base.establish_connection(
|
10
|
+
ActiveRecord::Base.establish_connection(ENV['DB'].to_sym)
|
11
11
|
|
12
12
|
ActiveRecord::Schema.define :version => 0 do
|
13
13
|
create_table :ducks, :force => true do |t|
|
@@ -148,7 +148,7 @@ class MotorBike < Vehicle
|
|
148
148
|
end
|
149
149
|
|
150
150
|
class Ego < ActiveRecord::Base
|
151
|
-
primary_key = :alternative_to_id
|
151
|
+
self.primary_key = :alternative_to_id
|
152
152
|
include RankedModel
|
153
153
|
ranks :size
|
154
154
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ranked-model
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.4.
|
4
|
+
version: 0.4.5
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matthew Beale
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2020-01-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activerecord
|
@@ -16,14 +16,14 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: 4.
|
19
|
+
version: '4.2'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: 4.
|
26
|
+
version: '4.2'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rspec
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -122,7 +122,7 @@ dependencies:
|
|
122
122
|
- - ">="
|
123
123
|
- !ruby/object:Gem::Version
|
124
124
|
version: '0'
|
125
|
-
description: ranked-model is a modern row sorting library built for Rails
|
125
|
+
description: ranked-model is a modern row sorting library built for Rails 4.2+. It
|
126
126
|
uses ARel aggressively and is better optimized than most other libraries.
|
127
127
|
email:
|
128
128
|
- matt.beale@madhatted.com
|
@@ -138,11 +138,11 @@ files:
|
|
138
138
|
- LICENSE
|
139
139
|
- Rakefile
|
140
140
|
- Readme.mkd
|
141
|
-
- gemfiles/rails_4_1.gemfile
|
142
141
|
- gemfiles/rails_4_2.gemfile
|
143
142
|
- gemfiles/rails_5_0.gemfile
|
144
143
|
- gemfiles/rails_5_1.gemfile
|
145
144
|
- gemfiles/rails_5_2.gemfile
|
145
|
+
- gemfiles/rails_6_0.gemfile
|
146
146
|
- lib/ranked-model.rb
|
147
147
|
- lib/ranked-model/railtie.rb
|
148
148
|
- lib/ranked-model/ranker.rb
|
@@ -183,11 +183,10 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
183
183
|
- !ruby/object:Gem::Version
|
184
184
|
version: '0'
|
185
185
|
requirements: []
|
186
|
-
|
187
|
-
rubygems_version: 2.5.2.2
|
186
|
+
rubygems_version: 3.0.3
|
188
187
|
signing_key:
|
189
188
|
specification_version: 4
|
190
|
-
summary: An acts_as_sortable replacement built for Rails
|
189
|
+
summary: An acts_as_sortable replacement built for Rails 4.2+
|
191
190
|
test_files:
|
192
191
|
- spec/duck-model/column_default_ducks_spec.rb
|
193
192
|
- spec/duck-model/duck_spec.rb
|
data/gemfiles/rails_4_1.gemfile
DELETED
@@ -1,22 +0,0 @@
|
|
1
|
-
# This file was generated by Appraisal
|
2
|
-
|
3
|
-
source "https://rubygems.org"
|
4
|
-
|
5
|
-
gem "activerecord", "~> 4.1.16"
|
6
|
-
|
7
|
-
group :sqlite do
|
8
|
-
gem "sqlite3", "~> 1.3.13", platform: :ruby
|
9
|
-
gem "activerecord-jdbcsqlite3-adapter", "~> 1.3.24", platform: :jruby
|
10
|
-
end
|
11
|
-
|
12
|
-
group :mysql do
|
13
|
-
gem "mysql2", "~> 0.3.21", platform: :ruby
|
14
|
-
gem "activerecord-jdbcmysql-adapter", "~> 1.3.24", platform: :jruby
|
15
|
-
end
|
16
|
-
|
17
|
-
group :postgresql do
|
18
|
-
gem "pg", "~> 0.18.0", platform: :ruby
|
19
|
-
gem "activerecord-jdbcpostgresql-adapter", "~> 1.3.24", platform: :jruby
|
20
|
-
end
|
21
|
-
|
22
|
-
gemspec path: "../"
|