active_scaffold_sortable_vho 3.0.1 → 3.1.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -1,7 +1,5 @@
1
- require "active_scaffold_sortable/config/core.rb"
2
- require "active_scaffold_sortable/core.rb"
3
- require "active_scaffold_sortable/view_helpers.rb"
4
-
1
+ require 'active_scaffold_sortable/engine'
2
+ require 'active_scaffold_sortable/version'
5
3
 
6
4
  module ActiveScaffoldSortable
7
5
  def self.root
@@ -21,19 +19,4 @@ module ActiveScaffold
21
19
  module Helpers
22
20
  ActiveScaffold.autoload_subdir('helpers', self, File.dirname(__FILE__))
23
21
  end
24
- end
25
-
26
- ActiveScaffold::Config::Core.send :include, ActiveScaffoldSortable::Core
27
- ActionView::Base.send(:include, ActiveScaffoldSortable::ViewHelpers)
28
-
29
- ##
30
- ## Run the install assets script, too, just to make sure
31
- ## But at least rescue the action in production
32
- ##
33
- Rails::Application.initializer("active_scaffold_sortable.install_assets", :after => "active_scaffold.install_assets") do
34
- begin
35
- ActiveScaffoldAssets.copy_to_public(ActiveScaffoldSortable.root)
36
- rescue
37
- raise $! unless Rails.env == 'production'
38
- end
39
- end if defined?(ACTIVE_SCAFFOLD_SORTABLE_GEM)
22
+ end
@@ -0,0 +1,20 @@
1
+ module ActiveScaffoldSortable
2
+ #do not use module Rails... cause Rails.logger will fail
3
+ # not sure if it is a must though...
4
+ #module Rails
5
+ class Engine < ::Rails::Engine
6
+ initializer("initialize_active_scaffold_sortable", :after => "initialize_active_scaffold") do
7
+ ActiveSupport.on_load(:action_controller) do
8
+ require "active_scaffold_sortable/config/core.rb"
9
+ require "active_scaffold_sortable/core.rb"
10
+ ActiveScaffold::Config::Core.send :include, ActiveScaffoldSortable::Core
11
+ end
12
+
13
+ ActiveSupport.on_load(:action_view) do
14
+ require "active_scaffold_sortable/view_helpers.rb"
15
+ include ActiveScaffoldSortable::ViewHelpers
16
+ end
17
+ end
18
+ end
19
+ #end
20
+ end
@@ -1,8 +1,8 @@
1
1
  module ActiveScaffoldSortable
2
2
  module Version
3
3
  MAJOR = 3
4
- MINOR = 0
5
- PATCH = 1
4
+ MINOR = 1
5
+ PATCH = 0
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,180 +1,102 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_sortable_vho
3
- version: !ruby/object:Gem::Version
4
- hash: 5
5
- prerelease: false
6
- segments:
7
- - 3
8
- - 0
9
- - 1
10
- version: 3.0.1
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.1.0
5
+ prerelease:
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Volker Hochstein
14
9
  autorequire:
15
10
  bindir: bin
16
11
  cert_chain: []
17
-
18
- date: 2011-02-01 00:00:00 +01:00
19
- default_executable:
20
- dependencies:
21
- - !ruby/object:Gem::Dependency
22
- prerelease: false
12
+ date: 2011-02-01 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
23
15
  name: shoulda
24
- version_requirements: &id001 !ruby/object:Gem::Requirement
16
+ requirement: &7064900 !ruby/object:Gem::Requirement
25
17
  none: false
26
- requirements:
27
- - - ">="
28
- - !ruby/object:Gem::Version
29
- hash: 3
30
- segments:
31
- - 0
32
- version: "0"
33
- requirement: *id001
18
+ requirements:
19
+ - - ! '>='
20
+ - !ruby/object:Gem::Version
21
+ version: '0'
34
22
  type: :development
35
- - !ruby/object:Gem::Dependency
36
23
  prerelease: false
24
+ version_requirements: *7064900
25
+ - !ruby/object:Gem::Dependency
37
26
  name: bundler
38
- version_requirements: &id002 !ruby/object:Gem::Requirement
27
+ requirement: &7064420 !ruby/object:Gem::Requirement
39
28
  none: false
40
- requirements:
41
- - - ~>
42
- - !ruby/object:Gem::Version
43
- hash: 23
44
- segments:
45
- - 1
46
- - 0
47
- - 0
29
+ requirements:
30
+ - - ! '>='
31
+ - !ruby/object:Gem::Version
48
32
  version: 1.0.0
49
- requirement: *id002
50
- type: :development
51
- - !ruby/object:Gem::Dependency
52
- prerelease: false
53
- name: jeweler
54
- version_requirements: &id003 !ruby/object:Gem::Requirement
55
- none: false
56
- requirements:
57
- - - ~>
58
- - !ruby/object:Gem::Version
59
- hash: 7
60
- segments:
61
- - 1
62
- - 5
63
- - 2
64
- version: 1.5.2
65
- requirement: *id003
66
33
  type: :development
67
- - !ruby/object:Gem::Dependency
68
34
  prerelease: false
35
+ version_requirements: *7064420
36
+ - !ruby/object:Gem::Dependency
69
37
  name: rcov
70
- version_requirements: &id004 !ruby/object:Gem::Requirement
38
+ requirement: &7063940 !ruby/object:Gem::Requirement
71
39
  none: false
72
- requirements:
73
- - - ">="
74
- - !ruby/object:Gem::Version
75
- hash: 3
76
- segments:
77
- - 0
78
- version: "0"
79
- requirement: *id004
40
+ requirements:
41
+ - - ! '>='
42
+ - !ruby/object:Gem::Version
43
+ version: '0'
80
44
  type: :development
81
- - !ruby/object:Gem::Dependency
82
45
  prerelease: false
46
+ version_requirements: *7063940
47
+ - !ruby/object:Gem::Dependency
83
48
  name: active_scaffold_vho
84
- version_requirements: &id005 !ruby/object:Gem::Requirement
49
+ requirement: &7063460 !ruby/object:Gem::Requirement
85
50
  none: false
86
- requirements:
87
- - - ~>
88
- - !ruby/object:Gem::Version
89
- hash: 7
90
- segments:
91
- - 3
92
- - 0
93
- version: "3.0"
94
- requirement: *id005
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: 3.1.2
95
55
  type: :runtime
56
+ prerelease: false
57
+ version_requirements: *7063460
96
58
  description: Sort Tree or List Structures by Drag n Drop
97
59
  email: activescaffold@googlegroups.com
98
60
  executables: []
99
-
100
61
  extensions: []
101
-
102
- extra_rdoc_files:
103
- - LICENSE.txt
104
- - README.textile
105
- files:
106
- - .document
107
- - LICENSE.txt
108
- - README.textile
109
- - Rakefile
110
- - active_scaffold_sortable_vho.gemspec
111
- - frontends/default/stylesheets/sortable.css
112
- - frontends/default/views/_list_with_header.html.erb
113
- - frontends/default/views/on_create.js.rjs
114
- - frontends/default/views/on_update.js.rjs
115
- - frontends/default/views/reorder.js.rjs
116
- - init.rb
117
- - lib/active_scaffold/actions/sortable.rb
118
- - lib/active_scaffold/config/sortable.rb
119
- - lib/active_scaffold/helpers/sortable_helpers.rb
62
+ extra_rdoc_files: []
63
+ files:
64
+ - app/assets/stylesheets/sortable.css
65
+ - lib/active_scaffold_sortable_vho.rb
120
66
  - lib/active_scaffold_sortable.rb
121
- - lib/active_scaffold_sortable/config/core.rb
122
- - lib/active_scaffold_sortable/core.rb
123
67
  - lib/active_scaffold_sortable/version.rb
124
68
  - lib/active_scaffold_sortable/view_helpers.rb
125
- - lib/active_scaffold_sortable_vho.rb
126
- - test/auto_models_controller_test.rb
127
- - test/config_test.rb
128
- - test/controllers/auto_models_controller.rb
129
- - test/controllers/models_controller.rb
130
- - test/controllers/sortable_models_controller.rb
131
- - test/models/auto_model.rb
132
- - test/models/model.rb
133
- - test/router_test.rb
134
- - test/schema.rb
135
- - test/test_helper.rb
136
- has_rdoc: true
69
+ - lib/active_scaffold_sortable/config/core.rb
70
+ - lib/active_scaffold_sortable/engine.rb
71
+ - lib/active_scaffold_sortable/core.rb
72
+ - lib/active_scaffold/actions/sortable.rb
73
+ - lib/active_scaffold/config/sortable.rb
74
+ - lib/active_scaffold/helpers/sortable_helpers.rb
75
+ - README.textile
76
+ - LICENSE.txt
137
77
  homepage: http://github.com/vhochstein/active_scaffold_sortable
138
- licenses:
78
+ licenses:
139
79
  - MIT
140
80
  post_install_message:
141
81
  rdoc_options: []
142
-
143
- require_paths:
82
+ require_paths:
144
83
  - lib
145
- required_ruby_version: !ruby/object:Gem::Requirement
84
+ required_ruby_version: !ruby/object:Gem::Requirement
146
85
  none: false
147
- requirements:
148
- - - ">="
149
- - !ruby/object:Gem::Version
150
- hash: 3
151
- segments:
152
- - 0
153
- version: "0"
154
- required_rubygems_version: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - ! '>='
88
+ - !ruby/object:Gem::Version
89
+ version: '0'
90
+ required_rubygems_version: !ruby/object:Gem::Requirement
155
91
  none: false
156
- requirements:
157
- - - ">="
158
- - !ruby/object:Gem::Version
159
- hash: 3
160
- segments:
161
- - 0
162
- version: "0"
92
+ requirements:
93
+ - - ! '>='
94
+ - !ruby/object:Gem::Version
95
+ version: '0'
163
96
  requirements: []
164
-
165
97
  rubyforge_project:
166
- rubygems_version: 1.3.7
98
+ rubygems_version: 1.8.17
167
99
  signing_key:
168
100
  specification_version: 3
169
101
  summary: Drag n Drop Sorting for Activescaffold
170
- test_files:
171
- - test/auto_models_controller_test.rb
172
- - test/config_test.rb
173
- - test/controllers/auto_models_controller.rb
174
- - test/controllers/models_controller.rb
175
- - test/controllers/sortable_models_controller.rb
176
- - test/models/auto_model.rb
177
- - test/models/model.rb
178
- - test/router_test.rb
179
- - test/schema.rb
180
- - test/test_helper.rb
102
+ test_files: []
data/.document DELETED
@@ -1,5 +0,0 @@
1
- lib/**/*.rb
2
- bin/*
3
- -
4
- features/**/*.feature
5
- LICENSE.txt
data/Rakefile DELETED
@@ -1,56 +0,0 @@
1
- require 'rubygems'
2
- require 'bundler'
3
- begin
4
- Bundler.setup(:default, :development)
5
- rescue Bundler::BundlerError => e
6
- $stderr.puts e.message
7
- $stderr.puts "Run `bundle install` to install missing gems"
8
- exit e.status_code
9
- end
10
- require 'rake'
11
-
12
- require 'jeweler'
13
- require './lib/active_scaffold_sortable/version.rb'
14
- Jeweler::Tasks.new do |gem|
15
- # gem is a Gem::Specification... see http://docs.rubygems.org/read/chapter/20 for more options
16
- gem.name = "active_scaffold_sortable_vho"
17
- gem.version = ActiveScaffoldSortable::Version::STRING
18
- gem.homepage = "http://github.com/vhochstein/active_scaffold_sortable"
19
- gem.license = "MIT"
20
- gem.summary = %Q{Drag n Drop Sorting for Activescaffold}
21
- gem.description = %Q{Sort Tree or List Structures by Drag n Drop}
22
- gem.email = "activescaffold@googlegroups.com"
23
- gem.authors = ["Volker Hochstein"]
24
- gem.add_runtime_dependency 'active_scaffold_vho', '~> 3.0'
25
- # Include your dependencies below. Runtime dependencies are required when using your gem,
26
- # and development dependencies are only needed for development (ie running rake tasks, tests, etc)
27
- # gem.add_runtime_dependency 'jabber4r', '> 0.1'
28
- # gem.add_development_dependency 'rspec', '> 1.2.3'
29
- end
30
- Jeweler::RubygemsDotOrgTasks.new
31
-
32
- require 'rake/testtask'
33
- desc 'Test plugin.'
34
- Rake::TestTask.new(:test) do |t|
35
- t.libs << 'test'
36
- t.pattern = 'test/**/*_test.rb'
37
- t.verbose = true
38
- end
39
-
40
- require 'rcov/rcovtask'
41
- Rcov::RcovTask.new do |test|
42
- test.libs << 'test'
43
- test.pattern = 'test/**/test_*.rb'
44
- test.verbose = true
45
- end
46
-
47
- task :default => :test
48
-
49
- require 'rake/rdoctask'
50
- desc 'Generate documentation for plugin.'
51
- Rake::RDocTask.new(:rdoc) do |rdoc|
52
- rdoc.rdoc_dir = 'rdoc'
53
- rdoc.title = "active_scaffold_sortable #{ActiveScaffoldSortable::Version::STRING}"
54
- rdoc.rdoc_files.include('README*')
55
- rdoc.rdoc_files.include('lib/**/*.rb')
56
- end
@@ -1,94 +0,0 @@
1
- # Generated by jeweler
2
- # DO NOT EDIT THIS FILE DIRECTLY
3
- # Instead, edit Jeweler::Tasks in Rakefile, and run 'rake gemspec'
4
- # -*- encoding: utf-8 -*-
5
-
6
- Gem::Specification.new do |s|
7
- s.name = %q{active_scaffold_sortable_vho}
8
- s.version = "3.0.1"
9
-
10
- s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
- s.authors = ["Volker Hochstein"]
12
- s.date = %q{2011-02-01}
13
- s.description = %q{Sort Tree or List Structures by Drag n Drop}
14
- s.email = %q{activescaffold@googlegroups.com}
15
- s.extra_rdoc_files = [
16
- "LICENSE.txt",
17
- "README.textile"
18
- ]
19
- s.files = [
20
- ".document",
21
- "LICENSE.txt",
22
- "README.textile",
23
- "Rakefile",
24
- "active_scaffold_sortable_vho.gemspec",
25
- "frontends/default/stylesheets/sortable.css",
26
- "frontends/default/views/_list_with_header.html.erb",
27
- "frontends/default/views/on_create.js.rjs",
28
- "frontends/default/views/on_update.js.rjs",
29
- "frontends/default/views/reorder.js.rjs",
30
- "init.rb",
31
- "lib/active_scaffold/actions/sortable.rb",
32
- "lib/active_scaffold/config/sortable.rb",
33
- "lib/active_scaffold/helpers/sortable_helpers.rb",
34
- "lib/active_scaffold_sortable.rb",
35
- "lib/active_scaffold_sortable/config/core.rb",
36
- "lib/active_scaffold_sortable/core.rb",
37
- "lib/active_scaffold_sortable/version.rb",
38
- "lib/active_scaffold_sortable/view_helpers.rb",
39
- "lib/active_scaffold_sortable_vho.rb",
40
- "test/auto_models_controller_test.rb",
41
- "test/config_test.rb",
42
- "test/controllers/auto_models_controller.rb",
43
- "test/controllers/models_controller.rb",
44
- "test/controllers/sortable_models_controller.rb",
45
- "test/models/auto_model.rb",
46
- "test/models/model.rb",
47
- "test/router_test.rb",
48
- "test/schema.rb",
49
- "test/test_helper.rb"
50
- ]
51
- s.homepage = %q{http://github.com/vhochstein/active_scaffold_sortable}
52
- s.licenses = ["MIT"]
53
- s.require_paths = ["lib"]
54
- s.rubygems_version = %q{1.3.7}
55
- s.summary = %q{Drag n Drop Sorting for Activescaffold}
56
- s.test_files = [
57
- "test/auto_models_controller_test.rb",
58
- "test/config_test.rb",
59
- "test/controllers/auto_models_controller.rb",
60
- "test/controllers/models_controller.rb",
61
- "test/controllers/sortable_models_controller.rb",
62
- "test/models/auto_model.rb",
63
- "test/models/model.rb",
64
- "test/router_test.rb",
65
- "test/schema.rb",
66
- "test/test_helper.rb"
67
- ]
68
-
69
- if s.respond_to? :specification_version then
70
- current_version = Gem::Specification::CURRENT_SPECIFICATION_VERSION
71
- s.specification_version = 3
72
-
73
- if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
74
- s.add_development_dependency(%q<shoulda>, [">= 0"])
75
- s.add_development_dependency(%q<bundler>, ["~> 1.0.0"])
76
- s.add_development_dependency(%q<jeweler>, ["~> 1.5.2"])
77
- s.add_development_dependency(%q<rcov>, [">= 0"])
78
- s.add_runtime_dependency(%q<active_scaffold_vho>, ["~> 3.0"])
79
- else
80
- s.add_dependency(%q<shoulda>, [">= 0"])
81
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
82
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
83
- s.add_dependency(%q<rcov>, [">= 0"])
84
- s.add_dependency(%q<active_scaffold_vho>, ["~> 3.0"])
85
- end
86
- else
87
- s.add_dependency(%q<shoulda>, [">= 0"])
88
- s.add_dependency(%q<bundler>, ["~> 1.0.0"])
89
- s.add_dependency(%q<jeweler>, ["~> 1.5.2"])
90
- s.add_dependency(%q<rcov>, [">= 0"])
91
- s.add_dependency(%q<active_scaffold_vho>, ["~> 3.0"])
92
- end
93
- end
94
-
@@ -1,9 +0,0 @@
1
- <%= render :super %>
2
- <% if ActiveScaffold.js_framework == :prototype %>
3
- <%= sortable_element *sort_params %>
4
- <% elsif ActiveScaffold.js_framework == :jquery %>
5
- <% reorder_params = {}
6
- reorder_params[:eid] = params[:eid] unless params[:eid].blank?
7
- options = {:update => true, :action => 'reorder'} %>
8
- <%= javascript_tag "ActiveScaffold.sortable('#{sort_params[0]}', #{controller_name.to_json}, #{options.to_json}, #{reorder_params.to_json});" %>
9
- <% end %>
@@ -1,10 +0,0 @@
1
- page << render(:super, :locals => {:insert_at => :bottom})
2
- unless nested_singular_association?
3
- if ActiveScaffold.js_framework == :prototype
4
- page.sortable(*sort_params)
5
- elsif ActiveScaffold.js_framework == :jquery
6
- reorder_params = {}
7
- reorder_params[:eid] = params[:eid] unless params[:eid].blank?
8
- page << "ActiveScaffold.sortable('#{sort_params[0]}', #{controller_name.to_json}, #{reorder_params.to_json});"
9
- end if controller.send :successful?
10
- end
@@ -1,11 +0,0 @@
1
- page << render(:super)
2
- # if we are currently editing a nested belongs_to association do not do any sorting stuff
3
- unless nested_singular_association?
4
- if ActiveScaffold.js_framework == :prototype
5
- page.sortable(*sort_params)
6
- elsif ActiveScaffold.js_framework == :jquery
7
- reorder_params = {}
8
- reorder_params[:eid] = params[:eid] unless params[:eid].blank?
9
- page << "ActiveScaffold.sortable('#{sort_params[0]}', #{controller_name.to_json}, #{reorder_params.to_json});"
10
- end if controller.send :successful?
11
- end
@@ -1 +0,0 @@
1
- page << "ActiveScaffold.stripe('#{active_scaffold_tbody_id}');"
data/init.rb DELETED
@@ -1,7 +0,0 @@
1
- require 'active_scaffold_sortable'
2
-
3
- begin
4
- ActiveScaffoldAssets.copy_to_public(ActiveScaffoldSortable.root)
5
- rescue
6
- raise $! unless Rails.env == 'production'
7
- end
@@ -1,52 +0,0 @@
1
- require 'test_helper.rb'
2
-
3
- class AutoModelsControllerTest < ActionController::TestCase
4
- @@sortable_regexp = Regexp.new('Sortable.create\("as_auto_models-tbody", \{format:/\^\[\^_-\]\(\?:\[A-Za-z0-9_-\]\*\)-\(\.\*\)-row\$/, onUpdate:function\(\)\{new Ajax.Request\(\'/auto_models/reorder\', \{asynchronous:true, evalScripts:true, parameters:Sortable.serialize\("as_auto_models-tbody"\) \+ \'&controller=\' \+ encodeURIComponent\(\'auto_models\'\)\}\)\}, tag:\'tr\'\}\)')
5
- setup { AutoModel.create :name => 'test', :position => 1 }
6
-
7
- context "reordering" do
8
- setup do
9
- updates = sequence(:updates)
10
- AutoModel.expects(:update_all).with({:position => 1}, 'id' => '2').in_sequence(updates)
11
- AutoModel.expects(:update_all).with({:position => 2}, 'id' => '1').in_sequence(updates)
12
- xhr :post, :reorder, :'as_auto_models-tbody' => ['2', '1']
13
- end
14
- should_respond_with :success
15
- should_render_template :reorder
16
- should "update stripe" do
17
- assert_equal 'ActiveScaffold.stripe(\'as_auto_models-tbody\');', @response.body
18
- end
19
- end
20
-
21
- context "listing" do
22
- setup { get :index }
23
- should "render record with sortable class" do
24
- assert_select '.records tr.record.sortable'
25
- end
26
- should "render sortable script" do
27
- assert_select 'script[type=text/javascript]', @@sortable_regexp
28
- end
29
- end
30
-
31
- context "creating" do
32
- setup { xhr :post, :create, :record => {:name => 'test2', :position => 2} }
33
- should_respond_with :success
34
- should "insert at top" do
35
- assert_match "$(\"as_auto_models-tbody\").insert(\"as_auto_models-list-#{assigns(:record).id}-row\");", @response.body
36
- end
37
- should "update stripe" do
38
- assert_match 'ActiveScaffold.stripe(\'as_auto_models-tbody\');', @response.body
39
- end
40
- should "update sortable" do
41
- assert_match @@sortable_regexp, @response.body
42
- end
43
- end
44
-
45
- context "updating" do
46
- setup { xhr :put, :update, :id => 1, :record => {:name => 'test updated'} }
47
- should_respond_with :success
48
- should "update sortable" do
49
- assert_match @@sortable_regexp, @response.body
50
- end
51
- end
52
- end
data/test/config_test.rb DELETED
@@ -1,59 +0,0 @@
1
- require 'test_helper.rb'
2
-
3
- class ConfigTest < Test::Unit::TestCase
4
- def test_not_enable_sortable
5
- assert !ModelsController.active_scaffold_config.actions.include?(:sortable)
6
- end
7
-
8
- def test_auto_enable_sortable
9
- assert AutoModelsController.active_scaffold_config.actions.include?(:sortable)
10
- end
11
-
12
- def test_manual_enable_sortable
13
- assert SortableModelsController.active_scaffold_config.actions.include?(:sortable)
14
- end
15
-
16
- def test_position_column
17
- assert_equal :position, AutoModelsController.active_scaffold_config.sortable.column.name
18
- assert_equal :name, SortableModelsController.active_scaffold_config.sortable.column.name
19
- end
20
-
21
- def test_position_column_not_included
22
- assert !AutoModelsController.active_scaffold_config.list.columns.include?(:position)
23
- assert !AutoModelsController.active_scaffold_config.update.columns.include?(:position)
24
- assert !AutoModelsController.active_scaffold_config.create.columns.include?(:position)
25
- assert !AutoModelsController.active_scaffold_config.show.columns.include?(:position)
26
- assert !AutoModelsController.active_scaffold_config.subform.columns.include?(:position)
27
- assert !AutoModelsController.active_scaffold_config.search.columns.include?(:position)
28
-
29
- assert !SortableModelsController.active_scaffold_config.list.columns.include?(:name)
30
- assert !SortableModelsController.active_scaffold_config.update.columns.include?(:name)
31
- assert !SortableModelsController.active_scaffold_config.create.columns.include?(:name)
32
- assert !SortableModelsController.active_scaffold_config.show.columns.include?(:name)
33
- end
34
-
35
- def test_sorting
36
- assert_equal('"models"."id" ASC', ModelsController.active_scaffold_config.list.sorting.clause)
37
- assert ModelsController.active_scaffold_config.columns[:name].sortable?
38
- assert ModelsController.active_scaffold_config.columns[:position].sortable?
39
-
40
- assert_equal('"models"."position" ASC', AutoModelsController.active_scaffold_config.list.sorting.clause)
41
- assert !AutoModelsController.active_scaffold_config.columns[:name].sortable?
42
-
43
- assert_equal('"models"."name" ASC', SortableModelsController.active_scaffold_config.list.sorting.clause)
44
- assert !SortableModelsController.active_scaffold_config.columns[:position].sortable?
45
- end
46
-
47
- def test_pagination
48
- assert ModelsController.active_scaffold_config.list.pagination
49
- assert !AutoModelsController.active_scaffold_config.list.pagination
50
- assert !SortableModelsController.active_scaffold_config.list.pagination
51
- end
52
-
53
- def test_active_scaffold_paths
54
- path = File.join(Rails.root, 'vendor/plugins/active_scaffold_sortable/frontends/default/views')
55
- assert !ModelsController.active_scaffold_paths.include?(path)
56
- assert AutoModelsController.active_scaffold_paths.include?(path)
57
- assert SortableModelsController.active_scaffold_paths.include?(path)
58
- end
59
- end
@@ -1,3 +0,0 @@
1
- class AutoModelsController < ActionController::Base
2
- active_scaffold :auto_model
3
- end
@@ -1,3 +0,0 @@
1
- class ModelsController < ActionController::Base
2
- active_scaffold
3
- end
@@ -1,7 +0,0 @@
1
- class SortableModelsController < ActionController::Base
2
- active_scaffold :model do |config|
3
- config.actions.exclude :search
4
- config.actions << :sortable
5
- config.sortable.column = :name
6
- end
7
- end
@@ -1,8 +0,0 @@
1
- class AutoModel < Model
2
- def acts_as_list_class
3
- end
4
-
5
- def position_column
6
- 'position'
7
- end
8
- end
data/test/models/model.rb DELETED
@@ -1,2 +0,0 @@
1
- class Model < ActiveRecord::Base
2
- end
data/test/router_test.rb DELETED
@@ -1,5 +0,0 @@
1
- require 'test_helper.rb'
2
-
3
- class RouterTest < ActionController::TestCase
4
- should_route :post, "/sortable_models/reorder", :controller => :sortable_models, :action => :reorder
5
- end
data/test/schema.rb DELETED
@@ -1,9 +0,0 @@
1
- # encoding: utf-8
2
-
3
- ActiveRecord::Schema.define(:version => 1) do
4
- create_table 'models', :force => true do |t|
5
- t.string 'name'
6
- t.integer 'position'
7
- end
8
- add_index 'models', ['position']
9
- end
data/test/test_helper.rb DELETED
@@ -1,48 +0,0 @@
1
- # encoding: utf-8
2
- ENV["RAILS_ENV"] = "test"
3
-
4
- require 'test/unit'
5
- # You can use "rake test AR_VERSION=2.0.5" to test against 2.0.5, for example.
6
- # The default is to use the latest installed ActiveRecord.
7
- if ENV["AR_VERSION"]
8
- gem 'activerecord', "#{ENV["AR_VERSION"]}"
9
- gem 'actionpack', "#{ENV["AR_VERSION"]}"
10
- gem 'activesupport', "#{ENV["AR_VERSION"]}"
11
- end
12
- require 'rubygems'
13
- require 'active_record'
14
- require 'action_controller'
15
- require 'action_view/test_case'
16
- require 'action_mailer'
17
- require 'active_support'
18
- require 'initializer'
19
- ActionController::Base::logger = ActiveSupport::BufferedLogger.new(Tempfile.new('log').path)
20
-
21
- RAILS_ROOT = File.join(File.dirname(__FILE__), '../../../..')
22
- Rails.configuration = Rails::Configuration.new
23
-
24
- require 'shoulda'
25
- require 'shoulda/rails'
26
- require 'mocha'
27
- begin
28
- require 'redgreen'
29
- rescue LoadError
30
- end
31
-
32
- ActiveSupport::Dependencies.load_paths = %w(test/models test/controllers lib ../active_scaffold/lib).map {|dir| File.dirname(__FILE__) + "/../#{dir}"}
33
- $:.unshift *ActiveSupport::Dependencies.load_paths
34
-
35
- require File.join(File.dirname(__FILE__), '../../active_scaffold/environment')
36
- require 'sortable'
37
-
38
- ActionController::Routing::Routes.draw do |map|
39
- map.root :controller => 'home'
40
- map.resources :sortable_models, :active_scaffold => true
41
- map.resources :auto_models, :active_scaffold => true
42
- map.resources :models, :active_scaffold => true
43
- end
44
-
45
- ActiveRecord::Base.establish_connection :adapter => "sqlite3", :database => ":memory:"
46
- silence_stream(STDOUT) do
47
- load(File.dirname(__FILE__) + "/schema.rb")
48
- end