acts_as_list 0.9.8 → 0.9.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: 864fb6e920d9bb5ca2b305e4e76b95519b900ecc
4
- data.tar.gz: 5ee3657665bae3f1da65b9d91d43a2764b05f6eb
3
+ metadata.gz: b6d2515099c8746c438ada6bfd3307841f7a66d7
4
+ data.tar.gz: 3d5980d4d52abd7957daef5f851caceb967fd7e1
5
5
  SHA512:
6
- metadata.gz: af1bf25445a284d3911f876a8c3fe45c083c1af5cec67f141e72ba1e6035f17011cac9157f74f4e712ff366641d97e0634ef85297771cc868e051d0297e6008d
7
- data.tar.gz: 623352d9b387dbe134c14ffe301eac69744e5eb63f49108da683e924f90ea16151015ab6faf296f93e5513eaf7872332a9746cabaf9d459ab2e1dafa83c4d2ba
6
+ metadata.gz: b9bc5985bcccdd1f02cd4f5f814d5abba57745c29c28ea158a95de849f4e36954a9a944919fbefe418af4518a32d58746a0427474a4055bbe44672d8e4b54e94
7
+ data.tar.gz: 048b80713d0cf58cbd717d337d58869ae0b5c09704c1a40a9503e6d05a4979be8ee517d9dc2c1877445d2c0194854f5c01a5ad220d8210414ca1ba80afed2fc6
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## [v0.9.8](https://github.com/swanandp/acts_as_list/tree/v0.9.8) (2017-09-28)
4
+ [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.9.7...v0.9.8)
5
+
6
+ **Closed issues:**
7
+
8
+ - Deadlocking in update\_positions count query [\#285](https://github.com/swanandp/acts_as_list/issues/285)
9
+ - Updating the position fails uniqueness constraint. [\#275](https://github.com/swanandp/acts_as_list/issues/275)
10
+
3
11
  ## [v0.9.7](https://github.com/swanandp/acts_as_list/tree/v0.9.7) (2017-07-06)
4
12
  [Full Changelog](https://github.com/swanandp/acts_as_list/compare/v0.9.6...v0.9.7)
5
13
 
data/README.md CHANGED
@@ -115,6 +115,22 @@ class TodoItem < ActiveRecord::Base
115
115
  end
116
116
  ```
117
117
 
118
+ You can also add multiple scopes in this fashion:
119
+ ```ruby
120
+ class TodoItem < ActiveRecord::Base
121
+ acts_as_list scope: [:kind, :owner_id]
122
+ end
123
+ ```
124
+
125
+ Furthermore, you can optionally include a hash of fixed parameters that will be included in all queries:
126
+ ```ruby
127
+ class TodoItem < ActiveRecord::Base
128
+ acts_as_list scope: [:kind, :owner_id, deleted_at: nil]
129
+ end
130
+ ```
131
+
132
+ This is useful when using this gem in conjunction with the popular [acts_as_paranoid](https://github.com/ActsAsParanoid/acts_as_paranoid) gem.
133
+
118
134
  ## More Options
119
135
  - `column`
120
136
  default: `position`. Use this option if the column name in your database is different from position.
@@ -24,8 +24,17 @@ module ActiveRecord::Acts::List::ScopeMethodDefiner #:nodoc:
24
24
  end
25
25
  elsif scope.is_a?(Array)
26
26
  define_method :scope_condition do
27
- scope.inject({}) do |hash, column|
28
- hash.merge!({ column.to_sym => read_attribute(column.to_sym) })
27
+ # The elements of the Array can be symbols, strings, or hashes.
28
+ # If symbols or strings, they are treated as column names and the current value is looked up.
29
+ # If hashes, they are treated as fixed values.
30
+ scope.inject({}) do |hash, column_or_fixed_vals|
31
+ if column_or_fixed_vals.is_a?(Hash)
32
+ fixed_vals = column_or_fixed_vals
33
+ hash.merge!(fixed_vals)
34
+ else
35
+ column = column_or_fixed_vals
36
+ hash.merge!({ column.to_sym => read_attribute(column.to_sym) })
37
+ end
29
38
  end
30
39
  end
31
40
 
@@ -1,7 +1,7 @@
1
1
  module ActiveRecord
2
2
  module Acts
3
3
  module List
4
- VERSION = '0.9.8'
4
+ VERSION = '0.9.9'
5
5
  end
6
6
  end
7
7
  end
data/test/test_list.rb CHANGED
@@ -80,6 +80,10 @@ class ArrayScopeListMixin < Mixin
80
80
  acts_as_list column: "pos", scope: [:parent_id, :parent_type]
81
81
  end
82
82
 
83
+ class ArrayScopeListWithHashMixin < Mixin
84
+ acts_as_list column: "pos", scope: [:parent_id, state: nil]
85
+ end
86
+
83
87
  if rails_4
84
88
  class EnumArrayScopeListMixin < Mixin
85
89
  STATE_VALUES = %w(active archived)
@@ -707,6 +711,20 @@ class MultipleListsArrayScopeTest < ActsAsListTestCase
707
711
  end
708
712
  end
709
713
 
714
+ class ArrayScopeListWithHashTest
715
+ def setup
716
+ setup_db
717
+ @obj1 = ArrayScopeListWithHashMixin.create! :pos => counter, :parent_id => 1, :state => nil
718
+ @obj2 = ArrayScopeListWithHashMixin.create! :pos => counter, :parent_id => 1, :state => 'anything'
719
+ end
720
+
721
+ def test_scope_condition_correct
722
+ [@obj1, @obj2].each do |obj|
723
+ assert_equal({ :parent_id => 1, :state => nil }, obj.scope_condition)
724
+ end
725
+ end
726
+ end
727
+
710
728
  require 'timecop'
711
729
 
712
730
  class TouchTest < ActsAsListTestCase
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: acts_as_list
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.9.8
4
+ version: 0.9.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - David Heinemeier Hansson
@@ -10,7 +10,7 @@ authors:
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
- date: 2017-09-28 00:00:00.000000000 Z
13
+ date: 2017-10-03 00:00:00.000000000 Z
14
14
  dependencies:
15
15
  - !ruby/object:Gem::Dependency
16
16
  name: activerecord