acts_as_restful_list 0.2.1 → 0.3.0
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.
- data/VERSION +1 -1
- data/acts_as_restful_list.gemspec +4 -4
- data/lib/acts_as_restful_list.rb +2 -2
- data/spec/acts_as_restful_list_spec.rb +34 -0
- metadata +12 -5
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.
|
1
|
+
0.3.0
|
@@ -5,11 +5,11 @@
|
|
5
5
|
|
6
6
|
Gem::Specification.new do |s|
|
7
7
|
s.name = %q{acts_as_restful_list}
|
8
|
-
s.version = "0.
|
8
|
+
s.version = "0.3.0"
|
9
9
|
|
10
10
|
s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
|
11
11
|
s.authors = ["'Trey Bean'"]
|
12
|
-
s.date = %q{2010-
|
12
|
+
s.date = %q{2010-11-11}
|
13
13
|
s.description = %q{Just like acts_as_list, but allows updating through standard restful methods.}
|
14
14
|
s.email = %q{trey@12spokes.com}
|
15
15
|
s.extra_rdoc_files = [
|
@@ -34,7 +34,7 @@ Gem::Specification.new do |s|
|
|
34
34
|
s.homepage = %q{http://github.com/12spokes/acts_as_restful_list}
|
35
35
|
s.rdoc_options = ["--charset=UTF-8"]
|
36
36
|
s.require_paths = ["lib"]
|
37
|
-
s.rubygems_version = %q{1.3.
|
37
|
+
s.rubygems_version = %q{1.3.7}
|
38
38
|
s.summary = %q{Restful acts_as_list}
|
39
39
|
s.test_files = [
|
40
40
|
"spec/acts_as_restful_list_spec.rb",
|
@@ -45,7 +45,7 @@ Gem::Specification.new do |s|
|
|
45
45
|
current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
|
46
46
|
s.specification_version = 3
|
47
47
|
|
48
|
-
if Gem::Version.new(Gem::
|
48
|
+
if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
|
49
49
|
s.add_development_dependency(%q<rspec>, [">= 1.2.9"])
|
50
50
|
else
|
51
51
|
s.add_dependency(%q<rspec>, [">= 1.2.9"])
|
data/lib/acts_as_restful_list.rb
CHANGED
@@ -28,9 +28,9 @@ module ActsAsRestfulList
|
|
28
28
|
nil
|
29
29
|
else
|
30
30
|
scopes = Array(configuration[:scope]).collect do |scope|
|
31
|
-
column = scope.to_s
|
31
|
+
column = self.class.column_names.include?(scope.to_s) ? scope.to_s : "#{scope}_id"
|
32
32
|
value = self.send(column)
|
33
|
-
value.nil? ? "#{column} IS NULL" : "#{column} = #{value}"
|
33
|
+
value.nil? ? "#{column} IS NULL" : "#{column} = #{value.is_a?(String) ? "'#{value}'" : value}"
|
34
34
|
end
|
35
35
|
scopes.join(' AND ')
|
36
36
|
end
|
@@ -307,6 +307,40 @@ describe "ActsAsRestfulList" do
|
|
307
307
|
end
|
308
308
|
|
309
309
|
|
310
|
+
describe 'declaring acts_as_restful_list and setting the scope on a column that is not an _id column' do
|
311
|
+
before(:all) do
|
312
|
+
ActiveRecord::Schema.define(:version => 1) do
|
313
|
+
create_table :mixins do |t|
|
314
|
+
t.column :position, :integer
|
315
|
+
t.column :parent_name, :string
|
316
|
+
t.column :created_at, :datetime
|
317
|
+
t.column :updated_at, :datetime
|
318
|
+
end
|
319
|
+
end
|
320
|
+
|
321
|
+
class Mixin < ActiveRecord::Base
|
322
|
+
acts_as_restful_list :scope => :parent_name
|
323
|
+
end
|
324
|
+
end
|
325
|
+
|
326
|
+
after(:all) do
|
327
|
+
Object.send(:remove_const, :Mixin)
|
328
|
+
|
329
|
+
ActiveRecord::Base.connection.tables.each do |table|
|
330
|
+
ActiveRecord::Base.connection.drop_table(table)
|
331
|
+
end
|
332
|
+
end
|
333
|
+
|
334
|
+
it 'should define scope_condition as an instance method' do
|
335
|
+
Mixin.new.should respond_to(:scope_condition)
|
336
|
+
end
|
337
|
+
|
338
|
+
it 'should return a scope condition that limits based on the parent_id' do
|
339
|
+
Mixin.new(:parent_name => 'Brandy').scope_condition.should == "parent_name = 'Brandy'"
|
340
|
+
end
|
341
|
+
end
|
342
|
+
|
343
|
+
|
310
344
|
describe 'declaring acts_as_restful_list and setting the scope to multiple columns' do
|
311
345
|
before(:all) do
|
312
346
|
ActiveRecord::Schema.define(:version => 1) do
|
metadata
CHANGED
@@ -1,12 +1,13 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: acts_as_restful_list
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
+
hash: 19
|
4
5
|
prerelease: false
|
5
6
|
segments:
|
6
7
|
- 0
|
7
|
-
-
|
8
|
-
-
|
9
|
-
version: 0.
|
8
|
+
- 3
|
9
|
+
- 0
|
10
|
+
version: 0.3.0
|
10
11
|
platform: ruby
|
11
12
|
authors:
|
12
13
|
- "'Trey Bean'"
|
@@ -14,16 +15,18 @@ autorequire:
|
|
14
15
|
bindir: bin
|
15
16
|
cert_chain: []
|
16
17
|
|
17
|
-
date: 2010-
|
18
|
+
date: 2010-11-11 00:00:00 -07:00
|
18
19
|
default_executable:
|
19
20
|
dependencies:
|
20
21
|
- !ruby/object:Gem::Dependency
|
21
22
|
name: rspec
|
22
23
|
prerelease: false
|
23
24
|
requirement: &id001 !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
24
26
|
requirements:
|
25
27
|
- - ">="
|
26
28
|
- !ruby/object:Gem::Version
|
29
|
+
hash: 13
|
27
30
|
segments:
|
28
31
|
- 1
|
29
32
|
- 2
|
@@ -64,23 +67,27 @@ rdoc_options:
|
|
64
67
|
require_paths:
|
65
68
|
- lib
|
66
69
|
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
none: false
|
67
71
|
requirements:
|
68
72
|
- - ">="
|
69
73
|
- !ruby/object:Gem::Version
|
74
|
+
hash: 3
|
70
75
|
segments:
|
71
76
|
- 0
|
72
77
|
version: "0"
|
73
78
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
79
|
+
none: false
|
74
80
|
requirements:
|
75
81
|
- - ">="
|
76
82
|
- !ruby/object:Gem::Version
|
83
|
+
hash: 3
|
77
84
|
segments:
|
78
85
|
- 0
|
79
86
|
version: "0"
|
80
87
|
requirements: []
|
81
88
|
|
82
89
|
rubyforge_project:
|
83
|
-
rubygems_version: 1.3.
|
90
|
+
rubygems_version: 1.3.7
|
84
91
|
signing_key:
|
85
92
|
specification_version: 3
|
86
93
|
summary: Restful acts_as_list
|