active_scaffold_duplicate 1.0.1 → 1.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA512:
3
- data.tar.gz: fe4482042e71ce1e6bcc63b89b863c254f92d421b32599109f919858fd465382e45d2f8efd2377966499420fb3b7689e5a0d53d4ce8ae0650a4b0cfe38af3355
4
- metadata.gz: bb3a717673f55a665db6c817f41439a191d3fadf9a0b58d2f0e77eff71e4cbfb50273580bc8deb7a0c0848faee526ad43a5ec4f89d90e1ad12ebc9da575a37c1
3
+ metadata.gz: 9b5d2ea08bb9933c5c781fdc04d62c32e6e20d16e8459228d587191bc9c0c16614f525ce4f0618cdaa8991521f37a3862622f20ab00deb1c1465d1e238b6b3dd
4
+ data.tar.gz: be85990c06e9a547ade9832c317a5cf639b91cf89eb954c6894524cd688cf12d7d59d5e59c08eac1843ddfa2494ec224b2f8da6b13807114dad9473037b096d2
5
5
  SHA1:
6
- data.tar.gz: 86c1f70bcb1c2d68272246587de58b7219ade71b
7
- metadata.gz: dab546f0a8408f5a9999e9d91d419d548884427b
6
+ metadata.gz: 5daa3ed12a984d555966e05ce266457eabfe3f50
7
+ data.tar.gz: befe1fe887af748add75ff9fe4f72c55e7a00b45
@@ -0,0 +1,14 @@
1
+ module ActiveScaffold
2
+ module Helpers
3
+ module DuplicateHelpers
4
+ def current_form_columns(record, scope, subform_controller = nil)
5
+ columns = super
6
+ if columns.nil? && action_name == 'duplicate'
7
+ active_scaffold_config.create.columns.names
8
+ else
9
+ columns
10
+ end
11
+ end
12
+ end
13
+ end
14
+ end
@@ -15,4 +15,8 @@ module ActiveScaffold
15
15
  module Config
16
16
  ActiveScaffold.autoload_subdir('config', self, File.dirname(__FILE__))
17
17
  end
18
+
19
+ module Helpers
20
+ ActiveScaffold.autoload_subdir('helpers', self, File.dirname(__FILE__))
21
+ end
18
22
  end
@@ -1,4 +1,9 @@
1
1
  module ActiveScaffoldDuplicate
2
2
  class Engine < ::Rails::Engine
3
+ initializer "active_scaffold.action_view" do |app|
4
+ ActiveSupport.on_load :action_view do
5
+ include ActiveScaffold::Helpers::DuplicateHelpers
6
+ end
7
+ end
3
8
  end
4
9
  end
@@ -2,7 +2,7 @@ module ActiveScaffoldDuplicate
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: active_scaffold_duplicate
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.1
4
+ version: 1.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sergio Cambra
@@ -9,47 +9,47 @@ autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
11
 
12
- date: 2014-02-17 00:00:00 Z
12
+ date: 2014-06-11 00:00:00 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
- version_requirements: &id001 !ruby/object:Gem::Requirement
15
+ requirement: &id001 !ruby/object:Gem::Requirement
16
16
  requirements:
17
17
  - &id003
18
18
  - ">="
19
19
  - !ruby/object:Gem::Version
20
20
  version: "0"
21
+ version_requirements: *id001
22
+ prerelease: false
21
23
  type: :development
22
24
  name: shoulda
23
- requirement: *id001
24
- prerelease: false
25
25
  - !ruby/object:Gem::Dependency
26
- version_requirements: &id002 !ruby/object:Gem::Requirement
26
+ requirement: &id002 !ruby/object:Gem::Requirement
27
27
  requirements:
28
28
  - - ~>
29
29
  - !ruby/object:Gem::Version
30
30
  version: 1.0.0
31
+ version_requirements: *id002
32
+ prerelease: false
31
33
  type: :development
32
34
  name: bundler
33
- requirement: *id002
34
- prerelease: false
35
35
  - !ruby/object:Gem::Dependency
36
- version_requirements: &id004 !ruby/object:Gem::Requirement
36
+ requirement: &id004 !ruby/object:Gem::Requirement
37
37
  requirements:
38
38
  - *id003
39
+ version_requirements: *id004
40
+ prerelease: false
39
41
  type: :development
40
42
  name: rcov
41
- requirement: *id004
42
- prerelease: false
43
43
  - !ruby/object:Gem::Dependency
44
- version_requirements: &id005 !ruby/object:Gem::Requirement
44
+ requirement: &id005 !ruby/object:Gem::Requirement
45
45
  requirements:
46
46
  - - ">="
47
47
  - !ruby/object:Gem::Version
48
48
  version: 3.3.0.rc
49
+ version_requirements: *id005
50
+ prerelease: false
49
51
  type: :runtime
50
52
  name: active_scaffold
51
- requirement: *id005
52
- prerelease: false
53
53
  description: Clone records using a method from model in ActiveScaffold
54
54
  email: activescaffold@googlegroups.com
55
55
  executables: []
@@ -69,6 +69,7 @@ files:
69
69
  - lib/active_scaffold/config/clone.rb~
70
70
  - lib/active_scaffold/config/duplicate.rb
71
71
  - lib/active_scaffold/config/duplicate.rb~
72
+ - lib/active_scaffold/helpers/duplicate_helpers.rb
72
73
  - lib/active_scaffold_duplicate/config/core.rb
73
74
  - lib/active_scaffold_duplicate/config/core.rb~
74
75
  - lib/active_scaffold_duplicate/version.rb
@@ -83,16 +84,6 @@ files:
83
84
  - config/locales/en.yml
84
85
  - LICENSE.txt
85
86
  - README.textile
86
- - test/auto_models_controller_test.rb
87
- - test/config_test.rb
88
- - test/controllers/auto_models_controller.rb
89
- - test/controllers/models_controller.rb
90
- - test/controllers/sortable_models_controller.rb
91
- - test/models/auto_model.rb
92
- - test/models/model.rb
93
- - test/router_test.rb
94
- - test/schema.rb
95
- - test/test_helper.rb
96
87
  homepage: http://github.com/activescaffold/active_scaffold_duplicate
97
88
  licenses:
98
89
  - MIT
@@ -116,14 +107,5 @@ rubygems_version: 2.0.7
116
107
  signing_key:
117
108
  specification_version: 4
118
109
  summary: Clone record gem for Activescaffold
119
- test_files:
120
- - test/auto_models_controller_test.rb
121
- - test/config_test.rb
122
- - test/controllers/auto_models_controller.rb
123
- - test/controllers/models_controller.rb
124
- - test/controllers/sortable_models_controller.rb
125
- - test/models/auto_model.rb
126
- - test/models/model.rb
127
- - test/router_test.rb
128
- - test/schema.rb
129
- - test/test_helper.rb
110
+ test_files: []
111
+
@@ -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