acts_as_list_ar 0.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,83 @@
1
+ require 'rubygems'
2
+ require 'test/unit'
3
+ require 'active_record'
4
+ $:.unshift "#{File.dirname(__FILE__)}/../lib/"
5
+ require 'acts_as_list_ar'
6
+ ActiveRecord::Base.establish_connection(:adapter => "sqlite3", :database => ":memory:")
7
+
8
+ def setup_db
9
+ ActiveRecord::Schema.define(:version => 1) do
10
+ create_table :mixins do |t|
11
+ t.column :pos, :integer
12
+ t.column :parent_id, :integer
13
+ t.column :created_at, :datetime
14
+ t.column :updated_at, :datetime
15
+ end
16
+
17
+ create_table :sti_mixins do |t|
18
+ t.column :position, :integer
19
+ t.column :type, :string
20
+ end
21
+
22
+ create_table :mixin_with_strings do |t|
23
+ t.column :id, :string
24
+ t.column :pos, :integer
25
+ t.column :parent_id, :string
26
+ t.column :created_at, :datetime
27
+ t.column :updated_at, :datetime
28
+ end
29
+ end
30
+ end
31
+
32
+ def teardown_db
33
+ ActiveRecord::Base.connection.tables.each do |table|
34
+ ActiveRecord::Base.connection.drop_table(table)
35
+ end
36
+ end
37
+
38
+ module DefaultBehavior
39
+ attr_accessor :before_save_triggered
40
+
41
+ def log_before_save
42
+ self.before_save_triggered = true
43
+ end
44
+ end
45
+
46
+ class Mixin < ActiveRecord::Base
47
+ before_save :log_before_save
48
+ before_create :add_to_list_bottom_when_necessary
49
+
50
+ def self.table_name
51
+ "mixins"
52
+ end
53
+
54
+ include DefaultBehavior
55
+ end
56
+
57
+ class MixinWithStrings < ActiveRecord::Base
58
+ acts_as_list :column => "pos", :scope => :parent
59
+ end
60
+
61
+ class ListMixin < Mixin
62
+ acts_as_list :column => "pos", :scope => :parent
63
+ end
64
+
65
+ class ListMixinSub1 < ListMixin
66
+ end
67
+
68
+ class ListMixinSub2 < ListMixin
69
+ end
70
+
71
+ class ListWithStringScopeMixin < Mixin
72
+ acts_as_list :column => "pos", :scope => 'parent_id = #{parent_id}'
73
+ end
74
+
75
+ class StiMixin < Mixin
76
+ acts_as_list
77
+ end
78
+
79
+ class StiMixinSub1 < StiMixin
80
+ end
81
+
82
+ class StiMixinSub2 < StiMixin
83
+ end
metadata ADDED
@@ -0,0 +1,104 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: acts_as_list_ar
3
+ version: !ruby/object:Gem::Version
4
+ prerelease: false
5
+ segments:
6
+ - 0
7
+ - 1
8
+ - 0
9
+ version: 0.1.0
10
+ platform: ruby
11
+ authors:
12
+ - Kristian Mandrup
13
+ - Others
14
+ autorequire:
15
+ bindir: bin
16
+ cert_chain: []
17
+
18
+ date: 2010-06-20 00:00:00 +02:00
19
+ default_executable:
20
+ dependencies:
21
+ - !ruby/object:Gem::Dependency
22
+ name: activerecord
23
+ prerelease: false
24
+ requirement: &id001 !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ">="
28
+ - !ruby/object:Gem::Version
29
+ segments:
30
+ - 1
31
+ - 15
32
+ - 4
33
+ - 7794
34
+ version: 1.15.4.7794
35
+ type: :runtime
36
+ version_requirements: *id001
37
+ description: |-
38
+ Make your model acts as a list. This acts_as extension provides the capabilities for sorting and reordering a number of objects in a list.
39
+ The class that has this specified needs to have a +position+ column defined as an integer on the mapped database table.
40
+ email: kmandrup@gmail.com
41
+ executables: []
42
+
43
+ extensions: []
44
+
45
+ extra_rdoc_files:
46
+ - LICENSE
47
+ - README.rdoc
48
+ files:
49
+ - .document
50
+ - .gitignore
51
+ - LICENSE
52
+ - Notes.txt
53
+ - README.rdoc
54
+ - Rakefile
55
+ - VERSION
56
+ - init.rb
57
+ - lib/acts_as_list_ar.rb
58
+ - lib/acts_as_list_ar/rails2.rb
59
+ - lib/acts_as_list_ar/rails3.rb
60
+ - spec/list_spec.rb
61
+ - spec/spec_helper.rb
62
+ - test/acts_as_list_test.rb
63
+ - test/list_w_string_ids_test.rb
64
+ - test/sub_list_test.rb
65
+ - test/test_helper.rb
66
+ has_rdoc: true
67
+ homepage: http://github.com/rails/acts_as_list
68
+ licenses: []
69
+
70
+ post_install_message:
71
+ rdoc_options:
72
+ - --charset=UTF-8
73
+ require_paths:
74
+ - lib
75
+ required_ruby_version: !ruby/object:Gem::Requirement
76
+ none: false
77
+ requirements:
78
+ - - ">="
79
+ - !ruby/object:Gem::Version
80
+ segments:
81
+ - 0
82
+ version: "0"
83
+ required_rubygems_version: !ruby/object:Gem::Requirement
84
+ none: false
85
+ requirements:
86
+ - - ">="
87
+ - !ruby/object:Gem::Version
88
+ segments:
89
+ - 0
90
+ version: "0"
91
+ requirements: []
92
+
93
+ rubyforge_project:
94
+ rubygems_version: 1.3.7
95
+ signing_key:
96
+ specification_version: 3
97
+ summary: Gem version of acts_as_list for Active Record with Rails 2 and 3 support
98
+ test_files:
99
+ - spec/list_spec.rb
100
+ - spec/spec_helper.rb
101
+ - test/acts_as_list_test.rb
102
+ - test/list_w_string_ids_test.rb
103
+ - test/sub_list_test.rb
104
+ - test/test_helper.rb