tableficate 0.1.3 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (76) hide show
  1. data/README.markdown +53 -48
  2. data/app/views/tableficate/{_column_header.html.erb → _header.html.erb} +0 -0
  3. data/app/views/tableficate/_table.html.erb +4 -4
  4. data/app/views/tableficate/filters/_check_box.html.erb +4 -0
  5. data/app/views/tableficate/{_input_filter.html.erb → filters/_input.html.erb} +0 -0
  6. data/app/views/tableficate/{_input_range_filter.html.erb → filters/_input_range.html.erb} +0 -0
  7. data/app/views/tableficate/filters/_radio.html.erb +4 -0
  8. data/app/views/tableficate/{_select_filter.html.erb → filters/_select.html.erb} +0 -0
  9. data/app/views/tableficate/filters/_select_range.html.erb +6 -0
  10. data/changelog.markdown +8 -0
  11. data/lib/tableficate/action_column.rb +2 -2
  12. data/lib/tableficate/base.rb +2 -2
  13. data/lib/tableficate/column.rb +6 -2
  14. data/lib/tableficate/exceptions.rb +4 -0
  15. data/lib/tableficate/filters/base.rb +21 -0
  16. data/lib/tableficate/filters/check_box.rb +6 -0
  17. data/lib/tableficate/filters/choice.rb +23 -0
  18. data/lib/tableficate/filters/collection.rb +30 -0
  19. data/lib/tableficate/filters/input.rb +12 -0
  20. data/lib/tableficate/filters/input_range.rb +57 -0
  21. data/lib/tableficate/filters/radio.rb +6 -0
  22. data/lib/tableficate/filters/select.rb +6 -0
  23. data/lib/tableficate/filters/select_range.rb +54 -0
  24. data/lib/tableficate/helper.rb +69 -4
  25. data/lib/tableficate/table.rb +56 -10
  26. data/lib/tableficate/version.rb +1 -1
  27. data/lib/tableficate.rb +9 -3
  28. data/spec/action_column_spec.rb +1 -1
  29. data/spec/column_spec.rb +8 -0
  30. data/spec/filters/base_spec.rb +30 -0
  31. data/spec/filters/choice_spec.rb +13 -0
  32. data/spec/filters/collection_spec.rb +94 -0
  33. data/spec/filters/input_range_spec.rb +91 -0
  34. data/spec/filters/input_spec.rb +24 -0
  35. data/spec/generators/tableficate_table_spec.rb +20 -0
  36. data/spec/generators/tableficate_theme_spec.rb +11 -0
  37. data/spec/helper_spec.rb +164 -0
  38. data/spec/spec_helper.rb +3 -0
  39. data/spec/table_spec.rb +38 -13
  40. data/spec/test_app/Gemfile +1 -1
  41. data/spec/test_app/app/controllers/filters_controller.rb +7 -0
  42. data/spec/test_app/app/views/filters/check_box_tags.html.erb +14 -0
  43. data/spec/test_app/app/views/filters/multi_select_from_string.html.erb +11 -0
  44. data/spec/test_app/app/views/filters/multi_select_tag.html.erb +11 -0
  45. data/spec/test_app/app/views/filters/radio_tags.html.erb +14 -0
  46. data/spec/test_app/app/views/filters/select_from_string.html.erb +11 -0
  47. data/spec/test_app/app/views/filters/select_tag.html.erb +11 -0
  48. data/spec/test_app/app/views/tableficate/custom_check_box_block/_data.html.erb +1 -0
  49. data/spec/test_app/app/views/tableficate/custom_check_box_block/_header.html.erb +8 -0
  50. data/spec/test_app/app/views/tableficate/custom_check_box_block/_row.html.erb +5 -0
  51. data/spec/test_app/app/views/tableficate/custom_check_box_block/_table.html.erb +36 -0
  52. data/spec/test_app/app/views/tableficate/custom_check_box_block/filters/_check_box.html.erb +7 -0
  53. data/spec/test_app/app/views/tableficate/custom_check_box_block/filters/_input.html.erb +4 -0
  54. data/spec/test_app/app/views/tableficate/custom_check_box_block/filters/_input_range.html.erb +6 -0
  55. data/spec/test_app/app/views/tableficate/custom_check_box_block/filters/_radio.html.erb +4 -0
  56. data/spec/test_app/app/views/tableficate/custom_check_box_block/filters/_select.html.erb +4 -0
  57. data/spec/test_app/app/views/tableficate/custom_check_box_block/filters/_select_range_filter.html.erb +6 -0
  58. data/spec/test_app/app/views/tableficate/custom_radio_block/_data.html.erb +1 -0
  59. data/spec/test_app/app/views/tableficate/custom_radio_block/_header.html.erb +8 -0
  60. data/spec/test_app/app/views/tableficate/custom_radio_block/_row.html.erb +5 -0
  61. data/spec/test_app/app/views/tableficate/custom_radio_block/_table.html.erb +36 -0
  62. data/spec/test_app/app/views/tableficate/custom_radio_block/filters/_check_box.html.erb +4 -0
  63. data/spec/test_app/app/views/tableficate/custom_radio_block/filters/_input.html.erb +4 -0
  64. data/spec/test_app/app/views/tableficate/custom_radio_block/filters/_input_range.html.erb +6 -0
  65. data/spec/test_app/app/views/tableficate/custom_radio_block/filters/_radio.html.erb +7 -0
  66. data/spec/test_app/app/views/tableficate/custom_radio_block/filters/_select.html.erb +4 -0
  67. data/spec/test_app/app/views/tableficate/custom_radio_block/filters/_select_range_filter.html.erb +6 -0
  68. data/spec/test_app/config/routes.rb +1 -56
  69. data/tableficate.gemspec +4 -2
  70. metadata +122 -27
  71. data/lib/tableficate/filters/filter.rb +0 -19
  72. data/lib/tableficate/filters/input_filters.rb +0 -64
  73. data/lib/tableficate/filters/select_filter.rb +0 -11
  74. data/spec/filter_spec.rb +0 -30
  75. data/spec/input_filter_spec.rb +0 -90
  76. data/spec/select_filter_spec.rb +0 -10
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tableficate
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.3
4
+ version: 0.2.0
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -9,11 +9,11 @@ authors:
9
9
  autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
- date: 2011-11-27 00:00:00.000000000Z
12
+ date: 2011-12-06 00:00:00.000000000Z
13
13
  dependencies:
14
14
  - !ruby/object:Gem::Dependency
15
15
  name: rails
16
- requirement: &70183465929100 !ruby/object:Gem::Requirement
16
+ requirement: &70096246764520 !ruby/object:Gem::Requirement
17
17
  none: false
18
18
  requirements:
19
19
  - - ! '>='
@@ -21,10 +21,10 @@ dependencies:
21
21
  version: '3.1'
22
22
  type: :runtime
23
23
  prerelease: false
24
- version_requirements: *70183465929100
24
+ version_requirements: *70096246764520
25
25
  - !ruby/object:Gem::Dependency
26
26
  name: rake
27
- requirement: &70183465928680 !ruby/object:Gem::Requirement
27
+ requirement: &70096246764080 !ruby/object:Gem::Requirement
28
28
  none: false
29
29
  requirements:
30
30
  - - ! '>='
@@ -32,10 +32,10 @@ dependencies:
32
32
  version: '0'
33
33
  type: :development
34
34
  prerelease: false
35
- version_requirements: *70183465928680
35
+ version_requirements: *70096246764080
36
36
  - !ruby/object:Gem::Dependency
37
37
  name: rspec
38
- requirement: &70183465928220 !ruby/object:Gem::Requirement
38
+ requirement: &70096246763620 !ruby/object:Gem::Requirement
39
39
  none: false
40
40
  requirements:
41
41
  - - ! '>='
@@ -43,10 +43,32 @@ dependencies:
43
43
  version: '0'
44
44
  type: :development
45
45
  prerelease: false
46
- version_requirements: *70183465928220
46
+ version_requirements: *70096246763620
47
+ - !ruby/object:Gem::Dependency
48
+ name: genspec
49
+ requirement: &70096246763180 !ruby/object:Gem::Requirement
50
+ none: false
51
+ requirements:
52
+ - - ! '>='
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ type: :development
56
+ prerelease: false
57
+ version_requirements: *70096246763180
47
58
  - !ruby/object:Gem::Dependency
48
59
  name: sqlite3
49
- requirement: &70183465927800 !ruby/object:Gem::Requirement
60
+ requirement: &70096246762740 !ruby/object:Gem::Requirement
61
+ none: false
62
+ requirements:
63
+ - - ! '>='
64
+ - !ruby/object:Gem::Version
65
+ version: '0'
66
+ type: :development
67
+ prerelease: false
68
+ version_requirements: *70096246762740
69
+ - !ruby/object:Gem::Dependency
70
+ name: capybara
71
+ requirement: &70096246762320 !ruby/object:Gem::Requirement
50
72
  none: false
51
73
  requirements:
52
74
  - - ! '>='
@@ -54,8 +76,8 @@ dependencies:
54
76
  version: '0'
55
77
  type: :development
56
78
  prerelease: false
57
- version_requirements: *70183465927800
58
- description: Simple tables for Rails.
79
+ version_requirements: *70096246762320
80
+ description: A DSL for Rails that provides easy table creation with sorting and filtering.
59
81
  email:
60
82
  - alasseigne@sei-mi.com
61
83
  executables: []
@@ -67,13 +89,16 @@ files:
67
89
  - LICENSE
68
90
  - README.markdown
69
91
  - Rakefile
70
- - app/views/tableficate/_column_header.html.erb
71
92
  - app/views/tableficate/_data.html.erb
72
- - app/views/tableficate/_input_filter.html.erb
73
- - app/views/tableficate/_input_range_filter.html.erb
93
+ - app/views/tableficate/_header.html.erb
74
94
  - app/views/tableficate/_row.html.erb
75
- - app/views/tableficate/_select_filter.html.erb
76
95
  - app/views/tableficate/_table.html.erb
96
+ - app/views/tableficate/filters/_check_box.html.erb
97
+ - app/views/tableficate/filters/_input.html.erb
98
+ - app/views/tableficate/filters/_input_range.html.erb
99
+ - app/views/tableficate/filters/_radio.html.erb
100
+ - app/views/tableficate/filters/_select.html.erb
101
+ - app/views/tableficate/filters/_select_range.html.erb
77
102
  - changelog.markdown
78
103
  - lib/generators/tableficate/table/table_generator.rb
79
104
  - lib/generators/tableficate/table/templates/table.rb
@@ -85,9 +110,15 @@ files:
85
110
  - lib/tableficate/column.rb
86
111
  - lib/tableficate/engine.rb
87
112
  - lib/tableficate/exceptions.rb
88
- - lib/tableficate/filters/filter.rb
89
- - lib/tableficate/filters/input_filters.rb
90
- - lib/tableficate/filters/select_filter.rb
113
+ - lib/tableficate/filters/base.rb
114
+ - lib/tableficate/filters/check_box.rb
115
+ - lib/tableficate/filters/choice.rb
116
+ - lib/tableficate/filters/collection.rb
117
+ - lib/tableficate/filters/input.rb
118
+ - lib/tableficate/filters/input_range.rb
119
+ - lib/tableficate/filters/radio.rb
120
+ - lib/tableficate/filters/select.rb
121
+ - lib/tableficate/filters/select_range.rb
91
122
  - lib/tableficate/finder.rb
92
123
  - lib/tableficate/helper.rb
93
124
  - lib/tableficate/table.rb
@@ -97,10 +128,15 @@ files:
97
128
  - spec/active_record_extension_spec.rb
98
129
  - spec/base_spec.rb
99
130
  - spec/column_spec.rb
100
- - spec/filter_spec.rb
131
+ - spec/filters/base_spec.rb
132
+ - spec/filters/choice_spec.rb
133
+ - spec/filters/collection_spec.rb
134
+ - spec/filters/input_range_spec.rb
135
+ - spec/filters/input_spec.rb
101
136
  - spec/finder_spec.rb
102
- - spec/input_filter_spec.rb
103
- - spec/select_filter_spec.rb
137
+ - spec/generators/tableficate_table_spec.rb
138
+ - spec/generators/tableficate_theme_spec.rb
139
+ - spec/helper_spec.rb
104
140
  - spec/spec_helper.rb
105
141
  - spec/table_spec.rb
106
142
  - spec/test_app/.gitignore
@@ -111,12 +147,39 @@ files:
111
147
  - spec/test_app/app/assets/javascripts/application.js
112
148
  - spec/test_app/app/assets/stylesheets/application.css
113
149
  - spec/test_app/app/controllers/application_controller.rb
150
+ - spec/test_app/app/controllers/filters_controller.rb
114
151
  - spec/test_app/app/helpers/application_helper.rb
115
152
  - spec/test_app/app/mailers/.gitkeep
116
153
  - spec/test_app/app/models/.gitkeep
117
154
  - spec/test_app/app/models/nobel_prize.rb
118
155
  - spec/test_app/app/models/nobel_prize_winner.rb
156
+ - spec/test_app/app/views/filters/check_box_tags.html.erb
157
+ - spec/test_app/app/views/filters/multi_select_from_string.html.erb
158
+ - spec/test_app/app/views/filters/multi_select_tag.html.erb
159
+ - spec/test_app/app/views/filters/radio_tags.html.erb
160
+ - spec/test_app/app/views/filters/select_from_string.html.erb
161
+ - spec/test_app/app/views/filters/select_tag.html.erb
119
162
  - spec/test_app/app/views/layouts/application.html.erb
163
+ - spec/test_app/app/views/tableficate/custom_check_box_block/_data.html.erb
164
+ - spec/test_app/app/views/tableficate/custom_check_box_block/_header.html.erb
165
+ - spec/test_app/app/views/tableficate/custom_check_box_block/_row.html.erb
166
+ - spec/test_app/app/views/tableficate/custom_check_box_block/_table.html.erb
167
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_check_box.html.erb
168
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_input.html.erb
169
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_input_range.html.erb
170
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_radio.html.erb
171
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_select.html.erb
172
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_select_range_filter.html.erb
173
+ - spec/test_app/app/views/tableficate/custom_radio_block/_data.html.erb
174
+ - spec/test_app/app/views/tableficate/custom_radio_block/_header.html.erb
175
+ - spec/test_app/app/views/tableficate/custom_radio_block/_row.html.erb
176
+ - spec/test_app/app/views/tableficate/custom_radio_block/_table.html.erb
177
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_check_box.html.erb
178
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_input.html.erb
179
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_input_range.html.erb
180
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_radio.html.erb
181
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_select.html.erb
182
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_select_range_filter.html.erb
120
183
  - spec/test_app/config.ru
121
184
  - spec/test_app/config/application.rb
122
185
  - spec/test_app/config/boot.rb
@@ -167,7 +230,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
167
230
  version: '0'
168
231
  segments:
169
232
  - 0
170
- hash: -3799563162300104254
233
+ hash: -4309695575052773710
171
234
  required_rubygems_version: !ruby/object:Gem::Requirement
172
235
  none: false
173
236
  requirements:
@@ -176,22 +239,27 @@ required_rubygems_version: !ruby/object:Gem::Requirement
176
239
  version: '0'
177
240
  segments:
178
241
  - 0
179
- hash: -3799563162300104254
242
+ hash: -4309695575052773710
180
243
  requirements: []
181
244
  rubyforge_project: tableficate
182
245
  rubygems_version: 1.8.6
183
246
  signing_key:
184
247
  specification_version: 3
185
- summary: Simple tables for Rails.
248
+ summary: A DSL for Rails that provides easy table creation with sorting and filtering.
186
249
  test_files:
187
250
  - spec/action_column_spec.rb
188
251
  - spec/active_record_extension_spec.rb
189
252
  - spec/base_spec.rb
190
253
  - spec/column_spec.rb
191
- - spec/filter_spec.rb
254
+ - spec/filters/base_spec.rb
255
+ - spec/filters/choice_spec.rb
256
+ - spec/filters/collection_spec.rb
257
+ - spec/filters/input_range_spec.rb
258
+ - spec/filters/input_spec.rb
192
259
  - spec/finder_spec.rb
193
- - spec/input_filter_spec.rb
194
- - spec/select_filter_spec.rb
260
+ - spec/generators/tableficate_table_spec.rb
261
+ - spec/generators/tableficate_theme_spec.rb
262
+ - spec/helper_spec.rb
195
263
  - spec/spec_helper.rb
196
264
  - spec/table_spec.rb
197
265
  - spec/test_app/.gitignore
@@ -202,12 +270,39 @@ test_files:
202
270
  - spec/test_app/app/assets/javascripts/application.js
203
271
  - spec/test_app/app/assets/stylesheets/application.css
204
272
  - spec/test_app/app/controllers/application_controller.rb
273
+ - spec/test_app/app/controllers/filters_controller.rb
205
274
  - spec/test_app/app/helpers/application_helper.rb
206
275
  - spec/test_app/app/mailers/.gitkeep
207
276
  - spec/test_app/app/models/.gitkeep
208
277
  - spec/test_app/app/models/nobel_prize.rb
209
278
  - spec/test_app/app/models/nobel_prize_winner.rb
279
+ - spec/test_app/app/views/filters/check_box_tags.html.erb
280
+ - spec/test_app/app/views/filters/multi_select_from_string.html.erb
281
+ - spec/test_app/app/views/filters/multi_select_tag.html.erb
282
+ - spec/test_app/app/views/filters/radio_tags.html.erb
283
+ - spec/test_app/app/views/filters/select_from_string.html.erb
284
+ - spec/test_app/app/views/filters/select_tag.html.erb
210
285
  - spec/test_app/app/views/layouts/application.html.erb
286
+ - spec/test_app/app/views/tableficate/custom_check_box_block/_data.html.erb
287
+ - spec/test_app/app/views/tableficate/custom_check_box_block/_header.html.erb
288
+ - spec/test_app/app/views/tableficate/custom_check_box_block/_row.html.erb
289
+ - spec/test_app/app/views/tableficate/custom_check_box_block/_table.html.erb
290
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_check_box.html.erb
291
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_input.html.erb
292
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_input_range.html.erb
293
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_radio.html.erb
294
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_select.html.erb
295
+ - spec/test_app/app/views/tableficate/custom_check_box_block/filters/_select_range_filter.html.erb
296
+ - spec/test_app/app/views/tableficate/custom_radio_block/_data.html.erb
297
+ - spec/test_app/app/views/tableficate/custom_radio_block/_header.html.erb
298
+ - spec/test_app/app/views/tableficate/custom_radio_block/_row.html.erb
299
+ - spec/test_app/app/views/tableficate/custom_radio_block/_table.html.erb
300
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_check_box.html.erb
301
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_input.html.erb
302
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_input_range.html.erb
303
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_radio.html.erb
304
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_select.html.erb
305
+ - spec/test_app/app/views/tableficate/custom_radio_block/filters/_select_range_filter.html.erb
211
306
  - spec/test_app/config.ru
212
307
  - spec/test_app/config/application.rb
213
308
  - spec/test_app/config/boot.rb
@@ -1,19 +0,0 @@
1
- module Tableficate
2
- class Filter
3
- attr_reader :name, :label, :options, :template, :table, :field_name
4
-
5
- def initialize(table, name, options = {})
6
- @table = table
7
- @name = name
8
- @options = options
9
-
10
- @template = self.class.name.demodulize.underscore
11
- @label = @options[:label] || table.columns.detect{|column| column.name == @name}.try(:header) || name.to_s.titleize
12
- @field_name = "#{table.as}[filter][#{@name}]"
13
- end
14
-
15
- def field_value(params)
16
- params[:filter][@name] rescue ''
17
- end
18
- end
19
- end
@@ -1,64 +0,0 @@
1
- module Tableficate
2
- class InputFilter < Filter
3
- def initialize(table, name, options = {})
4
- super(table, name, options)
5
-
6
- type = @options[:field_options][:type] rescue 'text'
7
-
8
- if not Dir.glob('app/views/' + Tableficate::Utils::template_path("_#{type}_#{@template}.html.*", table.options[:theme])).empty?
9
- @template = "#{type}_#{@template}"
10
- end
11
- end
12
- end
13
-
14
- class InputStartFilter < InputFilter
15
- def initialize(table, name, options = {})
16
- super(table, name, options)
17
-
18
- @field_name += '[start]'
19
- end
20
-
21
- def name
22
- "#{@name}_start".to_sym
23
- end
24
-
25
- def field_value(params)
26
- params[:filter][@name][:start] rescue ''
27
- end
28
- end
29
-
30
- class InputStopFilter < InputFilter
31
- def initialize(table, name, options = {})
32
- super(table, name, options)
33
-
34
- @field_name += '[stop]'
35
- end
36
-
37
- def name
38
- "#{@name}_stop".to_sym
39
- end
40
-
41
- def field_value(params)
42
- params[:filter][@name][:stop] rescue ''
43
- end
44
- end
45
-
46
- class InputRangeFilter < Filter
47
- attr_reader :start, :stop
48
-
49
- def initialize(table, name, options = {})
50
- start_options = options.delete(:start) || {}
51
- stop_options = options.delete(:stop) || {}
52
-
53
- super(table, name, options)
54
-
55
- start_options.reverse_merge!(@options)
56
- start_options.reverse_merge!(label: self.label)
57
- stop_options.reverse_merge!(@options)
58
- stop_options.reverse_merge!(label: self.label)
59
-
60
- @start = InputStartFilter.new(table, name, start_options)
61
- @stop = InputStopFilter.new(table, name, stop_options)
62
- end
63
- end
64
- end
@@ -1,11 +0,0 @@
1
- module Tableficate
2
- class SelectFilter < Filter
3
- attr_reader :choices
4
-
5
- def initialize(table, name, choices, options = {})
6
- super(table, name, options)
7
-
8
- @choices = choices
9
- end
10
- end
11
- end
data/spec/filter_spec.rb DELETED
@@ -1,30 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Tableficate::Filter do
4
- before(:all) do
5
- @table = Tableficate::Table.new(nil, NobelPrizeWinner.limit(1), {}, {})
6
- @table.column(:first_name, header: 'Given Name')
7
- end
8
-
9
- it 'should find the correct template type' do
10
- Tableficate::Filter.new(@table, :first_name).template.should == 'filter'
11
- end
12
-
13
- it 'should use the provided label or default to the column header' do
14
- Tableficate::Filter.new(@table, :first_name).label.should == 'Given Name'
15
- Tableficate::Filter.new(@table, :first_name, label: 'First').label.should == 'First'
16
- end
17
-
18
- it 'should provide a field name' do
19
- Tableficate::Filter.new(@table, :first_name).field_name.should == "#{@table.as}[filter][first_name]"
20
- end
21
-
22
- it 'should provide a field value when given params or a blank value' do
23
- Tableficate::Filter.new(@table, :first_name).field_value({filter: {first_name: 'Aaron'}}).should == 'Aaron'
24
- Tableficate::Filter.new(@table, :first_name).field_value({}).should == ''
25
- end
26
-
27
- it 'should allow for filters that do not match a particular field' do
28
- Tableficate::Filter.new(@table, :custom_field).label.should == 'Custom Field'
29
- end
30
- end
@@ -1,90 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Tableficate::InputFilter do
4
- before(:all) do
5
- @table = Tableficate::Table.new(nil, NobelPrizeWinner.joins(:nobel_prizes).limit(1), {}, {})
6
- @table.column(:first_name)
7
- end
8
-
9
- it 'should find the correct template type' do
10
- Tableficate::InputFilter.new(@table, :first_name).template.should == 'input_filter'
11
-
12
- Tableficate::InputFilter.new(@table, :first_name, field_options: {type: 'email'}).template.should == 'input_filter'
13
-
14
- file = File.open('app/views/tableficate/_email_input_filter.html.erb', 'w')
15
- Tableficate::InputFilter.new(@table, :first_name, field_options: {type: 'email'}).template.should == 'email_input_filter'
16
- File.delete(file.path)
17
-
18
- file = File.open('app/views/tableficate/_email_input_filter.html.haml', 'w')
19
- Tableficate::InputFilter.new(@table, :first_name, field_options: {type: 'email'}).template.should == 'email_input_filter'
20
- File.delete(file.path)
21
- end
22
- end
23
-
24
- describe Tableficate::InputStartFilter do
25
- before(:all) do
26
- @table = Tableficate::Table.new(nil, NobelPrizeWinner.joins(:nobel_prizes).limit(1), {}, {})
27
- @table.column(:year)
28
- end
29
-
30
- it 'should append "[start]" to field_name' do
31
- Tableficate::InputStartFilter.new(@table, :year).field_name == "#{@table.as}[filter][year][start]"
32
- end
33
-
34
- it 'should append "_start" to the name' do
35
- Tableficate::InputStartFilter.new(@table, :year).name == :year_start
36
- end
37
-
38
- it 'should provide a field value when given params or a blank value' do
39
- Tableficate::InputStartFilter.new(@table, :year).field_value({filter: {year: {start: '2011'}}}).should == '2011'
40
- Tableficate::InputStartFilter.new(@table, :year).field_value({}).should == ''
41
- end
42
- end
43
-
44
- describe Tableficate::InputStopFilter do
45
- before(:all) do
46
- @table = Tableficate::Table.new(nil, NobelPrizeWinner.joins(:nobel_prizes).limit(1), {}, {})
47
- @table.column(:year)
48
- end
49
-
50
- it 'should append "[stop]" to field_name' do
51
- Tableficate::InputStopFilter.new(@table, :year).field_name == "#{@table.as}[filter][year][stop]"
52
- end
53
-
54
- it 'should append "_stop" to the name' do
55
- Tableficate::InputStopFilter.new(@table, :year).name == :year_stop
56
- end
57
-
58
- it 'should provide a field value when given params or a blank value' do
59
- Tableficate::InputStopFilter.new(@table, :year).field_value({filter: {year: {stop: '2011'}}}).should == '2011'
60
- Tableficate::InputStopFilter.new(@table, :year).field_value({}).should == ''
61
- end
62
- end
63
-
64
- describe Tableficate::InputRangeFilter do
65
- before(:all) do
66
- @table = Tableficate::Table.new(nil, NobelPrizeWinner.joins(:nobel_prizes).limit(1), {}, {})
67
- @table.column(:year)
68
- end
69
-
70
- it 'should find the correct template type' do
71
- Tableficate::InputRangeFilter.new(@table, :year).template.should == 'input_range_filter'
72
- end
73
-
74
- it 'should create a start and stop input' do
75
- filter = Tableficate::InputRangeFilter.new(@table, :year)
76
-
77
- filter.start.is_a?(Tableficate::InputStartFilter).should be true
78
- filter.stop.is_a?(Tableficate::InputStopFilter).should be true
79
- end
80
-
81
- it 'should use the :start and :stop option hashes for the individual filters and default any values not passed to the range options provided' do
82
- filter = Tableficate::InputRangeFilter.new(@table, :year, label: 'Nobel Prize Won In')
83
- filter.start.label.should == 'Nobel Prize Won In'
84
- filter.stop.label.should == 'Nobel Prize Won In'
85
-
86
- filter = Tableficate::InputRangeFilter.new(@table, :birth_date, label: 'Nobel Prize Won In', start: {label: 'Nobel Prize Won Between'}, stop: {label: 'and'})
87
- filter.start.label.should == 'Nobel Prize Won Between'
88
- filter.stop.label.should == 'and'
89
- end
90
- end
@@ -1,10 +0,0 @@
1
- require 'spec_helper'
2
-
3
- describe Tableficate::SelectFilter do
4
- it 'should find the correct template type' do
5
- table = Tableficate::Table.new(nil, NobelPrizeWinner.joins(:nobel_prizes).limit(1), {}, {})
6
- table.column(:year)
7
-
8
- Tableficate::SelectFilter.new(table, :year, []).template.should == 'select_filter'
9
- end
10
- end