acts_as_list 0.7.2 → 0.7.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +8 -8
- data/.gitignore +2 -0
- data/.travis.yml +6 -0
- data/Appraisals +3 -3
- data/CHANGELOG.md +241 -0
- data/Gemfile +4 -1
- data/README.md +12 -3
- data/Rakefile +8 -0
- data/gemfiles/rails_3_2.gemfile +5 -2
- data/gemfiles/rails_4_1.gemfile +5 -2
- data/gemfiles/rails_4_2.gemfile +4 -2
- data/lib/acts_as_list/active_record/acts/list.rb +88 -85
- data/lib/acts_as_list/version.rb +1 -1
- data/test/helper.rb +7 -0
- data/test/test_list.rb +35 -0
- metadata +3 -5
- data/gemfiles/rails_3_2.gemfile.lock +0 -258
- data/gemfiles/rails_4_1.gemfile.lock +0 -262
- data/gemfiles/rails_4_2.gemfile.lock +0 -53
checksums.yaml
CHANGED
@@ -1,15 +1,15 @@
|
|
1
1
|
---
|
2
2
|
!binary "U0hBMQ==":
|
3
3
|
metadata.gz: !binary |-
|
4
|
-
|
4
|
+
ODI0OTU2NzgzMmY0MmI3YjMyMDk2ZDg5YWJjNjkxZDE4ZjViODliYQ==
|
5
5
|
data.tar.gz: !binary |-
|
6
|
-
|
6
|
+
OThlMWNiYjU3MGRmMGQzNjA5NzQ1MDk1MzdiYTg1MGFjODJlNDJmYQ==
|
7
7
|
SHA512:
|
8
8
|
metadata.gz: !binary |-
|
9
|
-
|
10
|
-
|
11
|
-
|
9
|
+
ZDMzOWRkNzQ2ZjNmZGRlM2QxYzJkN2VjYzM2MGY1Yzk4MjE1MmZiOWQyZjY1
|
10
|
+
NmY4Y2FjY2U4YjczNjliZjFmYzYwYmMzYTNlNTA2MjU4NmVlODFmMzg1NGY0
|
11
|
+
OWNkN2Y4MGU2ZTM4YjM2YjY0MTZkNjcwMjk0NmQ1YzBkMmNjYjE=
|
12
12
|
data.tar.gz: !binary |-
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Mzg4NGQwNmY2NjdjN2MxZWIzYWE4MWNiOTlkMTc5NGM5NTRiMzRmY2MwNDVh
|
14
|
+
ODI2YTVhZmUwMzE1OTAwNzA1OWZjMjc3ZGNhZmI1Y2ZmNmU4NmYzNGQ3ZTc1
|
15
|
+
OGUyZDE0NjZkZTVjNmQxZTJhOWUyNjdhOWIwMjJiMTg2YzA2NWI=
|
data/.gitignore
CHANGED
data/.travis.yml
CHANGED
@@ -1,4 +1,10 @@
|
|
1
1
|
language: ruby
|
2
|
+
# Explicit usage of containerized builds, should provide faster feedback
|
3
|
+
# see https://docs.travis-ci.com/user/workers/container-based-infrastructure/
|
4
|
+
# and https://docs.travis-ci.com/user/ci-environment/#Virtualization-environments
|
5
|
+
sudo: false
|
6
|
+
before_install:
|
7
|
+
- gem update bundler
|
2
8
|
rvm:
|
3
9
|
- 1.9.3
|
4
10
|
- 2.0.0
|
data/Appraisals
CHANGED
@@ -1,11 +1,11 @@
|
|
1
1
|
appraise "rails-3-2" do
|
2
|
-
gem "activerecord", "3.2.21"
|
2
|
+
gem "activerecord", "~> 3.2.21"
|
3
3
|
end
|
4
4
|
|
5
5
|
appraise "rails-4-1" do
|
6
|
-
gem "activerecord", "4.1.10"
|
6
|
+
gem "activerecord", "~> 4.1.10"
|
7
7
|
end
|
8
8
|
|
9
9
|
appraise "rails-4-2" do
|
10
|
-
gem "activerecord", "4.2.1"
|
10
|
+
gem "activerecord", "~> 4.2.1"
|
11
11
|
end
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,241 @@
|
|
1
|
+
# Change Log
|
2
|
+
|
3
|
+
## [v0.7.3](https://github.com/swanandp/acts_as_list/tree/v0.7.3) (2016-04-14)
|
4
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.7.1...v0.7.3)
|
5
|
+
|
6
|
+
**Closed issues:**
|
7
|
+
|
8
|
+
- DEPRECATION WARNING: Passing string to define callback on Rails 5 beta 3 [\#191](https://github.com/swanandp/acts_as_list/issues/191)
|
9
|
+
- Why is `add\_to\_list\_bottom` private? [\#187](https://github.com/swanandp/acts_as_list/issues/187)
|
10
|
+
- Ordering of children when there are two possible parent models. [\#172](https://github.com/swanandp/acts_as_list/issues/172)
|
11
|
+
- Fix the jruby and rbx builds [\#169](https://github.com/swanandp/acts_as_list/issues/169)
|
12
|
+
- Unable to run tests [\#162](https://github.com/swanandp/acts_as_list/issues/162)
|
13
|
+
- shuffle\_positions\_on\_intermediate\_items is creating problems [\#134](https://github.com/swanandp/acts_as_list/issues/134)
|
14
|
+
- introduce Changelog file to quickly track changes [\#68](https://github.com/swanandp/acts_as_list/issues/68)
|
15
|
+
- Mongoid support? [\#52](https://github.com/swanandp/acts_as_list/issues/52)
|
16
|
+
|
17
|
+
**Merged pull requests:**
|
18
|
+
|
19
|
+
- Add filename/line number to class\_eval call [\#193](https://github.com/swanandp/acts_as_list/pull/193) ([hfwang](https://github.com/hfwang))
|
20
|
+
- Use a symbol as a string to define callback [\#192](https://github.com/swanandp/acts_as_list/pull/192) ([brendon](https://github.com/brendon))
|
21
|
+
- Pin changelog generator to a working version [\#190](https://github.com/swanandp/acts_as_list/pull/190) ([fabn](https://github.com/fabn))
|
22
|
+
- Fix bug, position is recomputed when object saved [\#188](https://github.com/swanandp/acts_as_list/pull/188) ([chrisortman](https://github.com/chrisortman))
|
23
|
+
- Update bundler before running tests, fixes test run on travis [\#179](https://github.com/swanandp/acts_as_list/pull/179) ([fabn](https://github.com/fabn))
|
24
|
+
- Changelog generator, closes \#68 [\#177](https://github.com/swanandp/acts_as_list/pull/177) ([fabn](https://github.com/fabn))
|
25
|
+
- Updating README example [\#175](https://github.com/swanandp/acts_as_list/pull/175) ([ryanbillings](https://github.com/ryanbillings))
|
26
|
+
- Adds description about various options available with the acts\_as\_list method [\#168](https://github.com/swanandp/acts_as_list/pull/168) ([udit7590](https://github.com/udit7590))
|
27
|
+
- Small changes to DRY up list.rb [\#163](https://github.com/swanandp/acts_as_list/pull/163) ([Albin-Willman](https://github.com/Albin-Willman))
|
28
|
+
- Only swap changed attributes which are persistable, i.e. are DB columns. [\#152](https://github.com/swanandp/acts_as_list/pull/152) ([ludwigschubert](https://github.com/ludwigschubert))
|
29
|
+
|
30
|
+
## [0.7.2](https://github.com/swanandp/acts_as_list/tree/0.7.2) (2015-05-06)
|
31
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.7.1...0.7.2)
|
32
|
+
|
33
|
+
## [0.7.1](https://github.com/swanandp/acts_as_list/tree/0.7.1) (2015-05-06)
|
34
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.7.0...0.7.1)
|
35
|
+
|
36
|
+
**Merged pull requests:**
|
37
|
+
|
38
|
+
- Update README.md [\#159](https://github.com/swanandp/acts_as_list/pull/159) ([tibastral](https://github.com/tibastral))
|
39
|
+
|
40
|
+
## [0.7.0](https://github.com/swanandp/acts_as_list/tree/0.7.0) (2015-05-01)
|
41
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.6.0...0.7.0)
|
42
|
+
|
43
|
+
**Closed issues:**
|
44
|
+
|
45
|
+
- Problem with reordering scoped list items [\#154](https://github.com/swanandp/acts_as_list/issues/154)
|
46
|
+
- Can no longer load acts\_as\_list in isolation if Rails is installed [\#145](https://github.com/swanandp/acts_as_list/issues/145)
|
47
|
+
|
48
|
+
**Merged pull requests:**
|
49
|
+
|
50
|
+
- Fix regression with using acts\_as\_list on base classes [\#147](https://github.com/swanandp/acts_as_list/pull/147) ([botandrose](https://github.com/botandrose))
|
51
|
+
- Don't require rails when loading [\#146](https://github.com/swanandp/acts_as_list/pull/146) ([botandrose](https://github.com/botandrose))
|
52
|
+
|
53
|
+
## [0.6.0](https://github.com/swanandp/acts_as_list/tree/0.6.0) (2014-12-24)
|
54
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.5.0...0.6.0)
|
55
|
+
|
56
|
+
**Closed issues:**
|
57
|
+
|
58
|
+
- Deprecation Warning: sanitize\_sql\_hash\_for\_conditions is deprecated and will be removed in Rails 5.0 [\#143](https://github.com/swanandp/acts_as_list/issues/143)
|
59
|
+
- Release a new gem version [\#136](https://github.com/swanandp/acts_as_list/issues/136)
|
60
|
+
|
61
|
+
**Merged pull requests:**
|
62
|
+
|
63
|
+
- Fix sanitize\_sql\_hash\_for\_conditions deprecation warning in Rails 4.2 [\#140](https://github.com/swanandp/acts_as_list/pull/140) ([eagletmt](https://github.com/eagletmt))
|
64
|
+
- Simpler method to find the subclass name [\#139](https://github.com/swanandp/acts_as_list/pull/139) ([brendon](https://github.com/brendon))
|
65
|
+
- Rails4 enum column support [\#130](https://github.com/swanandp/acts_as_list/pull/130) ([arunagw](https://github.com/arunagw))
|
66
|
+
- use eval for determing the self.class.name useful when this is used in an abstract class [\#123](https://github.com/swanandp/acts_as_list/pull/123) ([flarik](https://github.com/flarik))
|
67
|
+
|
68
|
+
## [0.5.0](https://github.com/swanandp/acts_as_list/tree/0.5.0) (2014-10-31)
|
69
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.4.0...0.5.0)
|
70
|
+
|
71
|
+
**Closed issues:**
|
72
|
+
|
73
|
+
- I want to have my existing records works like list [\#133](https://github.com/swanandp/acts_as_list/issues/133)
|
74
|
+
- Add Support For Multiple Indexes [\#127](https://github.com/swanandp/acts_as_list/issues/127)
|
75
|
+
- changing parent\_id does not update item positions [\#126](https://github.com/swanandp/acts_as_list/issues/126)
|
76
|
+
- How to exclude objects to be positioned? [\#125](https://github.com/swanandp/acts_as_list/issues/125)
|
77
|
+
- Scope for Polymorphic association + ManyToMany [\#106](https://github.com/swanandp/acts_as_list/issues/106)
|
78
|
+
- Bug when use \#insert\_at on an invalid ActiveRecord object [\#99](https://github.com/swanandp/acts_as_list/issues/99)
|
79
|
+
- has\_many :through with acts as list [\#95](https://github.com/swanandp/acts_as_list/issues/95)
|
80
|
+
- Update position when scope changes [\#19](https://github.com/swanandp/acts_as_list/issues/19)
|
81
|
+
|
82
|
+
**Merged pull requests:**
|
83
|
+
|
84
|
+
- Cast column default value to int before comparing with position column [\#129](https://github.com/swanandp/acts_as_list/pull/129) ([wioux](https://github.com/wioux))
|
85
|
+
- Fix travis builds for rbx [\#128](https://github.com/swanandp/acts_as_list/pull/128) ([meineerde](https://github.com/meineerde))
|
86
|
+
- Use unscoped blocks instead of chaining [\#121](https://github.com/swanandp/acts_as_list/pull/121) ([brendon](https://github.com/brendon))
|
87
|
+
- Make acts\_as\_list more compatible with BINARY column [\#116](https://github.com/swanandp/acts_as_list/pull/116) ([sikachu](https://github.com/sikachu))
|
88
|
+
- Added help notes on non-association scopes [\#115](https://github.com/swanandp/acts_as_list/pull/115) ([VorontsovIE](https://github.com/VorontsovIE))
|
89
|
+
- Let AR::Base properly lazy-loaded if Railtie is available [\#114](https://github.com/swanandp/acts_as_list/pull/114) ([amatsuda](https://github.com/amatsuda))
|
90
|
+
|
91
|
+
## [0.4.0](https://github.com/swanandp/acts_as_list/tree/0.4.0) (2014-02-22)
|
92
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.3.0...0.4.0)
|
93
|
+
|
94
|
+
**Closed issues:**
|
95
|
+
|
96
|
+
- insert\_at creates gaps [\#108](https://github.com/swanandp/acts_as_list/issues/108)
|
97
|
+
- move\_lower and move\_higher not working returning nil [\#57](https://github.com/swanandp/acts_as_list/issues/57)
|
98
|
+
- Mass-assignment issue with 0.1.8 [\#50](https://github.com/swanandp/acts_as_list/issues/50)
|
99
|
+
- validates error [\#49](https://github.com/swanandp/acts_as_list/issues/49)
|
100
|
+
- Ability to move multiple at once [\#40](https://github.com/swanandp/acts_as_list/issues/40)
|
101
|
+
- Duplicates created when using accepts\_nested\_attributes\_for [\#29](https://github.com/swanandp/acts_as_list/issues/29)
|
102
|
+
|
103
|
+
**Merged pull requests:**
|
104
|
+
|
105
|
+
- Update README [\#107](https://github.com/swanandp/acts_as_list/pull/107) ([Senjai](https://github.com/Senjai))
|
106
|
+
- Add license info: license file and gemspec [\#105](https://github.com/swanandp/acts_as_list/pull/105) ([chulkilee](https://github.com/chulkilee))
|
107
|
+
- Fix top position when position is lower than top position [\#104](https://github.com/swanandp/acts_as_list/pull/104) ([csaura](https://github.com/csaura))
|
108
|
+
- Get specs running under Rails 4.1.0.beta1 [\#101](https://github.com/swanandp/acts_as_list/pull/101) ([petergoldstein](https://github.com/petergoldstein))
|
109
|
+
- Add support for JRuby and Rubinius specs [\#100](https://github.com/swanandp/acts_as_list/pull/100) ([petergoldstein](https://github.com/petergoldstein))
|
110
|
+
- Use the correct syntax for conditions in Rails 4 on the readme. [\#94](https://github.com/swanandp/acts_as_list/pull/94) ([gotjosh](https://github.com/gotjosh))
|
111
|
+
- Adds `required\_ruby\_version` to gemspec [\#90](https://github.com/swanandp/acts_as_list/pull/90) ([tvdeyen](https://github.com/tvdeyen))
|
112
|
+
|
113
|
+
## [0.3.0](https://github.com/swanandp/acts_as_list/tree/0.3.0) (2013-08-02)
|
114
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.2.0...0.3.0)
|
115
|
+
|
116
|
+
**Closed issues:**
|
117
|
+
|
118
|
+
- act\_as\_list didn't install with bundle install [\#83](https://github.com/swanandp/acts_as_list/issues/83)
|
119
|
+
- Cannot update to version 0.1.7 [\#48](https://github.com/swanandp/acts_as_list/issues/48)
|
120
|
+
- when position is null all new items get inserted in position 1 [\#41](https://github.com/swanandp/acts_as_list/issues/41)
|
121
|
+
|
122
|
+
**Merged pull requests:**
|
123
|
+
|
124
|
+
- Test against activerecord v3 and v4 [\#82](https://github.com/swanandp/acts_as_list/pull/82) ([sanemat](https://github.com/sanemat))
|
125
|
+
- Fix check\_scope to work on lists with array scopes [\#81](https://github.com/swanandp/acts_as_list/pull/81) ([conzett](https://github.com/conzett))
|
126
|
+
- Rails4 compatibility [\#80](https://github.com/swanandp/acts_as_list/pull/80) ([philippfranke](https://github.com/philippfranke))
|
127
|
+
- Add tests for moving within scope and add method: move\_within\_scope [\#79](https://github.com/swanandp/acts_as_list/pull/79) ([philippfranke](https://github.com/philippfranke))
|
128
|
+
- Option to not automatically add items to the list [\#72](https://github.com/swanandp/acts_as_list/pull/72) ([forrest](https://github.com/forrest))
|
129
|
+
|
130
|
+
## [0.2.0](https://github.com/swanandp/acts_as_list/tree/0.2.0) (2013-02-28)
|
131
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.1.9...0.2.0)
|
132
|
+
|
133
|
+
**Merged pull requests:**
|
134
|
+
|
135
|
+
- Fix update\_all deprecation warnings in Rails 4.0.0.beta1 [\#73](https://github.com/swanandp/acts_as_list/pull/73) ([soffes](https://github.com/soffes))
|
136
|
+
- Add quotes to Id in SQL requests [\#69](https://github.com/swanandp/acts_as_list/pull/69) ([noefroidevaux](https://github.com/noefroidevaux))
|
137
|
+
- Update position when scope changes [\#67](https://github.com/swanandp/acts_as_list/pull/67) ([philippfranke](https://github.com/philippfranke))
|
138
|
+
- add and categorize public instance methods in readme; add misc notes to ... [\#66](https://github.com/swanandp/acts_as_list/pull/66) ([barelyknown](https://github.com/barelyknown))
|
139
|
+
- Updates \#bottom\_item .find syntax to \>= Rails 3 compatible syntax. [\#65](https://github.com/swanandp/acts_as_list/pull/65) ([tvdeyen](https://github.com/tvdeyen))
|
140
|
+
- add GitHub Flavored Markdown to README [\#63](https://github.com/swanandp/acts_as_list/pull/63) ([phlipper](https://github.com/phlipper))
|
141
|
+
|
142
|
+
## [0.1.9](https://github.com/swanandp/acts_as_list/tree/0.1.9) (2012-12-04)
|
143
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.1.8...0.1.9)
|
144
|
+
|
145
|
+
**Closed issues:**
|
146
|
+
|
147
|
+
- Mysql2 error [\#54](https://github.com/swanandp/acts_as_list/issues/54)
|
148
|
+
- Use alternative column name? [\#53](https://github.com/swanandp/acts_as_list/issues/53)
|
149
|
+
|
150
|
+
**Merged pull requests:**
|
151
|
+
|
152
|
+
- attr-accessible can be damaging, is not always necessary. [\#60](https://github.com/swanandp/acts_as_list/pull/60) ([graemeworthy](https://github.com/graemeworthy))
|
153
|
+
- More reliable lower/higher item detection [\#59](https://github.com/swanandp/acts_as_list/pull/59) ([miks](https://github.com/miks))
|
154
|
+
- Instructions for using an array with scope [\#58](https://github.com/swanandp/acts_as_list/pull/58) ([zukowski](https://github.com/zukowski))
|
155
|
+
- Attr accessible patch, should solve \#50 [\#51](https://github.com/swanandp/acts_as_list/pull/51) ([fabn](https://github.com/fabn))
|
156
|
+
- support accepts\_nested\_attributes\_for multi-destroy [\#46](https://github.com/swanandp/acts_as_list/pull/46) ([saberma](https://github.com/saberma))
|
157
|
+
|
158
|
+
## [0.1.8](https://github.com/swanandp/acts_as_list/tree/0.1.8) (2012-08-09)
|
159
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.1.7...0.1.8)
|
160
|
+
|
161
|
+
## [0.1.7](https://github.com/swanandp/acts_as_list/tree/0.1.7) (2012-08-09)
|
162
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.1.6...0.1.7)
|
163
|
+
|
164
|
+
**Closed issues:**
|
165
|
+
|
166
|
+
- Remove use of update\_attribute [\#44](https://github.com/swanandp/acts_as_list/issues/44)
|
167
|
+
- Order is reversed when adding multiple rows at once [\#34](https://github.com/swanandp/acts_as_list/issues/34)
|
168
|
+
|
169
|
+
**Merged pull requests:**
|
170
|
+
|
171
|
+
- Fixed issue with update\_positions that wasn't taking 'scope\_condition' into account [\#47](https://github.com/swanandp/acts_as_list/pull/47) ([bastien](https://github.com/bastien))
|
172
|
+
- Replaced usage of update\_attribute with update\_attribute! [\#45](https://github.com/swanandp/acts_as_list/pull/45) ([kevmoo](https://github.com/kevmoo))
|
173
|
+
- use self.class.primary\_key instead of id in shuffle\_positions\_on\_intermediate\_items [\#42](https://github.com/swanandp/acts_as_list/pull/42) ([servercrunch](https://github.com/servercrunch))
|
174
|
+
- initialize gem [\#39](https://github.com/swanandp/acts_as_list/pull/39) ([megatux](https://github.com/megatux))
|
175
|
+
- Added ability to set item positions directly \(e.g. In a form\) [\#38](https://github.com/swanandp/acts_as_list/pull/38) ([dubroe](https://github.com/dubroe))
|
176
|
+
- Prevent SQL error when position\_column is not unique [\#37](https://github.com/swanandp/acts_as_list/pull/37) ([hinrik](https://github.com/hinrik))
|
177
|
+
- Add installation instructions to README.md [\#35](https://github.com/swanandp/acts_as_list/pull/35) ([mark-rushakoff](https://github.com/mark-rushakoff))
|
178
|
+
|
179
|
+
## [0.1.6](https://github.com/swanandp/acts_as_list/tree/0.1.6) (2012-04-19)
|
180
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.1.5...0.1.6)
|
181
|
+
|
182
|
+
**Closed issues:**
|
183
|
+
|
184
|
+
- eval mistakenly resolved the module path [\#32](https://github.com/swanandp/acts_as_list/issues/32)
|
185
|
+
- Duplicated positions when creating parent and children from scratch in 0.1.5 [\#31](https://github.com/swanandp/acts_as_list/issues/31)
|
186
|
+
- add info about v0.1.5 require Rails 3 [\#28](https://github.com/swanandp/acts_as_list/issues/28)
|
187
|
+
- position not updated with move\_higher or move\_lover [\#23](https://github.com/swanandp/acts_as_list/issues/23)
|
188
|
+
|
189
|
+
**Merged pull requests:**
|
190
|
+
|
191
|
+
- update ActiveRecord class eval to support ActiveSupport on\_load [\#33](https://github.com/swanandp/acts_as_list/pull/33) ([mergulhao](https://github.com/mergulhao))
|
192
|
+
- Add :add\_new\_at option [\#30](https://github.com/swanandp/acts_as_list/pull/30) ([mjbellantoni](https://github.com/mjbellantoni))
|
193
|
+
|
194
|
+
## [0.1.5](https://github.com/swanandp/acts_as_list/tree/0.1.5) (2012-02-24)
|
195
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.1.4...0.1.5)
|
196
|
+
|
197
|
+
**Closed issues:**
|
198
|
+
|
199
|
+
- increment\_positions\_on\_lower\_items called twice on insert\_at with new item [\#21](https://github.com/swanandp/acts_as_list/issues/21)
|
200
|
+
- Change bundler dependency from ~\>1.0.0 to ~\>1.0 [\#20](https://github.com/swanandp/acts_as_list/issues/20)
|
201
|
+
- decrement\_positions\_on\_lower\_items method [\#17](https://github.com/swanandp/acts_as_list/issues/17)
|
202
|
+
- New gem release [\#16](https://github.com/swanandp/acts_as_list/issues/16)
|
203
|
+
- acts\_as\_list :scope =\> "doesnt\_seem\_to\_work" [\#12](https://github.com/swanandp/acts_as_list/issues/12)
|
204
|
+
- don't work perfectly with default\_scope [\#11](https://github.com/swanandp/acts_as_list/issues/11)
|
205
|
+
- MySQL: Position column MUST NOT have default [\#10](https://github.com/swanandp/acts_as_list/issues/10)
|
206
|
+
- insert\_at fails on postgresql w/ non-null constraint on postion\_column [\#8](https://github.com/swanandp/acts_as_list/issues/8)
|
207
|
+
|
208
|
+
**Merged pull requests:**
|
209
|
+
|
210
|
+
- Efficiency improvement for insert\_at when repositioning an existing item [\#27](https://github.com/swanandp/acts_as_list/pull/27) ([bradediger](https://github.com/bradediger))
|
211
|
+
- Use before validate instead of before create [\#25](https://github.com/swanandp/acts_as_list/pull/25) ([webervin](https://github.com/webervin))
|
212
|
+
- Massive test refactorings. [\#24](https://github.com/swanandp/acts_as_list/pull/24) ([splattael](https://github.com/splattael))
|
213
|
+
- Silent migrations to reduce test noise. [\#22](https://github.com/swanandp/acts_as_list/pull/22) ([splattael](https://github.com/splattael))
|
214
|
+
- Should decrement lower items after the item has been destroyed to avoid unique key conflicts. [\#18](https://github.com/swanandp/acts_as_list/pull/18) ([aepstein](https://github.com/aepstein))
|
215
|
+
- Fix spelling and grammer [\#15](https://github.com/swanandp/acts_as_list/pull/15) ([tmiller](https://github.com/tmiller))
|
216
|
+
- store\_at\_0 should yank item from the list then decrement items to avoid r [\#14](https://github.com/swanandp/acts_as_list/pull/14) ([aepstein](https://github.com/aepstein))
|
217
|
+
- Support default\_scope ordering by calling .unscoped [\#13](https://github.com/swanandp/acts_as_list/pull/13) ([tanordheim](https://github.com/tanordheim))
|
218
|
+
|
219
|
+
## [0.1.4](https://github.com/swanandp/acts_as_list/tree/0.1.4) (2011-07-27)
|
220
|
+
[Full Changelog](https://github.com/swanandp/acts_as_list/compare/0.1.3...0.1.4)
|
221
|
+
|
222
|
+
**Merged pull requests:**
|
223
|
+
|
224
|
+
- Fix sqlite3 dependency [\#7](https://github.com/swanandp/acts_as_list/pull/7) ([joneslee85](https://github.com/joneslee85))
|
225
|
+
|
226
|
+
## [0.1.3](https://github.com/swanandp/acts_as_list/tree/0.1.3) (2011-06-10)
|
227
|
+
**Closed issues:**
|
228
|
+
|
229
|
+
- Graph like behaviour [\#5](https://github.com/swanandp/acts_as_list/issues/5)
|
230
|
+
- Updated Gem? [\#4](https://github.com/swanandp/acts_as_list/issues/4)
|
231
|
+
|
232
|
+
**Merged pull requests:**
|
233
|
+
|
234
|
+
- Converted into a gem... plus some slight refactors [\#6](https://github.com/swanandp/acts_as_list/pull/6) ([chaffeqa](https://github.com/chaffeqa))
|
235
|
+
- Fixed test issue for test\_injection: expected SQL was reversed. [\#3](https://github.com/swanandp/acts_as_list/pull/3) ([afriqs](https://github.com/afriqs))
|
236
|
+
- Added an option to set the top of the position [\#2](https://github.com/swanandp/acts_as_list/pull/2) ([danielcooper](https://github.com/danielcooper))
|
237
|
+
- minor change to acts\_as\_list's callbacks [\#1](https://github.com/swanandp/acts_as_list/pull/1) ([tiegz](https://github.com/tiegz))
|
238
|
+
|
239
|
+
|
240
|
+
|
241
|
+
\* *This Change Log was automatically generated by [github_changelog_generator](https://github.com/skywinder/Github-Changelog-Generator)*
|
data/Gemfile
CHANGED
data/README.md
CHANGED
@@ -32,9 +32,10 @@ class TodoItem < ActiveRecord::Base
|
|
32
32
|
belongs_to :todo_list
|
33
33
|
acts_as_list scope: :todo_list
|
34
34
|
end
|
35
|
-
|
36
|
-
todo_list.
|
37
|
-
todo_list.
|
35
|
+
|
36
|
+
todo_list = TodoList.find(...)
|
37
|
+
todo_list.todo_items.first.move_to_bottom
|
38
|
+
todo_list.todo_items.last.move_higher
|
38
39
|
```
|
39
40
|
|
40
41
|
## Instance Methods Added To ActiveRecord Models
|
@@ -85,6 +86,14 @@ class TodoItem < ActiveRecord::Base
|
|
85
86
|
end
|
86
87
|
```
|
87
88
|
|
89
|
+
## More Options
|
90
|
+
- `column`
|
91
|
+
default: 'position'. Use this option if the column name in your database is different from position.
|
92
|
+
- `top_of_list`
|
93
|
+
default: '1'. Use this option to define the top of the list. Use 0 to make the collection act more like an array in its indexing.
|
94
|
+
- `add_new_at`
|
95
|
+
default: ':bottom'. Use this option to specify whether objects get added to the :top or :bottom of the list. `nil` will result in new items not being added to the list on create, i.e, position will be kept nil after create.
|
96
|
+
|
88
97
|
## Versions
|
89
98
|
All versions `0.1.5` onwards require Rails 3.0.x and higher.
|
90
99
|
|
data/Rakefile
CHANGED
@@ -32,3 +32,11 @@ rescue LoadError
|
|
32
32
|
rescue StandardError
|
33
33
|
puts "RDocTask is not supported on this platform."
|
34
34
|
end
|
35
|
+
|
36
|
+
# See https://github.com/skywinder/github-changelog-generator#rake-task for details
|
37
|
+
# and github_changelog_generator --help for available options
|
38
|
+
require 'github_changelog_generator/task'
|
39
|
+
GitHubChangelogGenerator::RakeTask.new :changelog do |config|
|
40
|
+
config.project = 'acts_as_list'
|
41
|
+
config.user = 'swanandp'
|
42
|
+
end
|
data/gemfiles/rails_3_2.gemfile
CHANGED
@@ -6,10 +6,13 @@ gem "sqlite3", :platforms => [:ruby]
|
|
6
6
|
gem "activerecord-jdbcsqlite3-adapter", :platforms => [:jruby]
|
7
7
|
gem "rake"
|
8
8
|
gem "appraisal"
|
9
|
-
gem "
|
9
|
+
gem "github_changelog_generator", "1.9.0"
|
10
|
+
gem "activerecord", "~> 3.2.21"
|
10
11
|
|
11
12
|
group :test do
|
12
|
-
gem "minitest"
|
13
|
+
gem "minitest", "~> 5.0"
|
14
|
+
gem "test_after_commit", "~> 0.4.2"
|
15
|
+
gem "after_commit_exception_notification"
|
13
16
|
end
|
14
17
|
|
15
18
|
platforms :rbx do
|
data/gemfiles/rails_4_1.gemfile
CHANGED
@@ -6,10 +6,13 @@ gem "sqlite3", :platforms => [:ruby]
|
|
6
6
|
gem "activerecord-jdbcsqlite3-adapter", :platforms => [:jruby]
|
7
7
|
gem "rake"
|
8
8
|
gem "appraisal"
|
9
|
-
gem "
|
9
|
+
gem "github_changelog_generator", "1.9.0"
|
10
|
+
gem "activerecord", "~> 4.1.10"
|
10
11
|
|
11
12
|
group :test do
|
12
|
-
gem "minitest"
|
13
|
+
gem "minitest", "~> 5.0"
|
14
|
+
gem "test_after_commit", "~> 0.4.2"
|
15
|
+
gem "after_commit_exception_notification"
|
13
16
|
end
|
14
17
|
|
15
18
|
platforms :rbx do
|
data/gemfiles/rails_4_2.gemfile
CHANGED
@@ -6,10 +6,12 @@ gem "sqlite3", :platforms => [:ruby]
|
|
6
6
|
gem "activerecord-jdbcsqlite3-adapter", :platforms => [:jruby]
|
7
7
|
gem "rake"
|
8
8
|
gem "appraisal"
|
9
|
-
gem "
|
9
|
+
gem "github_changelog_generator", "1.9.0"
|
10
|
+
gem "activerecord", "~> 4.2.1"
|
10
11
|
|
11
12
|
group :test do
|
12
|
-
gem "minitest"
|
13
|
+
gem "minitest", "~> 5.0"
|
14
|
+
gem "test_after_commit", "~> 0.4.2"
|
13
15
|
end
|
14
16
|
|
15
17
|
platforms :rbx do
|
@@ -38,32 +38,30 @@ module ActiveRecord
|
|
38
38
|
configuration = { column: "position", scope: "1 = 1", top_of_list: 1, add_new_at: :bottom}
|
39
39
|
configuration.update(options) if options.is_a?(Hash)
|
40
40
|
|
41
|
-
|
41
|
+
if configuration[:scope].is_a?(Symbol) && configuration[:scope].to_s !~ /_id$/
|
42
|
+
configuration[:scope] = :"#{configuration[:scope]}_id"
|
43
|
+
end
|
42
44
|
|
43
45
|
if configuration[:scope].is_a?(Symbol)
|
44
46
|
scope_methods = %(
|
45
47
|
def scope_condition
|
46
|
-
{
|
48
|
+
{ #{configuration[:scope]}: send(:#{configuration[:scope]}) }
|
47
49
|
end
|
48
50
|
|
49
51
|
def scope_changed?
|
50
|
-
|
52
|
+
changed.include?(scope_name.to_s)
|
51
53
|
end
|
52
54
|
)
|
53
55
|
elsif configuration[:scope].is_a?(Array)
|
54
56
|
scope_methods = %(
|
55
|
-
def
|
56
|
-
|
57
|
-
|
57
|
+
def scope_condition
|
58
|
+
#{configuration[:scope]}.inject({}) do |hash, column|
|
59
|
+
hash.merge!({ column.to_sym => read_attribute(column.to_sym) })
|
58
60
|
end
|
59
61
|
end
|
60
62
|
|
61
63
|
def scope_changed?
|
62
|
-
(
|
63
|
-
end
|
64
|
-
|
65
|
-
def scope_condition
|
66
|
-
attrs
|
64
|
+
(scope_condition.keys & changed.map(&:to_sym)).any?
|
67
65
|
end
|
68
66
|
)
|
69
67
|
else
|
@@ -76,7 +74,7 @@ module ActiveRecord
|
|
76
74
|
)
|
77
75
|
end
|
78
76
|
|
79
|
-
class_eval <<-EOV
|
77
|
+
class_eval <<-EOV, __FILE__, __LINE__ + 1
|
80
78
|
include ::ActiveRecord::Acts::List::InstanceMethods
|
81
79
|
|
82
80
|
def acts_as_list_top
|
@@ -113,17 +111,21 @@ module ActiveRecord
|
|
113
111
|
attr_accessible :#{configuration[:column]}
|
114
112
|
end
|
115
113
|
|
114
|
+
before_validation :check_top_position
|
115
|
+
|
116
116
|
before_destroy :reload_position
|
117
117
|
after_destroy :decrement_positions_on_lower_items
|
118
|
+
|
118
119
|
before_update :check_scope
|
119
120
|
after_update :update_positions
|
120
|
-
|
121
|
+
|
122
|
+
after_commit 'remove_instance_variable(:@scope_changed) if defined?(@scope_changed)'
|
121
123
|
|
122
124
|
scope :in_list, lambda { where("#{table_name}.#{configuration[:column]} IS NOT NULL") }
|
123
125
|
EOV
|
124
126
|
|
125
127
|
if configuration[:add_new_at].present?
|
126
|
-
self.send
|
128
|
+
self.send :before_create, :"add_to_list_#{configuration[:add_new_at]}"
|
127
129
|
end
|
128
130
|
|
129
131
|
end
|
@@ -221,10 +223,7 @@ module ActiveRecord
|
|
221
223
|
# Return the next higher item in the list.
|
222
224
|
def higher_item
|
223
225
|
return nil unless in_list?
|
224
|
-
|
225
|
-
acts_as_list_class.where(scope_condition).where("#{position_column} < #{(send(position_column).to_i).to_s}").
|
226
|
-
order("#{acts_as_list_class.table_name}.#{position_column} DESC").first
|
227
|
-
end
|
226
|
+
higher_items(1).first
|
228
227
|
end
|
229
228
|
|
230
229
|
# Return the next n higher items in the list
|
@@ -242,10 +241,7 @@ module ActiveRecord
|
|
242
241
|
# Return the next lower item in the list.
|
243
242
|
def lower_item
|
244
243
|
return nil unless in_list?
|
245
|
-
|
246
|
-
acts_as_list_class.where(scope_condition).where("#{position_column} > #{(send(position_column).to_i).to_s}").
|
247
|
-
order("#{acts_as_list_class.table_name}.#{position_column} ASC").first
|
248
|
-
end
|
244
|
+
lower_items(1).first
|
249
245
|
end
|
250
246
|
|
251
247
|
# Return the next n lower items in the list
|
@@ -293,14 +289,26 @@ module ActiveRecord
|
|
293
289
|
def add_to_list_top
|
294
290
|
increment_positions_on_all_items
|
295
291
|
self[position_column] = acts_as_list_top
|
292
|
+
# Make sure we know that we've processed this scope change already
|
293
|
+
@scope_changed = false
|
294
|
+
#dont halt the callback chain
|
295
|
+
true
|
296
296
|
end
|
297
297
|
|
298
|
+
# A poorly named method. It will insert the item at the desired position if the position
|
299
|
+
# has been set manually using position=, not necessarily the bottom of the list
|
298
300
|
def add_to_list_bottom
|
299
|
-
if not_in_list? ||
|
301
|
+
if not_in_list? || internal_scope_changed? && !@position_changed || default_position?
|
300
302
|
self[position_column] = bottom_position_in_list.to_i + 1
|
301
303
|
else
|
302
304
|
increment_positions_on_lower_items(self[position_column], id)
|
303
305
|
end
|
306
|
+
|
307
|
+
# Make sure we know that we've processed this scope change already
|
308
|
+
@scope_changed = false
|
309
|
+
|
310
|
+
#dont halt the callback chain
|
311
|
+
true
|
304
312
|
end
|
305
313
|
|
306
314
|
# Overwrite this method to define the scope of the list changes
|
@@ -317,9 +325,11 @@ module ActiveRecord
|
|
317
325
|
def bottom_item(except = nil)
|
318
326
|
conditions = scope_condition
|
319
327
|
conditions = except ? "#{self.class.primary_key} != #{self.class.connection.quote(except.id)}" : {}
|
320
|
-
|
321
|
-
|
322
|
-
|
328
|
+
acts_as_list_list.in_list.where(
|
329
|
+
conditions
|
330
|
+
).order(
|
331
|
+
"#{acts_as_list_class.table_name}.#{position_column} DESC"
|
332
|
+
).first
|
323
333
|
end
|
324
334
|
|
325
335
|
# Forces item to assume the bottom position in the list.
|
@@ -334,62 +344,50 @@ module ActiveRecord
|
|
334
344
|
|
335
345
|
# This has the effect of moving all the higher items up one.
|
336
346
|
def decrement_positions_on_higher_items(position)
|
337
|
-
|
338
|
-
|
339
|
-
|
340
|
-
)
|
341
|
-
|
342
|
-
)
|
343
|
-
end
|
347
|
+
acts_as_list_list.where(
|
348
|
+
"#{position_column} <= #{position}"
|
349
|
+
).update_all(
|
350
|
+
"#{position_column} = (#{position_column} - 1)"
|
351
|
+
)
|
344
352
|
end
|
345
353
|
|
346
354
|
# This has the effect of moving all the lower items up one.
|
347
355
|
def decrement_positions_on_lower_items(position=nil)
|
348
356
|
return unless in_list?
|
349
357
|
position ||= send(position_column).to_i
|
350
|
-
|
351
|
-
|
352
|
-
|
353
|
-
)
|
354
|
-
|
355
|
-
)
|
356
|
-
end
|
358
|
+
acts_as_list_list.where(
|
359
|
+
"#{position_column} > #{position}"
|
360
|
+
).update_all(
|
361
|
+
"#{position_column} = (#{position_column} - 1)"
|
362
|
+
)
|
357
363
|
end
|
358
364
|
|
359
365
|
# This has the effect of moving all the higher items down one.
|
360
366
|
def increment_positions_on_higher_items
|
361
367
|
return unless in_list?
|
362
|
-
|
363
|
-
|
364
|
-
|
365
|
-
)
|
366
|
-
|
367
|
-
)
|
368
|
-
end
|
368
|
+
acts_as_list_list.where(
|
369
|
+
"#{position_column} < #{send(position_column).to_i}"
|
370
|
+
).update_all(
|
371
|
+
"#{position_column} = (#{position_column} + 1)"
|
372
|
+
)
|
369
373
|
end
|
370
374
|
|
371
375
|
# This has the effect of moving all the lower items down one.
|
372
376
|
def increment_positions_on_lower_items(position, avoid_id = nil)
|
373
377
|
avoid_id_condition = avoid_id ? " AND #{self.class.primary_key} != #{self.class.connection.quote(avoid_id)}" : ''
|
374
378
|
|
375
|
-
|
376
|
-
|
377
|
-
|
378
|
-
)
|
379
|
-
|
380
|
-
)
|
381
|
-
end
|
379
|
+
acts_as_list_list.where(
|
380
|
+
"#{position_column} >= #{position}#{avoid_id_condition}"
|
381
|
+
).update_all(
|
382
|
+
"#{position_column} = (#{position_column} + 1)"
|
383
|
+
)
|
382
384
|
end
|
383
385
|
|
384
386
|
# Increments position (<tt>position_column</tt>) of all items in the list.
|
385
387
|
def increment_positions_on_all_items
|
386
|
-
|
387
|
-
|
388
|
-
|
389
|
-
).update_all(
|
390
|
-
"#{position_column} = (#{position_column} + 1)"
|
391
|
-
)
|
392
|
-
end
|
388
|
+
acts_as_list_list.update_all(
|
389
|
+
"#{position_column} = (#{position_column} + 1)"
|
390
|
+
)
|
393
391
|
end
|
394
392
|
|
395
393
|
# Reorders intermediate items to support moving an item from old_position to new_position.
|
@@ -402,29 +400,25 @@ module ActiveRecord
|
|
402
400
|
#
|
403
401
|
# e.g., if moving an item from 2 to 5,
|
404
402
|
# move [3, 4, 5] to [2, 3, 4]
|
405
|
-
|
406
|
-
|
407
|
-
|
408
|
-
|
409
|
-
|
410
|
-
)
|
411
|
-
|
412
|
-
)
|
413
|
-
end
|
403
|
+
acts_as_list_list.where(
|
404
|
+
"#{position_column} > #{old_position}"
|
405
|
+
).where(
|
406
|
+
"#{position_column} <= #{new_position}#{avoid_id_condition}"
|
407
|
+
).update_all(
|
408
|
+
"#{position_column} = (#{position_column} - 1)"
|
409
|
+
)
|
414
410
|
else
|
415
411
|
# Increment position of intermediate items
|
416
412
|
#
|
417
413
|
# e.g., if moving an item from 5 to 2,
|
418
414
|
# move [2, 3, 4] to [3, 4, 5]
|
419
|
-
|
420
|
-
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
)
|
425
|
-
|
426
|
-
)
|
427
|
-
end
|
415
|
+
acts_as_list_list.where(
|
416
|
+
"#{position_column} >= #{new_position}"
|
417
|
+
).where(
|
418
|
+
"#{position_column} < #{old_position}#{avoid_id_condition}"
|
419
|
+
).update_all(
|
420
|
+
"#{position_column} = (#{position_column} + 1)"
|
421
|
+
)
|
428
422
|
end
|
429
423
|
end
|
430
424
|
|
@@ -453,20 +447,29 @@ module ActiveRecord
|
|
453
447
|
old_position = send("#{position_column}_was").to_i
|
454
448
|
new_position = send(position_column).to_i
|
455
449
|
|
456
|
-
return unless
|
457
|
-
|
458
|
-
|
450
|
+
return unless acts_as_list_list.where(
|
451
|
+
"#{position_column} = #{new_position}"
|
452
|
+
).count > 1
|
459
453
|
shuffle_positions_on_intermediate_items old_position, new_position, id
|
460
454
|
end
|
461
455
|
|
456
|
+
def internal_scope_changed?
|
457
|
+
return @scope_changed if defined?(@scope_changed)
|
458
|
+
|
459
|
+
@scope_changed = scope_changed?
|
460
|
+
end
|
461
|
+
|
462
462
|
# Temporarily swap changes attributes with current attributes
|
463
463
|
def swap_changed_attributes
|
464
|
-
@changed_attributes.each
|
465
|
-
self
|
464
|
+
@changed_attributes.each do |k, _|
|
465
|
+
if self.class.column_names.include? k
|
466
|
+
@changed_attributes[k], self[k] = self[k], @changed_attributes[k]
|
467
|
+
end
|
468
|
+
end
|
466
469
|
end
|
467
470
|
|
468
471
|
def check_scope
|
469
|
-
if
|
472
|
+
if internal_scope_changed?
|
470
473
|
swap_changed_attributes
|
471
474
|
send('decrement_positions_on_lower_items') if lower_item
|
472
475
|
swap_changed_attributes
|