table-for 2.2.0 → 3.0.0

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.
data/spec/spec_helper.rb CHANGED
@@ -9,6 +9,7 @@ require 'xmlsimple'
9
9
  require 'active_record'
10
10
  require 'active_support/all'
11
11
  require 'with_model'
12
+ require 'ruby-debug'
12
13
 
13
14
  def print_hash(hash)
14
15
  hash.inject("") { |s, (k, v)| "#{s} #{k}: #{v}." }
@@ -0,0 +1,96 @@
1
+ require "spec_helper"
2
+
3
+ describe TableFor::HelperMethods do
4
+ before(:each) do
5
+ @view_class = Class.new
6
+ @view = @view_class.new
7
+ @view_class.send(:include, Blocks::ViewAdditions::ClassMethods)
8
+ @helper = TableFor::Base.new(@view)
9
+ @records = [OpenStruct.new(:id => 1)]
10
+ @column = stub(:name => :my_column, :anonymous => false)
11
+ end
12
+
13
+ describe "header_column_html method" do
14
+ it "should return an empty hash if header_column_html is not passed in" do
15
+ header_column_html = @helper.header_column_html(@column)
16
+ header_column_html.should eql({})
17
+ end
18
+
19
+ it "should evaluate any procs for header_column_html" do
20
+ header_column_html = @helper.header_column_html(@column, :header_column_html => {:class => lambda {|column| "#{column.name}_header"}})
21
+ header_column_html[:class].should eql "#{@column.name}_header"
22
+ end
23
+
24
+ it "should join the 'sorting' class with any other header_column_html class provided" do
25
+ @view.expects(:params).returns({})
26
+ header_column_html = @helper.header_column_html(@column, :header_column_html => {:class => "c1 c2"}, :sortable => true)
27
+ header_column_html[:class].should eql "c1 c2 sorting"
28
+ end
29
+
30
+ it "should add a 'sorting' class to the header_column_html class if a column is sortable" do
31
+ @view.expects(:params).returns({})
32
+ header_column_html = @helper.header_column_html(@column, :sortable => true)
33
+ header_column_html[:class].should eql "sorting"
34
+ end
35
+
36
+ it "should add a 'sorting_asc' class to the header_column_html class if a column is sortable and it is already sorted in asc order" do
37
+ @view.expects(:params).at_least_once.returns(:order => @column.name.to_s, :sort_mode => "asc")
38
+ header_column_html = @helper.header_column_html(@column, :sortable => true)
39
+ header_column_html[:class].should eql "sorting_asc"
40
+ end
41
+
42
+ it "should add a 'sorting_desc' class to the header_column_html class if a column is sortable and it is already sorted in desc order" do
43
+ @view.expects(:params).at_least_once.returns(:order => @column.name.to_s, :sort_mode => "desc")
44
+ header_column_html = @helper.header_column_html(@column, :sortable => true)
45
+ header_column_html[:class].should eql "sorting_desc"
46
+ end
47
+
48
+ it "should add a 'sorting' class to the header_column_html class if a column is sortable and it is reset mode" do
49
+ @view.expects(:params).at_least_once.returns(:order => @column.name.to_s, :sort_mode => "reset")
50
+ header_column_html = @helper.header_column_html(@column, :sortable => true)
51
+ header_column_html[:class].should eql "sorting"
52
+ end
53
+ end
54
+
55
+ describe "header_sort_link method" do
56
+ before(:each) do
57
+ @view.stubs(:capture).returns(@column.name.to_s.titleize)
58
+ end
59
+
60
+ it "should be able to generate a sort link for a column if that column is sortable" do
61
+ @view.expects(:params).at_least_once.returns({})
62
+ @view.expects(:link_to).with(@column.name.to_s.titleize, "?order=#{@column.name}&sort_mode=asc").returns "my link"
63
+ @helper.header_sort_link(@column, :sortable => true).should eql "my link"
64
+ end
65
+
66
+ it "should be able to generate a sort link for a column if that column is sortable and it is already sorted in asc order" do
67
+ @view.expects(:params).at_least_once.returns(:order => @column.name.to_s, :sort_mode => "asc")
68
+ @view.expects(:link_to).with(@column.name.to_s.titleize, "?order=#{@column.name}&sort_mode=desc").returns "my link"
69
+ @helper.header_sort_link(@column, :sortable => true).should eql "my link"
70
+ end
71
+
72
+ it "should be able to generate a sort link for a column if that column is sortable and it is already sorted in desc order" do
73
+ @view.expects(:params).at_least_once.returns(:order => @column.name.to_s, :sort_mode => "desc")
74
+ @view.expects(:link_to).with(@column.name.to_s.titleize, "?order=#{@column.name}&sort_mode=reset").returns "my link"
75
+ @helper.header_sort_link(@column, :sortable => true).should eql "my link"
76
+ end
77
+
78
+ it "should be able specify the sort_url for a sort link" do
79
+ @view.expects(:params).at_least_once.returns({})
80
+ @view.expects(:link_to).with(@column.name.to_s.titleize, "/users?order=#{@column.name}&sort_mode=asc").returns "my link"
81
+ @helper.header_sort_link(@column, :sort_url => "/users", :sortable => true).should eql "my link"
82
+ end
83
+
84
+ it "should be able specify the order field for a sort link" do
85
+ @view.expects(:params).at_least_once.returns({})
86
+ @view.expects(:link_to).with(@column.name.to_s.titleize, "?order=first_name%2Clast_name&sort_mode=asc").returns "my link"
87
+ @helper.header_sort_link(@column, :order => "first_name,last_name", :sortable => true).should eql "my link"
88
+ end
89
+
90
+ it "should remove the action and controller params when generating the url" do
91
+ @view.expects(:params).at_least_once.returns(:controller => "users", :action => "show")
92
+ @view.expects(:link_to).with(@column.name.to_s.titleize, "?order=#{@column.name}&sort_mode=asc").returns "my link"
93
+ @helper.header_sort_link(@column, :sortable => true) { @column.name.to_s.titleize }.should eql "my link"
94
+ end
95
+ end
96
+ end
@@ -42,90 +42,4 @@ describe TableFor::ViewAdditions do
42
42
  @view.table_for(@records, :option1 => 1, :option2 => "2")
43
43
  end
44
44
  end
45
-
46
- describe "table_for_header_html method" do
47
- it "should return an empty hash if header_html is not passed in" do
48
- header_html = @view.table_for_header_html(@column)
49
- header_html.should eql({})
50
- end
51
-
52
- it "should evaluate any procs for header_html" do
53
- header_html = @view.table_for_header_html(@column, :header_html => {:class => lambda {|column| "#{column.name}_header"}})
54
- header_html[:class].should eql "#{@column.name}_header"
55
- end
56
-
57
- it "should join the 'sorting' class with any other header_html class provided" do
58
- @view.expects(:params).returns({})
59
- header_html = @view.table_for_header_html(@column, :header_html => {:class => "c1 c2"}, :sortable => true)
60
- header_html[:class].should eql "c1 c2 sorting"
61
- end
62
-
63
- it "should add a 'sorting' class to the header_html class if a column is sortable" do
64
- @view.expects(:params).returns({})
65
- header_html = @view.table_for_header_html(@column, :sortable => true)
66
- header_html[:class].should eql "sorting"
67
- end
68
-
69
- it "should add a 'sorting_asc' class to the header_html class if a column is sortable and it is already sorted in asc order" do
70
- @view.expects(:params).at_least_once.returns(:order => @column.name.to_s, :sort_mode => "asc")
71
- header_html = @view.table_for_header_html(@column, :sortable => true)
72
- header_html[:class].should eql "sorting_asc"
73
- end
74
-
75
- it "should add a 'sorting_desc' class to the header_html class if a column is sortable and it is already sorted in desc order" do
76
- @view.expects(:params).at_least_once.returns(:order => @column.name.to_s, :sort_mode => "desc")
77
- header_html = @view.table_for_header_html(@column, :sortable => true)
78
- header_html[:class].should eql "sorting_desc"
79
- end
80
-
81
- it "should add a 'sorting' class to the header_html class if a column is sortable and it is reset mode" do
82
- @view.expects(:params).at_least_once.returns(:order => @column.name.to_s, :sort_mode => "reset")
83
- header_html = @view.table_for_header_html(@column, :sortable => true)
84
- header_html[:class].should eql "sorting"
85
- end
86
- end
87
-
88
- describe "table_for_sort_link method" do
89
- it "should be able to generate a sort link for a column if that column is sortable" do
90
- @view.expects(:params).at_least_once.returns({})
91
- @view.expects(:link_to).with(@column.name.to_s.titleize, "?order=#{@column.name}&sort_mode=asc").returns "my link"
92
- @view.table_for_sort_link(@column).should eql "my link"
93
- end
94
-
95
- it "should be able to generate a sort link for a column if that column is sortable and it is already sorted in asc order" do
96
- @view.expects(:params).at_least_once.returns(:order => @column.name.to_s, :sort_mode => "asc")
97
- @view.expects(:link_to).with(@column.name.to_s.titleize, "?order=#{@column.name}&sort_mode=desc").returns "my link"
98
- @view.table_for_sort_link(@column).should eql "my link"
99
- end
100
-
101
- it "should be able to generate a sort link for a column if that column is sortable and it is already sorted in desc order" do
102
- @view.expects(:params).at_least_once.returns(:order => @column.name.to_s, :sort_mode => "desc")
103
- @view.expects(:link_to).with(@column.name.to_s.titleize, "?order=#{@column.name}&sort_mode=reset").returns "my link"
104
- @view.table_for_sort_link(@column).should eql "my link"
105
- end
106
-
107
- it "should be able specify the label for a sort link" do
108
- @view.expects(:params).at_least_once.returns({})
109
- @view.expects(:link_to).with("My Label", "?order=#{@column.name}&sort_mode=asc").returns "my link"
110
- @view.table_for_sort_link(@column, :label => "My Label").should eql "my link"
111
- end
112
-
113
- it "should be able specify the sort_url for a sort link" do
114
- @view.expects(:params).at_least_once.returns({})
115
- @view.expects(:link_to).with(@column.name.to_s.titleize, "/users?order=#{@column.name}&sort_mode=asc").returns "my link"
116
- @view.table_for_sort_link(@column, :sort_url => "/users").should eql "my link"
117
- end
118
-
119
- it "should be able specify the order field for a sort link" do
120
- @view.expects(:params).at_least_once.returns({})
121
- @view.expects(:link_to).with(@column.name.to_s.titleize, "?order=first_name%2Clast_name&sort_mode=asc").returns "my link"
122
- @view.table_for_sort_link(@column, :order => "first_name,last_name").should eql "my link"
123
- end
124
-
125
- it "should remove the action and controller params when generating the url" do
126
- @view.expects(:params).at_least_once.returns(:controller => "users", :action => "show")
127
- @view.expects(:link_to).with(@column.name.to_s.titleize, "?order=#{@column.name}&sort_mode=asc").returns "my link"
128
- @view.table_for_sort_link(@column).should eql "my link"
129
- end
130
- end
131
45
  end
data/table-for.gemspec CHANGED
@@ -5,11 +5,11 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "table-for"
8
- s.version = "2.2.0"
8
+ s.version = "3.0.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Andrew Hunter"]
12
- s.date = "2013-08-17"
12
+ s.date = "2013-08-28"
13
13
  s.description = "table-for is a table builder for an array of objects, easily allowing overriding of how any aspect of the table is generated"
14
14
  s.email = "hunterae@gmail.com"
15
15
  s.extra_rdoc_files = [
@@ -26,14 +26,18 @@ Gem::Specification.new do |s|
26
26
  "Rakefile",
27
27
  "VERSION",
28
28
  "app/views/table_for/_table_for.html.erb",
29
+ "example.rdoc",
30
+ "example_table.png",
29
31
  "lib/table-for.rb",
30
32
  "lib/table_for.rb",
31
33
  "lib/table_for/base.rb",
32
34
  "lib/table_for/engine.rb",
35
+ "lib/table_for/helper_methods.rb",
33
36
  "lib/table_for/view_additions.rb",
34
37
  "rails/init.rb",
35
38
  "spec/integration/table_for_spec.rb",
36
39
  "spec/spec_helper.rb",
40
+ "spec/table_for/helper_methods_spec.rb",
37
41
  "spec/table_for/view_additions_spec.rb",
38
42
  "table-for.gemspec"
39
43
  ]
@@ -48,7 +52,7 @@ Gem::Specification.new do |s|
48
52
 
49
53
  if Gem::Version.new(Gem::VERSION) >= Gem::Version.new('1.2.0') then
50
54
  s.add_runtime_dependency(%q<rails>, [">= 3.0.0"])
51
- s.add_runtime_dependency(%q<blocks>, ["~> 2.2.0"])
55
+ s.add_runtime_dependency(%q<blocks>, ["~> 2.3.0"])
52
56
  s.add_development_dependency(%q<rspec-rails>, [">= 2.0.0.beta.20"])
53
57
  s.add_development_dependency(%q<mocha>, ["= 0.10.3"])
54
58
  s.add_development_dependency(%q<xml-simple>, ["= 1.1.1"])
@@ -57,9 +61,10 @@ Gem::Specification.new do |s|
57
61
  s.add_development_dependency(%q<with_model>, ["= 0.2.6"])
58
62
  s.add_development_dependency(%q<bundler>, ["~> 1.3.5"])
59
63
  s.add_development_dependency(%q<jeweler>, ["~> 1.8.4"])
64
+ s.add_development_dependency(%q<debugger>, [">= 0"])
60
65
  else
61
66
  s.add_dependency(%q<rails>, [">= 3.0.0"])
62
- s.add_dependency(%q<blocks>, ["~> 2.2.0"])
67
+ s.add_dependency(%q<blocks>, ["~> 2.3.0"])
63
68
  s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta.20"])
64
69
  s.add_dependency(%q<mocha>, ["= 0.10.3"])
65
70
  s.add_dependency(%q<xml-simple>, ["= 1.1.1"])
@@ -68,10 +73,11 @@ Gem::Specification.new do |s|
68
73
  s.add_dependency(%q<with_model>, ["= 0.2.6"])
69
74
  s.add_dependency(%q<bundler>, ["~> 1.3.5"])
70
75
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
76
+ s.add_dependency(%q<debugger>, [">= 0"])
71
77
  end
72
78
  else
73
79
  s.add_dependency(%q<rails>, [">= 3.0.0"])
74
- s.add_dependency(%q<blocks>, ["~> 2.2.0"])
80
+ s.add_dependency(%q<blocks>, ["~> 2.3.0"])
75
81
  s.add_dependency(%q<rspec-rails>, [">= 2.0.0.beta.20"])
76
82
  s.add_dependency(%q<mocha>, ["= 0.10.3"])
77
83
  s.add_dependency(%q<xml-simple>, ["= 1.1.1"])
@@ -80,6 +86,7 @@ Gem::Specification.new do |s|
80
86
  s.add_dependency(%q<with_model>, ["= 0.2.6"])
81
87
  s.add_dependency(%q<bundler>, ["~> 1.3.5"])
82
88
  s.add_dependency(%q<jeweler>, ["~> 1.8.4"])
89
+ s.add_dependency(%q<debugger>, [">= 0"])
83
90
  end
84
91
  end
85
92
 
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: table-for
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.2.0
4
+ version: 3.0.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,7 +9,7 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2013-08-17 00:00:00.000000000 Z
12
+ date: 2013-08-28 00:00:00.000000000 Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
@@ -34,7 +34,7 @@ dependencies:
34
34
  requirements:
35
35
  - - ~>
36
36
  - !ruby/object:Gem::Version
37
- version: 2.2.0
37
+ version: 2.3.0
38
38
  type: :runtime
39
39
  prerelease: false
40
40
  version_requirements: !ruby/object:Gem::Requirement
@@ -42,7 +42,7 @@ dependencies:
42
42
  requirements:
43
43
  - - ~>
44
44
  - !ruby/object:Gem::Version
45
- version: 2.2.0
45
+ version: 2.3.0
46
46
  - !ruby/object:Gem::Dependency
47
47
  name: rspec-rails
48
48
  requirement: !ruby/object:Gem::Requirement
@@ -171,6 +171,22 @@ dependencies:
171
171
  - - ~>
172
172
  - !ruby/object:Gem::Version
173
173
  version: 1.8.4
174
+ - !ruby/object:Gem::Dependency
175
+ name: debugger
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :development
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
174
190
  description: table-for is a table builder for an array of objects, easily allowing
175
191
  overriding of how any aspect of the table is generated
176
192
  email: hunterae@gmail.com
@@ -189,14 +205,18 @@ files:
189
205
  - Rakefile
190
206
  - VERSION
191
207
  - app/views/table_for/_table_for.html.erb
208
+ - example.rdoc
209
+ - example_table.png
192
210
  - lib/table-for.rb
193
211
  - lib/table_for.rb
194
212
  - lib/table_for/base.rb
195
213
  - lib/table_for/engine.rb
214
+ - lib/table_for/helper_methods.rb
196
215
  - lib/table_for/view_additions.rb
197
216
  - rails/init.rb
198
217
  - spec/integration/table_for_spec.rb
199
218
  - spec/spec_helper.rb
219
+ - spec/table_for/helper_methods_spec.rb
200
220
  - spec/table_for/view_additions_spec.rb
201
221
  - table-for.gemspec
202
222
  homepage: http://github.com/hunterae/table-for
@@ -214,7 +234,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
214
234
  version: '0'
215
235
  segments:
216
236
  - 0
217
- hash: 1230221337141463981
237
+ hash: 2331322861691522510
218
238
  required_rubygems_version: !ruby/object:Gem::Requirement
219
239
  none: false
220
240
  requirements: