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 +4 -4
- data/lib/active_scaffold/helpers/duplicate_helpers.rb +14 -0
- data/lib/active_scaffold_duplicate.rb +4 -0
- data/lib/active_scaffold_duplicate/engine.rb +5 -0
- data/lib/active_scaffold_duplicate/version.rb +1 -1
- metadata +17 -35
- data/test/auto_models_controller_test.rb +0 -52
- data/test/config_test.rb +0 -59
- data/test/controllers/auto_models_controller.rb +0 -3
- data/test/controllers/models_controller.rb +0 -3
- data/test/controllers/sortable_models_controller.rb +0 -7
- data/test/models/auto_model.rb +0 -8
- data/test/models/model.rb +0 -2
- data/test/router_test.rb +0 -5
- data/test/schema.rb +0 -9
- data/test/test_helper.rb +0 -48
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA512:
|
3
|
-
|
4
|
-
|
3
|
+
metadata.gz: 9b5d2ea08bb9933c5c781fdc04d62c32e6e20d16e8459228d587191bc9c0c16614f525ce4f0618cdaa8991521f37a3862622f20ab00deb1c1465d1e238b6b3dd
|
4
|
+
data.tar.gz: be85990c06e9a547ade9832c317a5cf639b91cf89eb954c6894524cd688cf12d7d59d5e59c08eac1843ddfa2494ec224b2f8da6b13807114dad9473037b096d2
|
5
5
|
SHA1:
|
6
|
-
|
7
|
-
|
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
|
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.
|
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-
|
12
|
+
date: 2014-06-11 00:00:00 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
-
|
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
|
data/test/models/auto_model.rb
DELETED
data/test/models/model.rb
DELETED
data/test/router_test.rb
DELETED
data/test/schema.rb
DELETED
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
|