rows_controller 2.0.3 → 2.0.5

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/app/controllers/rows_controller.rb +8 -6
  3. data/app/controllers/rows_controller.rb.bak +89 -0
  4. data/lib/{rows_controller → rows}/engine.rb +0 -0
  5. data/lib/{rows_controller → rows}/locales/de.yml +0 -0
  6. data/lib/{rows_controller → rows}/locales/en.yml +0 -0
  7. data/lib/{rows_controller → rows}/model.rb +0 -0
  8. data/lib/{rows_controller → rows}/resources.rb +0 -0
  9. data/lib/{rows_controller → rows}/utils.rb +0 -0
  10. data/lib/rows/version.rb +3 -0
  11. data/lib/rows/version.rb.bak +3 -0
  12. data/lib/rows_controller.rb +3 -3
  13. metadata +13 -99
  14. data/.travis.yml +0 -19
  15. data/.watchr +0 -55
  16. data/Appraisals +0 -7
  17. data/lib/rows_controller/version.rb +0 -3
  18. data/test/controllers/order/items_controller_test.rb +0 -53
  19. data/test/controllers/orders_controller_test.rb +0 -53
  20. data/test/controllers/orders_test.rb +0 -93
  21. data/test/controllers/rows_controller_test.rb +0 -52
  22. data/test/controllers/rows_ext_controller_test.rb +0 -22
  23. data/test/dummy/Rakefile +0 -6
  24. data/test/dummy/app/controllers/application_controller.rb +0 -5
  25. data/test/dummy/app/controllers/order/items_controller.rb +0 -8
  26. data/test/dummy/app/controllers/orders_controller.rb +0 -8
  27. data/test/dummy/app/models/order.rb +0 -11
  28. data/test/dummy/app/models/order/item.rb +0 -2
  29. data/test/dummy/app/views/layouts/application.html.erb +0 -12
  30. data/test/dummy/app/views/order/items/_form.html.erb +0 -8
  31. data/test/dummy/app/views/orders/_form.html.erb +0 -8
  32. data/test/dummy/bin/bundle +0 -3
  33. data/test/dummy/bin/rails +0 -4
  34. data/test/dummy/bin/rake +0 -4
  35. data/test/dummy/bin/setup +0 -29
  36. data/test/dummy/config.ru +0 -4
  37. data/test/dummy/config/application.rb +0 -26
  38. data/test/dummy/config/boot.rb +0 -5
  39. data/test/dummy/config/database.yml +0 -25
  40. data/test/dummy/config/environment.rb +0 -5
  41. data/test/dummy/config/environments/development.rb +0 -41
  42. data/test/dummy/config/environments/production.rb +0 -79
  43. data/test/dummy/config/environments/test.rb +0 -42
  44. data/test/dummy/config/initializers/cookies_serializer.rb +0 -3
  45. data/test/dummy/config/initializers/filter_parameter_logging.rb +0 -4
  46. data/test/dummy/config/initializers/session_store.rb +0 -3
  47. data/test/dummy/config/initializers/wrap_parameters.rb +0 -14
  48. data/test/dummy/config/routes.rb +0 -9
  49. data/test/dummy/config/secrets.yml +0 -22
  50. data/test/dummy/db/development.sqlite3 +0 -0
  51. data/test/dummy/db/migrate/001_create_orders.rb +0 -9
  52. data/test/dummy/db/migrate/002_create_order_items.rb +0 -9
  53. data/test/dummy/db/schema.rb +0 -28
  54. data/test/dummy/db/test.sqlite3 +0 -0
  55. data/test/dummy/tmp/restart.txt +0 -0
  56. data/test/fixtures/order/items.yml +0 -5
  57. data/test/fixtures/orders.yml +0 -5
  58. data/test/test_helper.rb +0 -27
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afd501f680af68257cdd2a7f5df5874862667259
4
- data.tar.gz: ec22cd6d7a4f72057d1712065c1310313d9bb1f9
3
+ metadata.gz: 33f9954a9ae20610991b324e71feb9919bda9b7d
4
+ data.tar.gz: 6e175282d743d493a3d6799df84f5716eb5a1c62
5
5
  SHA512:
6
- metadata.gz: 757d0fb0008aa4f1115203f554e18a57fcb76ac0159871754766fc0d6f92bbd3c3415dcc1090cebe76d823dc3d26c2bda2002c114e2f01a02bf5c0974b7525b5
7
- data.tar.gz: f310dc6c707b4a8d4aea2ecb005c9d02baa167f3dbc0d08748c1224f42b52bb976582c917ed1c5519d44361621dc453a4a9da4eba58585a0347a04222d1a1e71
6
+ metadata.gz: cf4b93b51d181c35c938e12a458faaadd64dc0d53703bfa053ef49f8162d627718758c30ee00d29c19f6bea0cc0e8bc059b1ba772100e33d131cf94c5d9fed0a
7
+ data.tar.gz: 0417c1c32c5972b5a2f113dc62ca3ff2c25262de82d82c19b1880fc15a16f0e3e28ac784997e0b2a90e7438057c3e8c2bfb15593e246076d06e10c0ff8f31cfe
@@ -1,10 +1,8 @@
1
- require 'rows_controller/resources'
2
- require 'rows_controller/model'
3
- require 'rows_controller/utils'
1
+ require 'rows/resources'
2
+ require 'rows/model'
3
+ require 'rows/utils'
4
4
 
5
5
  class RowsController < ApplicationController
6
- before_action :set_resource, only: [:show, :edit, :update, :destroy]
7
-
8
6
  helper_method :set_resource, :set_resources, :resource, :resources
9
7
  helper_method :resource_columns, :resource_format
10
8
  helper_method :model_class, :model_name
@@ -26,6 +24,7 @@ class RowsController < ApplicationController
26
24
 
27
25
  # GET /:resource/:id[.json]
28
26
  def show
27
+ set_resource
29
28
  end
30
29
 
31
30
  # GET /:resource/new
@@ -35,6 +34,7 @@ class RowsController < ApplicationController
35
34
 
36
35
  # GET /:resource/:id/edit
37
36
  def edit
37
+ set_resource
38
38
  end
39
39
 
40
40
  # POST /:resources[.json]
@@ -44,16 +44,18 @@ class RowsController < ApplicationController
44
44
 
45
45
  # PATCH/PUT /:resources/:id[.json]
46
46
  def update
47
+ set_resource
47
48
  create_update(:resource_update, 'updated')
48
49
  end
49
50
 
50
51
  # DELETE /:resources/:id[.json]
51
52
  def destroy
53
+ set_resource
52
54
  resource_destroy
53
55
  flash[:notice] = t('ui.destroyed', model: model_name).html_safe unless request.xhr?
54
56
  respond_to do |format|
55
57
  format.html { redirect_to action: :index }
56
- format.js { render template: 'rows_controller/destroy', layout: false }
58
+ format.js { render template: 'rows/destroy', layout: false }
57
59
  format.json { head :no_content }
58
60
  end
59
61
  end
@@ -0,0 +1,89 @@
1
+ require 'rows/resources'
2
+ require 'rows/model'
3
+ require 'rows/utils'
4
+
5
+ class RowsController < ApplicationController
6
+ if defined?(before_action)
7
+ before_action :set_resource, only: [:show, :edit, :update, :destroy]
8
+ else
9
+ before_filter :set_resource, only: [:show, :edit, :update, :destroy]
10
+ end
11
+
12
+ helper_method :set_resource, :set_resources, :resource, :resources
13
+ helper_method :resource_columns, :resource_format
14
+ helper_method :model_class, :model_name
15
+ helper_method :model_symbol, :model_symbol_plural
16
+
17
+ include Rows::Model
18
+ include Rows::Resources
19
+ include Rows::Utils
20
+
21
+ def self.model_class(model_class = nil)
22
+ @_model_class = model_class unless model_class.nil?
23
+ @_model_class
24
+ end
25
+
26
+ # GET /:resources[.json]
27
+ def index
28
+ set_resources
29
+ end
30
+
31
+ # GET /:resource/:id[.json]
32
+ def show
33
+ end
34
+
35
+ # GET /:resource/new
36
+ def new
37
+ resource_new
38
+ end
39
+
40
+ # GET /:resource/:id/edit
41
+ def edit
42
+ end
43
+
44
+ # POST /:resources[.json]
45
+ def create
46
+ create_update(:resource_create, 'created')
47
+ end
48
+
49
+ # PATCH/PUT /:resources/:id[.json]
50
+ def update
51
+ create_update(:resource_update, 'updated')
52
+ end
53
+
54
+ # DELETE /:resources/:id[.json]
55
+ def destroy
56
+ resource_destroy
57
+ flash[:notice] = t('ui.destroyed', model: model_name).html_safe unless request.xhr?
58
+ respond_to do |format|
59
+ format.html { redirect_to action: :index }
60
+ format.js { render template: 'rows/destroy', layout: false }
61
+ format.json { head :no_content }
62
+ end
63
+ end
64
+
65
+ private
66
+ def create_update(which, msg)
67
+ respond_to do |format|
68
+ if self.send(which)
69
+ format.html {
70
+ flash[:notice] = t(msg, scope: :ui, model: model_name,
71
+ default: "%{model} was successfully #{msg}.").html_safe
72
+ if params[:commit] == 'OK'
73
+ redirect_to action: :index
74
+ else
75
+ redirect_to action: 'edit', id: resource.id
76
+ end
77
+ }
78
+ format.json { render action: 'show',
79
+ status: msg == 'created' ? :created : :ok,
80
+ location: resource }
81
+ else ## failed
82
+ format.html { render action: msg == 'created' ? :new : :edit }
83
+ format.json { render json: resource.errors,
84
+ status: :unprocessable_entity }
85
+ end
86
+ end
87
+ end
88
+
89
+ end
File without changes
File without changes
File without changes
File without changes
File without changes
File without changes
@@ -0,0 +1,3 @@
1
+ module Rows
2
+ VERSION = "2.0.5"
3
+ end
@@ -0,0 +1,3 @@
1
+ module Rows
2
+ VERSION = "2.0.4"
3
+ end
@@ -1,8 +1,8 @@
1
- require 'rows_controller/engine'
1
+ require 'rows/engine'
2
2
 
3
3
  module Rows
4
4
  end
5
5
 
6
- I18n.load_path << File.expand_path('../rows_controller/locales/en.yml', __FILE__)
7
- I18n.load_path << File.expand_path('../rows_controller/locales/de.yml', __FILE__)
6
+ I18n.load_path << File.expand_path('../rows/locales/en.yml', __FILE__)
7
+ I18n.load_path << File.expand_path('../rows/locales/de.yml', __FILE__)
8
8
  I18n.reload!
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rows_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.3
4
+ version: 2.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Dittmar Krall
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-10-21 00:00:00.000000000 Z
11
+ date: 2015-10-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sqlite3
@@ -31,13 +31,11 @@ executables: []
31
31
  extensions: []
32
32
  extra_rdoc_files: []
33
33
  files:
34
- - ".travis.yml"
35
- - ".watchr"
36
- - Appraisals
37
34
  - MIT-LICENSE
38
35
  - README.md
39
36
  - Rakefile
40
37
  - app/controllers/rows_controller.rb
38
+ - app/controllers/rows_controller.rb.bak
41
39
  - app/controllers/rows_ext_controller.rb
42
40
  - app/views/rows/_form.slim
43
41
  - app/views/rows/_list.slim
@@ -54,56 +52,16 @@ files:
54
52
  - app/views/rows/show.slim
55
53
  - app/views/shared/_error_explanation.slim
56
54
  - app/views/shared/_show_flash.slim
55
+ - lib/rows/engine.rb
56
+ - lib/rows/locales/de.yml
57
+ - lib/rows/locales/en.yml
58
+ - lib/rows/model.rb
59
+ - lib/rows/resources.rb
60
+ - lib/rows/utils.rb
61
+ - lib/rows/version.rb
62
+ - lib/rows/version.rb.bak
57
63
  - lib/rows_controller.rb
58
- - lib/rows_controller/engine.rb
59
- - lib/rows_controller/locales/de.yml
60
- - lib/rows_controller/locales/en.yml
61
- - lib/rows_controller/model.rb
62
- - lib/rows_controller/resources.rb
63
- - lib/rows_controller/utils.rb
64
- - lib/rows_controller/version.rb
65
- - test/controllers/order/items_controller_test.rb
66
- - test/controllers/orders_controller_test.rb
67
- - test/controllers/orders_test.rb
68
- - test/controllers/rows_controller_test.rb
69
- - test/controllers/rows_ext_controller_test.rb
70
- - test/dummy/Rakefile
71
- - test/dummy/app/controllers/application_controller.rb
72
- - test/dummy/app/controllers/order/items_controller.rb
73
- - test/dummy/app/controllers/orders_controller.rb
74
- - test/dummy/app/models/order.rb
75
- - test/dummy/app/models/order/item.rb
76
- - test/dummy/app/views/layouts/application.html.erb
77
- - test/dummy/app/views/order/items/_form.html.erb
78
- - test/dummy/app/views/orders/_form.html.erb
79
- - test/dummy/bin/bundle
80
- - test/dummy/bin/rails
81
- - test/dummy/bin/rake
82
- - test/dummy/bin/setup
83
- - test/dummy/config.ru
84
- - test/dummy/config/application.rb
85
- - test/dummy/config/boot.rb
86
- - test/dummy/config/database.yml
87
- - test/dummy/config/environment.rb
88
- - test/dummy/config/environments/development.rb
89
- - test/dummy/config/environments/production.rb
90
- - test/dummy/config/environments/test.rb
91
- - test/dummy/config/initializers/cookies_serializer.rb
92
- - test/dummy/config/initializers/filter_parameter_logging.rb
93
- - test/dummy/config/initializers/session_store.rb
94
- - test/dummy/config/initializers/wrap_parameters.rb
95
- - test/dummy/config/routes.rb
96
- - test/dummy/config/secrets.yml
97
- - test/dummy/db/development.sqlite3
98
- - test/dummy/db/migrate/001_create_orders.rb
99
- - test/dummy/db/migrate/002_create_order_items.rb
100
- - test/dummy/db/schema.rb
101
- - test/dummy/db/test.sqlite3
102
- - test/dummy/tmp/restart.txt
103
- - test/fixtures/order/items.yml
104
- - test/fixtures/orders.yml
105
- - test/test_helper.rb
106
- homepage: http://matique.de
64
+ homepage: https://github.com/matique/rows_controller
107
65
  licenses:
108
66
  - MIT
109
67
  metadata: {}
@@ -127,48 +85,4 @@ rubygems_version: 2.4.8
127
85
  signing_key:
128
86
  specification_version: 4
129
87
  summary: RowsController DRYs your controllers.
130
- test_files:
131
- - test/fixtures/order/items.yml
132
- - test/fixtures/orders.yml
133
- - test/test_helper.rb
134
- - test/dummy/Rakefile
135
- - test/dummy/config.ru
136
- - test/dummy/tmp/restart.txt
137
- - test/dummy/db/development.sqlite3
138
- - test/dummy/db/schema.rb
139
- - test/dummy/db/migrate/002_create_order_items.rb
140
- - test/dummy/db/migrate/001_create_orders.rb
141
- - test/dummy/db/test.sqlite3
142
- - test/dummy/app/models/order/item.rb
143
- - test/dummy/app/models/order.rb
144
- - test/dummy/app/views/order/items/_form.html.erb
145
- - test/dummy/app/views/layouts/application.html.erb
146
- - test/dummy/app/views/orders/_form.html.erb
147
- - test/dummy/app/controllers/application_controller.rb
148
- - test/dummy/app/controllers/order/items_controller.rb
149
- - test/dummy/app/controllers/orders_controller.rb
150
- - test/dummy/bin/setup
151
- - test/dummy/bin/bundle
152
- - test/dummy/bin/rake
153
- - test/dummy/bin/rails
154
- - test/dummy/config/environment.rb
155
- - test/dummy/config/initializers/wrap_parameters.rb
156
- - test/dummy/config/initializers/cookies_serializer.rb
157
- - test/dummy/config/initializers/session_store.rb
158
- - test/dummy/config/initializers/filter_parameter_logging.rb
159
- - test/dummy/config/secrets.yml
160
- - test/dummy/config/application.rb
161
- - test/dummy/config/routes.rb
162
- - test/dummy/config/boot.rb
163
- - test/dummy/config/environments/development.rb
164
- - test/dummy/config/environments/production.rb
165
- - test/dummy/config/environments/test.rb
166
- - test/dummy/config/database.yml
167
- - test/controllers/orders_test.rb
168
- - test/controllers/orders_controller_test.rb
169
- - test/controllers/order/items_controller_test.rb
170
- - test/controllers/rows_controller_test.rb
171
- - test/controllers/rows_ext_controller_test.rb
172
- - Appraisals
173
- - ".watchr"
174
- - ".travis.yml"
88
+ test_files: []
data/.travis.yml DELETED
@@ -1,19 +0,0 @@
1
- language: ruby
2
- sudo: false
3
- rvm:
4
- # - 2.0.0 # OK for Rails 4.2.4
5
- # - 2.2.0
6
- - 2.2.3
7
-
8
- gemfile:
9
- - gemfiles/rails_4.2.4.gemfile
10
-
11
- matrix:
12
- include:
13
- # fails due to test/dummy/config/environments/test.rb
14
- # - rvm: 1.9.3 # or 2.0.0
15
- # gemfile: gemfiles/rails-3.2.16.gemfile
16
- exclude:
17
-
18
- notifications:
19
- email: false
data/.watchr DELETED
@@ -1,55 +0,0 @@
1
- HH = '#' * 22 unless defined?(HH)
2
- H = '#' * 5 unless defined?(H)
3
-
4
- def usage
5
- puts <<-EOS
6
- Ctrl-\\ or ctrl-4 Running all tests
7
- Ctrl-C Exit
8
- EOS
9
- end
10
-
11
- def run(cmd)
12
- puts "#{HH} #{Time.now} #{HH}"
13
- puts "#{H} #{cmd}"
14
- system "/usr/bin/time --format '#{HH} Elapsed time %E' #{cmd}"
15
- end
16
-
17
- def run_it(type, file)
18
- case type
19
- when 'test'; run %Q{ruby -I"lib:test" -rubygems #{file}}
20
- when 'spec'; run %Q{rspec -X #{file}}
21
- else; puts "#{H} unknown type: #{type}, file: #{file}"
22
- end
23
- end
24
-
25
- def run_all_tests
26
- puts "\n#{HH} Running all tests #{HH}\n"
27
- %w{test spec}.each { |dir| run "rake #{dir} RAILS_ENV=test" if File.exists?(dir) }
28
- end
29
-
30
- def run_matching_files(base)
31
- base = base.split('_').first
32
- %w{test spec}.each { |type|
33
- files = Dir["#{type}/**/*.rb"].select { |file| file =~ /#{base}_.*\.rb/ }
34
- run_it type, files.join(' ') unless files.empty?
35
- }
36
- end
37
-
38
- %w{test spec}.each { |type|
39
- watch("#{type}/#{type}_helper\.rb") { run_all_tests }
40
- watch("#{type}/.*/*_#{type}\.rb") { |match| run_it type, match[0] }
41
- }
42
- #%w{rb erb haml slim}.each { |type|
43
- # watch("app/.*/.*\.#{type}") { |m|
44
- # run_matching_files("#{m[0].split('/').at(2).split('.').first}")
45
- # }
46
- #}
47
- Dir['**/*.rb'].find_all{ |x| !(x =~ /_test\.rb$/) }.each { |name|
48
- watch(name) { run_all_tests }
49
- }
50
-
51
- # Ctrl-\ or ctrl-4
52
- Signal.trap('QUIT') { run_all_tests }
53
- # Ctrl-C
54
- Signal.trap('INT') { abort("Interrupted\n") }
55
- usage
data/Appraisals DELETED
@@ -1,7 +0,0 @@
1
- #appraise "rails-3.2" do
2
- # gem "rails", "3.2.16"
3
- #end
4
-
5
- appraise "rails-4.2.4" do
6
- gem "rails", "4.2.4"
7
- end
@@ -1,3 +0,0 @@
1
- module Rows
2
- VERSION = "2.0.3"
3
- end
@@ -1,53 +0,0 @@
1
- # mostly generated by Rails
2
-
3
- require 'test_helper'
4
-
5
- class Order::ItemsControllerTest < ActionController::TestCase
6
- setup do
7
- @order_item = order_items(:one)
8
- end
9
-
10
- test "should get index" do
11
- get :index
12
- assert_response :success
13
- assert_not_nil assigns(:order_items)
14
- end
15
-
16
- test "should get new" do
17
- get :new
18
- assert_response :success
19
- end
20
-
21
- test "should create order_item" do
22
- assert_difference('Order::Item.count') do
23
- post :create, order_item: { price: @order_item.price }
24
- end
25
-
26
- ## assert_redirected_to order_item_path(assigns(:order_item))
27
- assert_redirected_to edit_order_item_path(assigns(:order_item))
28
- end
29
-
30
- test "should show order_item" do
31
- get :show, id: @order_item
32
- assert_response :success
33
- end
34
-
35
- test "should get edit" do
36
- get :edit, id: @order_item
37
- assert_response :success
38
- end
39
-
40
- test "should update order_item" do
41
- patch :update, id: @order_item, order_item: { price: @order_item.price }
42
- ## assert_redirected_to order_item_path(assigns(:order_item))
43
- assert_redirected_to edit_order_item_path(assigns(:order_item))
44
- end
45
-
46
- test "should destroy order_item" do
47
- assert_difference('Order::Item.count', -1) do
48
- delete :destroy, id: @order_item
49
- end
50
-
51
- assert_redirected_to order_items_path
52
- end
53
- end
@@ -1,53 +0,0 @@
1
- # mostly generated by Rails
2
-
3
- require 'test_helper'
4
-
5
- class OrdersControllerTest < ActionController::TestCase
6
- setup do
7
- @order = orders(:one)
8
- end
9
-
10
- test "should get index" do
11
- get :index
12
- assert_response :success
13
- assert_not_nil assigns(:orders)
14
- end
15
-
16
- test "should get new" do
17
- get :new
18
- assert_response :success
19
- end
20
-
21
- test "should create order" do
22
- assert_difference('Order.count') do
23
- post :create, order: { name: @order.name }
24
- end
25
-
26
- ## assert_redirected_to order_path(assigns(:order))
27
- assert_redirected_to edit_order_path(assigns(:order))
28
- end
29
-
30
- test "should show order" do
31
- get :show, id: @order
32
- assert_response :success
33
- end
34
-
35
- test "should get edit" do
36
- get :edit, id: @order
37
- assert_response :success
38
- end
39
-
40
- test "should update order" do
41
- patch :update, id: @order, order: { name: @order.name }
42
- ## assert_redirected_to order_path(assigns(:order))
43
- assert_redirected_to edit_order_path(assigns(:order))
44
- end
45
-
46
- test "should destroy order" do
47
- assert_difference('Order.count', -1) do
48
- delete :destroy, id: @order
49
- end
50
-
51
- assert_redirected_to orders_path
52
- end
53
- end
@@ -1,93 +0,0 @@
1
- require 'test_helper'
2
-
3
- class OrdersControllerTest < ActionController::TestCase
4
-
5
- setup do
6
- @order = orders(:one)
7
- end
8
-
9
- %i{ index new }.each do |action|
10
- test "renders the '#{action}' template" do
11
- get action
12
- assert_response :success
13
- assert_template "rows/#{action}"
14
- assert_match /Order/, response.body
15
- end
16
- end
17
-
18
- %i{ edit show }.each do |action|
19
- test "renders the '#{action}' template" do
20
- get action, id: @order.id
21
- assert_response :success
22
- assert_template "rows/#{action}"
23
- assert_match /Order/, response.body
24
- end
25
- end
26
-
27
- test 'checking resource' do
28
- get :show, id: @order.id
29
- assert_equal @order, @controller.send(:resource)
30
- assert_equal @order, assigns(:order)
31
- assert_equal @order, assigns(:row)
32
- end
33
-
34
- test 'checking resources' do
35
- get :index
36
- assert_kind_of Array, @controller.send(:resources).to_a
37
- assert_kind_of Array, assigns(:orders).to_a
38
- assert_kind_of Array, assigns(:rows).to_a
39
- assert_equal Order.all, assigns(:orders)
40
- end
41
-
42
- test 'checking model_class' do
43
- get :show, id: @order.id
44
- assert_equal Order, @controller.send(:model_class)
45
- assert_equal 'Order', @controller.send(:model_name)
46
- assert_equal 'order', @controller.send(:model_symbol)
47
- assert_equal 'orders', @controller.send(:model_symbol_plural)
48
- end
49
-
50
- test "should create order #2" do
51
- assert_difference('Order.count') do
52
- post :create, commit: 'OK', order: { name: @order.name }
53
- end
54
- end
55
-
56
- test 'should update' do
57
- put :update, { id: @order.id, order: {name: 'name'} }
58
- assert response
59
- assert_redirected_to(action: :edit)
60
- end
61
-
62
- test 'should update #2' do
63
- put :update, { id: @order.id, commit: 'OK', order: {name: 'name'} }
64
- assert response
65
- assert_redirected_to(action: :index)
66
- end
67
-
68
- test 'should not update' do
69
- put :update, { id: @order.id, order: {name: 'error'} }
70
- assert_response :success
71
- assert_template 'rows/edit'
72
- end
73
-
74
- test 'should not create' do
75
- post :create, { id: @order.id, order: {name: 'error'} }
76
- assert_response :success
77
- assert_template 'rows/new'
78
- end
79
-
80
- end
81
-
82
-
83
- class Order::ItemsControllerTest < ActionController::TestCase
84
-
85
- test 'checking model_...' do
86
- get :index
87
- assert_equal Order::Item, @controller.send(:model_class)
88
- assert_equal 'Order::Item', @controller.send(:model_name)
89
- assert_equal 'order_item', @controller.send(:model_symbol)
90
- assert_equal 'order_items', @controller.send(:model_symbol_plural)
91
- end
92
-
93
- end
@@ -1,52 +0,0 @@
1
- require 'test_helper'
2
-
3
- class RowsControllerTest < ActionController::TestCase
4
- test 'respond resource' do
5
- test_response %i{ resource resources set_resource set_resources }
6
- end
7
-
8
- test 'respond model' do
9
- test_response %i{ model_class }
10
- end
11
-
12
- test 'respond resource format' do
13
- test_response %i{ resource_format }
14
- end
15
-
16
-
17
- test 'respond action' do
18
- test_response %i{ index new create show edit update destroy }
19
- end
20
-
21
- test 'coverage resource_format' do
22
- assert_equal 'abc', @controller.send(:resource_format, 'abc')
23
- end
24
-
25
- test 'available public methods' do
26
- list = %i{create destroy edit index new show update}
27
- assert_equal list.sort, @controller.public_methods(false).sort
28
- end
29
-
30
- test 'exposed resource private methods' do
31
- list = %i{resource resource_format resources set_resource set_resources}
32
- assert_equal list.sort, filter(@controller.public_methods, 'resource')
33
- end
34
-
35
- test 'exposed model_ private methods' do
36
- list = %i{model_class model_name model_symbol model_symbol_plural
37
- model_name_from_record_or_class}
38
- assert_equal list.sort, filter(@controller.public_methods, 'model_')
39
- end
40
-
41
- private
42
- def filter(x, criteria)
43
- x.map(&:to_s).sort.find_all { |x| x =~ /#{criteria}/ }.map(&:to_sym).sort
44
- end
45
-
46
- def test_response(list)
47
- list.each { |x|
48
- assert @controller.respond_to?(x), "controller don't respond to #{x}"
49
- }
50
- end
51
-
52
- end
@@ -1,22 +0,0 @@
1
- require 'test_helper'
2
-
3
- class OrdersControllerTest < ActionController::TestCase
4
-
5
- test 'respond to :copy' do
6
- assert @controller.respond_to?(:copy)
7
- order = Order.create :name => 'name'
8
- n = Order.all.length
9
-
10
- put :copy, id: order.id
11
- assert_response :success
12
- assert_template 'rows/new'
13
- assert_match /New Order/, response.body
14
- end
15
-
16
- test 'coverage: multi deletion' do
17
- delete :multi_deletion
18
- assert response
19
- assert_redirected_to orders_url
20
- end
21
-
22
- end
data/test/dummy/Rakefile DELETED
@@ -1,6 +0,0 @@
1
- # Add your own tasks in files placed in lib/tasks ending in .rake,
2
- # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake.
3
-
4
- require File.expand_path('../config/application', __FILE__)
5
-
6
- Rails.application.load_tasks
@@ -1,5 +0,0 @@
1
- class ApplicationController < ActionController::Base
2
- # Prevent CSRF attacks by raising an exception.
3
- # For APIs, you may want to use :null_session instead.
4
- protect_from_forgery with: :exception
5
- end
@@ -1,8 +0,0 @@
1
- class Order::ItemsController < RowsController
2
-
3
- private
4
- def resource_whitelist
5
- %i{ name }
6
- end
7
-
8
- end
@@ -1,8 +0,0 @@
1
- class OrdersController < RowsExtController
2
-
3
- private
4
- def resource_whitelist
5
- %i{ name }
6
- end
7
-
8
- end
@@ -1,11 +0,0 @@
1
- class Order < ActiveRecord::Base
2
-
3
- before_save :huhu
4
- def huhu
5
- return true unless name == 'error'
6
-
7
- self.errors.add :base, 'panic'
8
- return false
9
- end
10
-
11
- end
@@ -1,2 +0,0 @@
1
- class Order::Item < ActiveRecord::Base
2
- end
@@ -1,12 +0,0 @@
1
- <!DOCTYPE html>
2
- <html>
3
- <head>
4
- <title>Dummy</title>
5
- <%= csrf_meta_tags %>
6
- </head>
7
- <body>
8
-
9
- <%= yield %>
10
-
11
- </body>
12
- </html>
@@ -1,8 +0,0 @@
1
- <%
2
- # This is a typical form
3
- # Requires f
4
- %>
5
- <div class="field">
6
- <%= f.label :price %><br />
7
- <%= f.text_field :price %>
8
- </div>
@@ -1,8 +0,0 @@
1
- <%
2
- # This is a typical form
3
- # Requires f
4
- %>
5
- <div class="field">
6
- <%= f.label :name %><br />
7
- <%= f.text_field :name %>
8
- </div>
@@ -1,3 +0,0 @@
1
- #!/usr/bin/env ruby
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__)
3
- load Gem.bin_path('bundler', 'bundle')
data/test/dummy/bin/rails DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- APP_PATH = File.expand_path('../../config/application', __FILE__)
3
- require_relative '../config/boot'
4
- require 'rails/commands'
data/test/dummy/bin/rake DELETED
@@ -1,4 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require_relative '../config/boot'
3
- require 'rake'
4
- Rake.application.run
data/test/dummy/bin/setup DELETED
@@ -1,29 +0,0 @@
1
- #!/usr/bin/env ruby
2
- require 'pathname'
3
-
4
- # path to your application root.
5
- APP_ROOT = Pathname.new File.expand_path('../../', __FILE__)
6
-
7
- Dir.chdir APP_ROOT do
8
- # This script is a starting point to setup your application.
9
- # Add necessary setup steps to this file:
10
-
11
- puts "== Installing dependencies =="
12
- system "gem install bundler --conservative"
13
- system "bundle check || bundle install"
14
-
15
- # puts "\n== Copying sample files =="
16
- # unless File.exist?("config/database.yml")
17
- # system "cp config/database.yml.sample config/database.yml"
18
- # end
19
-
20
- puts "\n== Preparing database =="
21
- system "bin/rake db:setup"
22
-
23
- puts "\n== Removing old logs and tempfiles =="
24
- system "rm -f log/*"
25
- system "rm -rf tmp/cache"
26
-
27
- #puts "\n== Restarting application server =="
28
- #system "touch tmp/restart.txt"
29
- end
data/test/dummy/config.ru DELETED
@@ -1,4 +0,0 @@
1
- # This file is used by Rack-based servers to start the application.
2
-
3
- require ::File.expand_path('../config/environment', __FILE__)
4
- run Rails.application
@@ -1,26 +0,0 @@
1
- require File.expand_path('../boot', __FILE__)
2
-
3
- require 'rails/all'
4
-
5
- Bundler.require(*Rails.groups)
6
- require "rows_controller"
7
-
8
- module Dummy
9
- class Application < Rails::Application
10
- # Settings in config/environments/* take precedence over those specified here.
11
- # Application configuration should go into files in config/initializers
12
- # -- all .rb files in that directory are automatically loaded.
13
-
14
- # Set Time.zone default to the specified zone and make Active Record auto-convert to this zone.
15
- # Run "rake -D time" for a list of tasks for finding time zone names. Default is UTC.
16
- # config.time_zone = 'Central Time (US & Canada)'
17
-
18
- # The default locale is :en and all translations from config/locales/*.rb,yml are auto loaded.
19
- # config.i18n.load_path += Dir[Rails.root.join('my', 'locales', '*.{rb,yml}').to_s]
20
- # config.i18n.default_locale = :de
21
-
22
- # Do not swallow errors in after_commit/after_rollback callbacks.
23
- config.active_record.raise_in_transactional_callbacks = true
24
- end
25
- end
26
-
@@ -1,5 +0,0 @@
1
- # Set up gems listed in the Gemfile.
2
- ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../../../Gemfile', __FILE__)
3
-
4
- require 'bundler/setup' if File.exist?(ENV['BUNDLE_GEMFILE'])
5
- $LOAD_PATH.unshift File.expand_path('../../../../lib', __FILE__)
@@ -1,25 +0,0 @@
1
- # SQLite version 3.x
2
- # gem install sqlite3
3
- #
4
- # Ensure the SQLite 3 gem is defined in your Gemfile
5
- # gem 'sqlite3'
6
- #
7
- default: &default
8
- adapter: sqlite3
9
- pool: 5
10
- timeout: 5000
11
-
12
- development:
13
- <<: *default
14
- database: db/development.sqlite3
15
-
16
- # Warning: The database defined as "test" will be erased and
17
- # re-generated from your development database when you run "rake".
18
- # Do not set this db to the same as development or production.
19
- test:
20
- <<: *default
21
- database: db/test.sqlite3
22
-
23
- production:
24
- <<: *default
25
- database: db/production.sqlite3
@@ -1,5 +0,0 @@
1
- # Load the Rails application.
2
- require File.expand_path('../application', __FILE__)
3
-
4
- # Initialize the Rails application.
5
- Rails.application.initialize!
@@ -1,41 +0,0 @@
1
- Rails.application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb.
3
-
4
- # In the development environment your application's code is reloaded on
5
- # every request. This slows down response time but is perfect for development
6
- # since you don't have to restart the web server when you make code changes.
7
- config.cache_classes = false
8
-
9
- # Do not eager load code on boot.
10
- config.eager_load = false
11
-
12
- # Show full error reports and disable caching.
13
- config.consider_all_requests_local = true
14
- config.action_controller.perform_caching = false
15
-
16
- # Don't care if the mailer can't send.
17
- config.action_mailer.raise_delivery_errors = false
18
-
19
- # Print deprecation notices to the Rails logger.
20
- config.active_support.deprecation = :log
21
-
22
- # Raise an error on page load if there are pending migrations.
23
- config.active_record.migration_error = :page_load
24
-
25
- # Debug mode disables concatenation and preprocessing of assets.
26
- # This option may cause significant delays in view rendering with a large
27
- # number of complex assets.
28
- config.assets.debug = true
29
-
30
- # Asset digests allow you to set far-future HTTP expiration dates on all assets,
31
- # yet still be able to expire them through the digest params.
32
- config.assets.digest = true
33
-
34
- # Adds additional error checking when serving assets at runtime.
35
- # Checks for improperly declared sprockets dependencies.
36
- # Raises helpful error messages.
37
- config.assets.raise_runtime_errors = true
38
-
39
- # Raises error for missing translations
40
- # config.action_view.raise_on_missing_translations = true
41
- end
@@ -1,79 +0,0 @@
1
- Rails.application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb.
3
-
4
- # Code is not reloaded between requests.
5
- config.cache_classes = true
6
-
7
- # Eager load code on boot. This eager loads most of Rails and
8
- # your application in memory, allowing both threaded web servers
9
- # and those relying on copy on write to perform better.
10
- # Rake tasks automatically ignore this option for performance.
11
- config.eager_load = true
12
-
13
- # Full error reports are disabled and caching is turned on.
14
- config.consider_all_requests_local = false
15
- config.action_controller.perform_caching = true
16
-
17
- # Enable Rack::Cache to put a simple HTTP cache in front of your application
18
- # Add `rack-cache` to your Gemfile before enabling this.
19
- # For large-scale production use, consider using a caching reverse proxy like
20
- # NGINX, varnish or squid.
21
- # config.action_dispatch.rack_cache = true
22
-
23
- # Disable serving static files from the `/public` folder by default since
24
- # Apache or NGINX already handles this.
25
- config.serve_static_files = ENV['RAILS_SERVE_STATIC_FILES'].present?
26
-
27
- # Compress JavaScripts and CSS.
28
- config.assets.js_compressor = :uglifier
29
- # config.assets.css_compressor = :sass
30
-
31
- # Do not fallback to assets pipeline if a precompiled asset is missed.
32
- config.assets.compile = false
33
-
34
- # Asset digests allow you to set far-future HTTP expiration dates on all assets,
35
- # yet still be able to expire them through the digest params.
36
- config.assets.digest = true
37
-
38
- # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb
39
-
40
- # Specifies the header that your server uses for sending files.
41
- # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
42
- # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
43
-
44
- # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
45
- # config.force_ssl = true
46
-
47
- # Use the lowest log level to ensure availability of diagnostic information
48
- # when problems arise.
49
- config.log_level = :debug
50
-
51
- # Prepend all log lines with the following tags.
52
- # config.log_tags = [ :subdomain, :uuid ]
53
-
54
- # Use a different logger for distributed setups.
55
- # config.logger = ActiveSupport::TaggedLogging.new(SyslogLogger.new)
56
-
57
- # Use a different cache store in production.
58
- # config.cache_store = :mem_cache_store
59
-
60
- # Enable serving of images, stylesheets, and JavaScripts from an asset server.
61
- # config.action_controller.asset_host = 'http://assets.example.com'
62
-
63
- # Ignore bad email addresses and do not raise email delivery errors.
64
- # Set this to true and configure the email server for immediate delivery to raise delivery errors.
65
- # config.action_mailer.raise_delivery_errors = false
66
-
67
- # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
68
- # the I18n.default_locale when a translation cannot be found).
69
- config.i18n.fallbacks = true
70
-
71
- # Send deprecation notices to registered listeners.
72
- config.active_support.deprecation = :notify
73
-
74
- # Use default logging formatter so that PID and timestamp are not suppressed.
75
- config.log_formatter = ::Logger::Formatter.new
76
-
77
- # Do not dump schema after migrations.
78
- config.active_record.dump_schema_after_migration = false
79
- end
@@ -1,42 +0,0 @@
1
- Rails.application.configure do
2
- # Settings specified here will take precedence over those in config/application.rb.
3
-
4
- # The test environment is used exclusively to run your application's
5
- # test suite. You never need to work with it otherwise. Remember that
6
- # your test database is "scratch space" for the test suite and is wiped
7
- # and recreated between test runs. Don't rely on the data there!
8
- config.cache_classes = true
9
-
10
- # Do not eager load code on boot. This avoids loading your whole application
11
- # just for the purpose of running a single test. If you are using a tool that
12
- # preloads Rails for running tests, you may have to set it to true.
13
- config.eager_load = false
14
-
15
- # Configure static file server for tests with Cache-Control for performance.
16
- config.serve_static_files = true
17
- config.static_cache_control = 'public, max-age=3600'
18
-
19
- # Show full error reports and disable caching.
20
- config.consider_all_requests_local = true
21
- config.action_controller.perform_caching = false
22
-
23
- # Raise exceptions instead of rendering exception templates.
24
- config.action_dispatch.show_exceptions = false
25
-
26
- # Disable request forgery protection in test environment.
27
- config.action_controller.allow_forgery_protection = false
28
-
29
- # Tell Action Mailer not to deliver emails to the real world.
30
- # The :test delivery method accumulates sent emails in the
31
- # ActionMailer::Base.deliveries array.
32
- config.action_mailer.delivery_method = :test
33
-
34
- # Randomize the order test cases are executed.
35
- config.active_support.test_order = :random
36
-
37
- # Print deprecation notices to the stderr.
38
- config.active_support.deprecation = :stderr
39
-
40
- # Raises error for missing translations
41
- # config.action_view.raise_on_missing_translations = true
42
- end
@@ -1,3 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- Rails.application.config.action_dispatch.cookies_serializer = :json
@@ -1,4 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Configure sensitive parameters which will be filtered from the log file.
4
- Rails.application.config.filter_parameters += [:password]
@@ -1,3 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- Rails.application.config.session_store :cookie_store, key: '_dummy_session'
@@ -1,14 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # This file contains settings for ActionController::ParamsWrapper which
4
- # is enabled by default.
5
-
6
- # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array.
7
- ActiveSupport.on_load(:action_controller) do
8
- wrap_parameters format: [:json] if respond_to?(:wrap_parameters)
9
- end
10
-
11
- # To enable root element in JSON for ActiveRecord objects.
12
- # ActiveSupport.on_load(:active_record) do
13
- # self.include_root_in_json = true
14
- # end
@@ -1,9 +0,0 @@
1
- Rails.application.routes.draw do
2
- resources :orders
3
- namespace :order do
4
- resources :items
5
- end
6
-
7
- put '/rows_ext/:id/copy', to: 'orders#copy'
8
- delete '/rows_ext/multi_deletion', to: 'orders#multi_deletion'
9
- end
@@ -1,22 +0,0 @@
1
- # Be sure to restart your server when you modify this file.
2
-
3
- # Your secret key is used for verifying the integrity of signed cookies.
4
- # If you change this key, all old signed cookies will become invalid!
5
-
6
- # Make sure the secret is at least 30 characters and all random,
7
- # no regular words or you'll be exposed to dictionary attacks.
8
- # You can use `rake secret` to generate a secure secret key.
9
-
10
- # Make sure the secrets in this file are kept private
11
- # if you're sharing your code publicly.
12
-
13
- development:
14
- secret_key_base: 1bbbda65cfaef631237017a4cb880b529b7e0de4e0ff541bbf6bcf85d70ab4ec5d1925fbf426423a29e8e50b71ce196f0fb65c4ee6bbbd6ded999a3ddf922fd9
15
-
16
- test:
17
- secret_key_base: cf224a954c393736fe6b57f436e5873d034dda3f7dd4d08d5178b09285ac0eea7c459ab323610575232260f56b17a2dea4711e6cafbbe75df4e8ce3e762fed38
18
-
19
- # Do not keep production secrets in the repository,
20
- # instead read values from the environment.
21
- production:
22
- secret_key_base: <%= ENV["SECRET_KEY_BASE"] %>
Binary file
@@ -1,9 +0,0 @@
1
- class CreateOrders < ActiveRecord::Migration
2
- def change
3
- create_table :orders do |t|
4
- t.string :name
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,9 +0,0 @@
1
- class CreateOrderItems < ActiveRecord::Migration
2
- def change
3
- create_table :order_items do |t|
4
- t.string :price
5
-
6
- t.timestamps
7
- end
8
- end
9
- end
@@ -1,28 +0,0 @@
1
- # encoding: UTF-8
2
- # This file is auto-generated from the current state of the database. Instead
3
- # of editing this file, please use the migrations feature of Active Record to
4
- # incrementally modify your database, and then regenerate this schema definition.
5
- #
6
- # Note that this schema.rb definition is the authoritative source for your
7
- # database schema. If you need to create the application database on another
8
- # system, you should be using db:schema:load, not running all the migrations
9
- # from scratch. The latter is a flawed and unsustainable approach (the more migrations
10
- # you'll amass, the slower it'll run and the greater likelihood for issues).
11
- #
12
- # It's strongly recommended that you check this file into your version control system.
13
-
14
- ActiveRecord::Schema.define(version: 20151018122938) do
15
-
16
- create_table "order_items", force: :cascade do |t|
17
- t.string "price"
18
- t.datetime "created_at"
19
- t.datetime "updated_at"
20
- end
21
-
22
- create_table "orders", force: :cascade do |t|
23
- t.string "name"
24
- t.datetime "created_at"
25
- t.datetime "updated_at"
26
- end
27
-
28
- end
Binary file
File without changes
@@ -1,5 +0,0 @@
1
- one:
2
- price: MyString
3
-
4
- two:
5
- price: MyString
@@ -1,5 +0,0 @@
1
- one:
2
- name: MyString
3
-
4
- two:
5
- name: MyString
data/test/test_helper.rb DELETED
@@ -1,27 +0,0 @@
1
- #require 'simplecov'
2
- #SimpleCov.start do
3
- # add_filter 'test'
4
- # command_name 'Minitest'
5
- #end
6
-
7
-
8
- # Configure Rails Environment
9
- ENV["RAILS_ENV"] = "test"
10
-
11
- require File.expand_path("../../test/dummy/config/environment.rb", __FILE__)
12
- ActiveRecord::Migrator.migrations_paths = [File.expand_path("../../test/dummy/db/migrate", __FILE__)]
13
- require "rails/test_help"
14
-
15
- # Filter out Minitest backtrace while allowing backtrace from other libraries
16
- # to be shown.
17
- Minitest.backtrace_filter = Minitest::BacktraceFilter.new
18
-
19
- # Load support files
20
- ##Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
21
-
22
- # Load fixtures from the engine
23
- if ActiveSupport::TestCase.respond_to?(:fixture_path=)
24
- ActiveSupport::TestCase.fixture_path = File.expand_path("../fixtures", __FILE__)
25
- ActionDispatch::IntegrationTest.fixture_path = ActiveSupport::TestCase.fixture_path
26
- ActiveSupport::TestCase.fixtures :all
27
- end