rows_controller 0.4.4 → 1.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (49) hide show
  1. checksums.yaml +7 -0
  2. data/.watchr +39 -43
  3. data/Gemfile +5 -2
  4. data/Gemfile.lock +72 -77
  5. data/MIT-LICENSE +1 -1
  6. data/README.md +20 -4
  7. data/app/controllers/rows_controller.rb +68 -53
  8. data/app/controllers/rows_controller/helpers.rb +68 -40
  9. data/app/controllers/rows_ext_controller.rb +18 -0
  10. data/app/views/rows/_form.slim +2 -0
  11. data/app/views/rows/_list.slim +18 -0
  12. data/app/views/rows/_list_footer.slim +5 -0
  13. data/app/views/rows/_list_header.slim +7 -0
  14. data/app/views/rows/_list_row.slim +10 -0
  15. data/app/views/rows/_row_buttons.slim +14 -0
  16. data/app/views/rows/_submit.slim +19 -0
  17. data/app/views/rows/_submit_part.slim +4 -0
  18. data/app/views/rows/edit.slim +17 -0
  19. data/app/views/rows/index.slim +10 -0
  20. data/app/views/rows/new.slim +16 -0
  21. data/app/views/rows/show.slim +17 -0
  22. data/app/views/shared/_error_explanation.slim +10 -0
  23. data/app/views/shared/_show_flash.slim +9 -0
  24. data/lib/rows_controller.rb +1 -0
  25. data/lib/rows_controller/locales/de.yml +23 -0
  26. data/lib/rows_controller/locales/en.yml +16 -27
  27. data/lib/rows_controller/version.rb +1 -1
  28. data/spec/controllers/orders_spec.rb +28 -3
  29. data/spec/controllers/rows_ext_spec.rb +6 -0
  30. data/spec/controllers/rows_spec.rb +5 -0
  31. data/spec/dummy/app/controllers/orders_controller.rb +11 -2
  32. data/spec/dummy/app/models/order.rb +5 -4
  33. data/spec/dummy/app/views/layouts/application.html.erb +1 -1
  34. data/spec/dummy/db/schema.rb +2 -2
  35. data/spec/{integration → features}/order_spec.rb +12 -3
  36. data/spec/spec_helper.rb +19 -52
  37. metadata +31 -34
  38. data/.rvmrc +0 -4
  39. data/app/views/rows/_form.html.erb +0 -3
  40. data/app/views/rows/_list.html.erb +0 -30
  41. data/app/views/rows/_submit.html.erb +0 -22
  42. data/app/views/rows/_submit_part.html.erb +0 -4
  43. data/app/views/rows/edit.html.erb +0 -22
  44. data/app/views/rows/index.html.erb +0 -17
  45. data/app/views/rows/new.html.erb +0 -22
  46. data/app/views/rows/show.html.erb +0 -24
  47. data/app/views/shared/_error_explanation.html.erb +0 -14
  48. data/app/views/shared/_flash.html.erb +0 -9
  49. data/spec/support/describe_private.rb +0 -14
@@ -0,0 +1,6 @@
1
+ require 'spec_helper'
2
+
3
+ describe RowsExtController do
4
+ specify { should respond_to(:copy) }
5
+ # specify { should respond_to(:multi_deletion) }
6
+ end
@@ -16,4 +16,9 @@ describe RowsController do
16
16
  specify { should respond_to(:create) }
17
17
  specify { should respond_to(:update) }
18
18
  specify { should respond_to(:destroy) }
19
+
20
+ it 'coverage resource_format' do
21
+ subject.send(:resource_format, 'abc').should == 'abc'
22
+ end
23
+
19
24
  end
@@ -1,3 +1,12 @@
1
- class OrdersController < RowsController
2
- ## messages missing
1
+ class OrdersController < RowsExtController
2
+
3
+ private
4
+ def resource_whitelist
5
+ %w{name qty}
6
+ end
7
+
8
+ def resource_columns
9
+ [:multi_selection] + super
10
+ end
11
+
3
12
  end
@@ -1,10 +1,11 @@
1
1
  class Order < ActiveRecord::Base
2
2
 
3
- before_save do |row|
4
- return true unless row.name == 'error'
3
+ before_save :before_save_x
4
+ def before_save_x
5
+ return true unless name == 'error'
5
6
 
6
- row.errors.add :base, 'panic'
7
- return false
7
+ self.errors.add :base, 'panic'
8
+ return false
8
9
  end
9
10
 
10
11
  end
@@ -7,7 +7,7 @@
7
7
  <%= csrf_meta_tags %>
8
8
  </head>
9
9
  <body>
10
- <%= render '/shared/flash' %>
10
+ <%= render '/shared/show_flash' %>
11
11
  <%= yield %>
12
12
  </body>
13
13
  </html>
@@ -16,8 +16,8 @@ ActiveRecord::Schema.define(:version => 1) do
16
16
  create_table "orders", :force => true do |t|
17
17
  t.string "name"
18
18
  t.string "qty"
19
- t.datetime "created_at"
20
- t.datetime "updated_at"
19
+ t.datetime "created_at", :null => false
20
+ t.datetime "updated_at", :null => false
21
21
  end
22
22
 
23
23
  end
@@ -13,7 +13,7 @@ describe "Order" do
13
13
  fill_in "Name", :with => "a name"
14
14
  click_button "Create"
15
15
  page.should have_content("Order created.")
16
- page.should have_content("Edit Order")
16
+ page.should have_content("Editing Order")
17
17
 
18
18
  Order.all.first.name.should == "a name"
19
19
  end
@@ -29,17 +29,26 @@ describe "Order" do
29
29
  Order.all.length.should == (n - 1)
30
30
  end
31
31
 
32
+ it 'index should have check_box for multi_selection' do
33
+ Order.create :name => 'name', :qty => 123
34
+ visit "/orders"
35
+ page.should have_css('table tr input[name="multi_selection[]"]')
36
+ end
37
+
32
38
  it 'should be copied' do
33
- order = Order.create :name => 'name', :qty => '123'
39
+ Order.create :name => 'name', :qty => 123
40
+ order = Order.all.first
34
41
  n = Order.all.length
35
42
  visit "/orders/#{order.id}/copy"
43
+
36
44
  page.should have_content("New")
37
45
  fill_in "Name", :with => "a name"
38
- click_button "Create"
46
+ click_button "OK"
39
47
 
40
48
  Order.all.length.should == (n + 1)
41
49
  order2 = Order.find(order.id + 1)
42
50
  order2.name.should_not == order.name
43
51
  order2.qty.should == order.qty
44
52
  end
53
+
45
54
  end
data/spec/spec_helper.rb CHANGED
@@ -1,63 +1,30 @@
1
- require 'rubygems'
1
+ require 'simplecov'
2
+ SimpleCov.start "rails" do
3
+ # add_filter '/application_controller.rb/'
4
+ end
5
+
2
6
  require 'spork'
7
+ require 'bundler'
8
+ Bundler.setup :default, :development, :test
3
9
 
4
10
  Spork.prefork do
5
- # Loading more in this block will cause your tests to run faster. However,
6
- # if you change any configuration or code from libraries loaded here, you'll
7
- # need to restart spork for it take effect.
8
-
9
- ENV["RAILS_ENV"] = "test"
10
-
11
- require File.expand_path("../dummy/config/environment.rb", __FILE__)
12
- require "rails/test_help"
13
- require "rspec/rails"
14
-
15
- # ActionMailer::Base.delivery_method = :test
16
- # ActionMailer::Base.perform_deliveries = true
17
- # ActionMailer::Base.default_url_options[:host] = "test.com"
18
-
19
- Rails.backtrace_cleaner.remove_silencers!
20
-
21
- # Configure capybara for integration testing
22
- require "capybara/rails"
23
- Capybara.default_driver = :rack_test
24
- Capybara.default_selector = :css
25
-
26
- # Run any available migration
27
- ActiveRecord::Migrator.migrate File.expand_path("../dummy/db/migrate/", __FILE__)
28
-
29
- # Load support files
30
- Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
11
+ ENV["RAILS_ENV"] ||= 'test'
12
+ # require File.expand_path("../../config/environment", __FILE__)
13
+ require File.expand_path("../../spec/dummy/config/environment", __FILE__)
14
+ require 'rspec/rails'
31
15
 
32
16
  RSpec.configure do |config|
33
- # Remove this line if you don't want RSpec's should and should_not
34
- # methods or matchers
35
- require 'rspec/expectations'
36
- config.include RSpec::Matchers
37
-
38
- # == Mock Framework
39
17
  config.mock_with :rspec
18
+ config.fixture_path = "#{::Rails.root}/spec/fixtures"
19
+ # config.use_transactional_fixtures = false
20
+ # increases speed; not sure why
21
+ config.use_transactional_fixtures = true
22
+
23
+ ActiveSupport::Dependencies.clear
40
24
  end
41
25
  end
42
26
 
43
-
44
27
  Spork.each_run do
45
- # This code will be run each time you run your specs.
46
- Dir["#{File.dirname(__FILE__)}/../lib/controllers/*.rb"].each { |f| load f }
47
-
48
- unless ENV['COVERAGE'].nil?
49
- require 'simplecov'
50
- SimpleCov.start 'rails' do
51
- coverage_dir 'coverage'
52
- end
53
- end
28
+ load "#{Rails.root}/config/routes.rb"
29
+ Dir["#{Rails.root}/app/**/*.rb"].each { |f| load f }
54
30
  end
55
-
56
-
57
- # --- Instructions ---
58
- # - Sort through your spec_helper file. Place as much environment loading
59
- # code that you don't normally modify during development in the
60
- # Spork.prefork block.
61
- # - Place the rest under Spork.each_run block
62
- # - Any code that is left outside of the blocks will be ran during preforking
63
- # and during each_run!
metadata CHANGED
@@ -1,62 +1,55 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rows_controller
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.4.4
5
- prerelease:
4
+ version: 1.0.1
6
5
  platform: ruby
7
6
  authors:
8
7
  - Dittmar Krall
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2012-07-29 00:00:00.000000000 Z
11
+ date: 2013-06-20 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: sqlite3
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - '>='
20
18
  - !ruby/object:Gem::Version
21
19
  version: '0'
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - '>='
28
25
  - !ruby/object:Gem::Version
29
26
  version: '0'
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec-rails
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - '>='
36
32
  - !ruby/object:Gem::Version
37
33
  version: '0'
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - '>='
44
39
  - !ruby/object:Gem::Version
45
40
  version: '0'
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: capybara
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ! '>='
45
+ - - '>='
52
46
  - !ruby/object:Gem::Version
53
47
  version: '0'
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ! '>='
52
+ - - '>='
60
53
  - !ruby/object:Gem::Version
61
54
  version: '0'
62
55
  description: YourController < RowsController ( < ApplicationController).
@@ -67,7 +60,6 @@ extensions: []
67
60
  extra_rdoc_files: []
68
61
  files:
69
62
  - .rspec
70
- - .rvmrc
71
63
  - .watchr
72
64
  - Gemfile
73
65
  - Gemfile.lock
@@ -76,23 +68,30 @@ files:
76
68
  - Rakefile
77
69
  - app/controllers/rows_controller.rb
78
70
  - app/controllers/rows_controller/helpers.rb
79
- - app/views/rows/_form.html.erb
80
- - app/views/rows/_list.html.erb
81
- - app/views/rows/_submit.html.erb
82
- - app/views/rows/_submit_part.html.erb
71
+ - app/controllers/rows_ext_controller.rb
72
+ - app/views/rows/_form.slim
73
+ - app/views/rows/_list.slim
74
+ - app/views/rows/_list_footer.slim
75
+ - app/views/rows/_list_header.slim
76
+ - app/views/rows/_list_row.slim
77
+ - app/views/rows/_row_buttons.slim
78
+ - app/views/rows/_submit.slim
79
+ - app/views/rows/_submit_part.slim
83
80
  - app/views/rows/destroy.js.erb
84
- - app/views/rows/edit.html.erb
85
- - app/views/rows/index.html.erb
86
- - app/views/rows/new.html.erb
87
- - app/views/rows/show.html.erb
88
- - app/views/shared/_error_explanation.html.erb
89
- - app/views/shared/_flash.html.erb
81
+ - app/views/rows/edit.slim
82
+ - app/views/rows/index.slim
83
+ - app/views/rows/new.slim
84
+ - app/views/rows/show.slim
85
+ - app/views/shared/_error_explanation.slim
86
+ - app/views/shared/_show_flash.slim
90
87
  - lib/rows_controller.rb
91
88
  - lib/rows_controller/engine.rb
89
+ - lib/rows_controller/locales/de.yml
92
90
  - lib/rows_controller/locales/en.yml
93
91
  - lib/rows_controller/version.rb
94
92
  - rows_controller.gemspec
95
93
  - spec/controllers/orders_spec.rb
94
+ - spec/controllers/rows_ext_spec.rb
96
95
  - spec/controllers/rows_spec.rb
97
96
  - spec/dummy/Rakefile
98
97
  - spec/dummy/app/assets/javascripts/application.js
@@ -117,32 +116,30 @@ files:
117
116
  - spec/dummy/db/seeds.rb
118
117
  - spec/dummy/public/favicon.ico
119
118
  - spec/dummy/script/rails
120
- - spec/integration/order_spec.rb
119
+ - spec/features/order_spec.rb
121
120
  - spec/models/order_spec.rb
122
121
  - spec/spec_helper.rb
123
- - spec/support/describe_private.rb
124
122
  homepage: http://matique.de
125
123
  licenses: []
124
+ metadata: {}
126
125
  post_install_message:
127
126
  rdoc_options: []
128
127
  require_paths:
129
128
  - lib
130
129
  required_ruby_version: !ruby/object:Gem::Requirement
131
- none: false
132
130
  requirements:
133
- - - ! '>='
131
+ - - '>='
134
132
  - !ruby/object:Gem::Version
135
133
  version: '0'
136
134
  required_rubygems_version: !ruby/object:Gem::Requirement
137
- none: false
138
135
  requirements:
139
- - - ! '>='
136
+ - - '>='
140
137
  - !ruby/object:Gem::Version
141
138
  version: '0'
142
139
  requirements: []
143
140
  rubyforge_project:
144
- rubygems_version: 1.8.24
141
+ rubygems_version: 2.0.3
145
142
  signing_key:
146
- specification_version: 3
143
+ specification_version: 4
147
144
  summary: Rows DRYs your controllers.
148
145
  test_files: []
data/.rvmrc DELETED
@@ -1,4 +0,0 @@
1
- rvm use 1.9.3@rails32
2
- #rvm use 1.9.2@rails31
3
-
4
- # rvm_gemset_create_on_use_flag=1
@@ -1,3 +0,0 @@
1
- <div style="color:red">
2
- Rendering requires partial '<%= model_symbol %>/_form.html.erb'
3
- </div>
@@ -1,30 +0,0 @@
1
- <%
2
- # Requires resources model_class columns
3
-
4
- cnt = 0
5
- %>
6
-
7
- <table class="rows-list">
8
- <tr>
9
- <% columns.each do |column| %>
10
- <th> <%= t("header.#{column}", :default => column) %> </th>
11
- <% end %>
12
- </tr>
13
- <% resources.each do |resource|
14
- url = "/#{controller_name}/#{resource.id}"
15
- cnt += 1
16
- %>
17
- <tr id="row_<%= resource.id%>" class="<%= %w{odd even}.at(cnt % 2) %>" >
18
- <% columns.each do |column| %>
19
- <td> <%= resource_format(resource.send(column)) %> </td>
20
- <% end %>
21
- <td>
22
- <%= link_to t('button.show', :default => 'Show'), url %>
23
- <%= link_to t('button.edit', :default => 'Edit'), url + '/edit' %>
24
- <%= link_to t('button.delete', :default => 'Delete'), url,
25
- :remote => true,
26
- :confirm => 'Are you sure?', :method => :delete %>
27
- </td>
28
- </tr>
29
- <% end %>
30
- </table>
@@ -1,22 +0,0 @@
1
- <%
2
- # submit links and/or buttons
3
- # Requires
4
- # content_for(:submit_<left|right>)
5
- # left|right (links names)
6
-
7
- # left|right must be used inside a form.
8
- # The clean content_for variant may be used unbounded.
9
-
10
- left ||= nil
11
- right ||= nil
12
- %>
13
- <div class="rows_submit" style="width:100%">
14
- <input style="display:none" type="submit" name="commit" value="OK" />
15
- <p style="float:left">
16
- <%= render '/rows/submit_part', :content => :submit_left, :names => left %>
17
- </p>
18
- <p style="float:right">
19
- <%= render '/rows/submit_part', :content => :submit_right, :names => right %>
20
- </p>
21
- <div style="clear:both"> </div>
22
- </div>
@@ -1,4 +0,0 @@
1
- <%= content_for(content) %>
2
- <% (names || []).each do |name| %>
3
- <button class="button" type="submit" name="commit" value="<%=name%>"><%=name%></button>
4
- <% end %>
@@ -1,22 +0,0 @@
1
- <%
2
- # Template for RowsController (edit)
3
- # Requires resource model_name model_symbol
4
- # partial 'form' template
5
-
6
- content_for(:submit_left) { link_to t('button.back', :default => 'Back'),
7
- "/#{controller_name}", class: 'button' }
8
- %>
9
-
10
- <%= render '/shared/error_explanation' %>
11
-
12
- <fieldset class="wide mask" id="<%= model_symbol %>">
13
- <legend>
14
- <%= t('ui.edit', :model => model_name,
15
- :default => 'Edit %{model}') %>
16
- </legend>
17
- <%= form_for resource do |f| %>
18
- <%= render 'form', :f => f %>
19
- <%= render '/rows/submit',
20
- :right => [t('ui.update', :default => 'Update')] %>
21
- <% end %>
22
- </fieldset>