rails-bootstrap-widgets 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (49) hide show
  1. data/MIT-LICENSE +20 -0
  2. data/README.md +220 -0
  3. data/Rakefile +40 -0
  4. data/app/assets/javascripts/rails-bootstrap-widgets/application.js +15 -0
  5. data/app/assets/javascripts/rails-bootstrap-widgets/filters.js.coffee +12 -0
  6. data/app/assets/javascripts/rails-bootstrap-widgets/show_modal.js +26 -0
  7. data/app/helpers/rails-bootstrap-widgets/application_helper.rb +4 -0
  8. data/app/helpers/rails-bootstrap-widgets/filters_helper.rb +58 -0
  9. data/app/helpers/rails-bootstrap-widgets/modal_helper.rb +61 -0
  10. data/config/locales/en.yml +15 -0
  11. data/config/locales/ru.yml +15 -0
  12. data/lib/rails-bootstrap-widgets.rb +4 -0
  13. data/lib/rails-bootstrap-widgets/engine.rb +5 -0
  14. data/lib/rails-bootstrap-widgets/version.rb +3 -0
  15. data/lib/tasks/rails-bootstrap-widgets_tasks.rake +4 -0
  16. data/spec/dummy/README.rdoc +261 -0
  17. data/spec/dummy/Rakefile +7 -0
  18. data/spec/dummy/app/assets/javascripts/application.js +15 -0
  19. data/spec/dummy/app/assets/stylesheets/application.css +13 -0
  20. data/spec/dummy/app/controllers/application_controller.rb +3 -0
  21. data/spec/dummy/app/helpers/application_helper.rb +2 -0
  22. data/spec/dummy/app/views/layouts/application.html.erb +14 -0
  23. data/spec/dummy/config.ru +4 -0
  24. data/spec/dummy/config/application.rb +59 -0
  25. data/spec/dummy/config/boot.rb +10 -0
  26. data/spec/dummy/config/database.yml +25 -0
  27. data/spec/dummy/config/environment.rb +5 -0
  28. data/spec/dummy/config/environments/development.rb +37 -0
  29. data/spec/dummy/config/environments/production.rb +67 -0
  30. data/spec/dummy/config/environments/test.rb +37 -0
  31. data/spec/dummy/config/initializers/backtrace_silencers.rb +7 -0
  32. data/spec/dummy/config/initializers/inflections.rb +15 -0
  33. data/spec/dummy/config/initializers/mime_types.rb +5 -0
  34. data/spec/dummy/config/initializers/secret_token.rb +7 -0
  35. data/spec/dummy/config/initializers/session_store.rb +8 -0
  36. data/spec/dummy/config/initializers/wrap_parameters.rb +14 -0
  37. data/spec/dummy/config/locales/en.yml +5 -0
  38. data/spec/dummy/config/routes.rb +4 -0
  39. data/spec/dummy/db/test.sqlite3 +0 -0
  40. data/spec/dummy/log/test.log +47 -0
  41. data/spec/dummy/public/404.html +26 -0
  42. data/spec/dummy/public/422.html +26 -0
  43. data/spec/dummy/public/500.html +25 -0
  44. data/spec/dummy/public/favicon.ico +0 -0
  45. data/spec/dummy/script/rails +6 -0
  46. data/spec/helpers/rails-bootstrap-widgets/filters_helper_spec.rb +50 -0
  47. data/spec/helpers/rails-bootstrap-widgets/modal_helper_spec.rb +75 -0
  48. data/spec/spec_helper.rb +14 -0
  49. metadata +356 -0
@@ -0,0 +1,75 @@
1
+ require 'spec_helper'
2
+
3
+ module RailsBootstrapWidgets
4
+ describe ModalHelper do
5
+
6
+ subject { helper }
7
+
8
+ describe "modal form widget" do
9
+
10
+ it { should respond_to :modal_form_widget }
11
+
12
+ it "should provide proper html" do
13
+ target = "<form accept-charset=\"UTF-8\" action=\"/some_addr\" class=\"modal fade\" data-remote=\"true\" id=\"modal\" method=\"post\"><div style=\"margin:0;padding:0;display:inline\"><input name=\"utf8\" type=\"hidden\" value=\"&#x2713;\" /></div><input id=\"_method\" name=\"_method\" type=\"hidden\" value=\"put\" /><header class=\"modal-header\"><button aria-hidden=\"true\" class=\"close\" data-dismiss=\"modal\" type=\"button\">&times;</button><h1>Title</h1></header><div class=\"modal-body\">content</div><div class=\"modal-footer\"><a href=\"#\" aria-hidden=\"true\" class=\"btn\" data-dismiss=\"modal\">Cancel</a><input class=\"btn btn-primary\" id=\"submit\" name=\"commit\" type=\"submit\" value=\"Button\" /></div></form>"
14
+ helper.modal_form_widget(title: 'Title', button: 'Button', method: :put, action: '/some_addr', cancel: "Cancel"){ "content" }.should eq(target)
15
+ end
16
+
17
+ it "should return blank if title isn't set" do
18
+ helper.modal_form_widget(button: 'Button', method: :get, action: '/some_addr', cancel: "Cancel"){ "content" }.should be_blank
19
+ end
20
+
21
+ it "should set method to post by default" do
22
+ helper.modal_form_widget(title: 'Title', button: 'Button', action: '/some_addr', cancel: "Cancel"){ "content" }[/_method/].should be_blank
23
+ end
24
+
25
+ it "should return blank if action isn't set" do
26
+ helper.modal_form_widget(title: 'Title', button: 'Button', method: :get, cancel: "Cancel"){ "content" }.should be_blank
27
+ end
28
+
29
+ it "should return blank if content isn't set" do
30
+ helper.modal_form_widget(title: 'Title', button: 'Button', method: :get, action: '/some_addr', cancel: "Cancel").should be_blank
31
+ end
32
+
33
+ it "should set cancel to default" do
34
+ helper.modal_form_widget(title: 'Title', method: :get, action: '/some_addr'){ "content" }[/#{ I18n.t("buttons.cancel") }/].should_not be_blank
35
+ end
36
+
37
+ it "should set button to default" do
38
+ helper.modal_form_widget(title: 'Title', method: :get, action: '/some_addr', cancel: "Cancel"){ "content" }[/#{ I18n.t("buttons.submit") }/].should_not be_blank
39
+ end
40
+ end
41
+
42
+ describe "modal view widget" do
43
+ it { should respond_to :modal_view_widget }
44
+
45
+ it "should provide proper html" do
46
+ target = "<div class=\"modal fade\" id=\"modal\"><header class=\"modal-header\"><button aria-hidden=\"true\" class=\"close\" data-dismiss=\"modal\" type=\"button\">&times;</button><h1>Title</h1></header><div class=\"modal-body\">content</div><div class=\"modal-footer\"><a href=\"#\" aria-hidden=\"true\" class=\"btn\" data-dismiss=\"modal\">Cancel</a><a href=\"/some_addr\" class=\"btn btn-primary\">Button</a></div></div>"
47
+ helper.modal_view_widget(title: 'Title', button: 'Button', href: '/some_addr', cancel: "Cancel"){ "content" }.should eq(target)
48
+ end
49
+
50
+ it "should return blank if title isn't set" do
51
+ helper.modal_view_widget(button: 'Button', href: '/some_addr', cancel: "Cancel"){ "content" }.should be_blank
52
+ end
53
+
54
+ it "should return blank if href isn't set" do
55
+ helper.modal_view_widget(title: 'Title', button: 'Button', cancel: "Cancel"){ "content" }.should be_blank
56
+ end
57
+
58
+ it "should return blank if content isn't set" do
59
+ helper.modal_view_widget(title: 'Title', button: 'Button', href: '/some_addr', cancel: "Cancel").should be_blank
60
+ end
61
+
62
+ it "should set cancel to default" do
63
+ helper.modal_view_widget(title: 'Title', href: '/some_addr'){ "content" }[/#{ I18n.t("buttons.cancel") }/].should_not be_blank
64
+ end
65
+
66
+ it "should set button to default" do
67
+ helper.modal_view_widget(title: 'Title', href: '/some_addr'){ "content" }[/#{ I18n.t("buttons.details") }/].should_not be_blank
68
+ end
69
+
70
+ it "should hide button if redirect is set to false" do
71
+ helper.modal_view_widget(title: 'Title', href: '/some_addr', redirect: false){ "content" }[/#{ I18n.t("buttons.details") }/].should be_blank
72
+ end
73
+ end
74
+ end
75
+ end
@@ -0,0 +1,14 @@
1
+ # This file is copied to spec/ when you run 'rails generate rspec:install'
2
+ ENV["RAILS_ENV"] ||= 'test'
3
+ require File.expand_path("../dummy/config/environment.rb", __FILE__)
4
+ require 'rspec/rails'
5
+
6
+ ENGINE_RAILS_ROOT=File.join(File.dirname(__FILE__), '../')
7
+
8
+ # Requires supporting ruby files with custom matchers and macros, etc,
9
+ # in spec/support/ and its subdirectories.
10
+ Dir[File.join(ENGINE_RAILS_ROOT, "spec/support/**/*.rb")].each { |f| require f }
11
+
12
+ RSpec.configure do |config|
13
+ config.use_transactional_fixtures = true
14
+ end
metadata ADDED
@@ -0,0 +1,356 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: rails-bootstrap-widgets
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ prerelease:
6
+ platform: ruby
7
+ authors:
8
+ - Andrew Kozin
9
+ autorequire:
10
+ bindir: bin
11
+ cert_chain: []
12
+ date: 2013-06-08 00:00:00.000000000 Z
13
+ dependencies:
14
+ - !ruby/object:Gem::Dependency
15
+ name: rails
16
+ requirement: !ruby/object:Gem::Requirement
17
+ none: false
18
+ requirements:
19
+ - - ~>
20
+ - !ruby/object:Gem::Version
21
+ version: 3.2.12
22
+ type: :runtime
23
+ prerelease: false
24
+ version_requirements: !ruby/object:Gem::Requirement
25
+ none: false
26
+ requirements:
27
+ - - ~>
28
+ - !ruby/object:Gem::Version
29
+ version: 3.2.12
30
+ - !ruby/object:Gem::Dependency
31
+ name: sanitize
32
+ requirement: !ruby/object:Gem::Requirement
33
+ none: false
34
+ requirements:
35
+ - - ! '>='
36
+ - !ruby/object:Gem::Version
37
+ version: '0'
38
+ type: :runtime
39
+ prerelease: false
40
+ version_requirements: !ruby/object:Gem::Requirement
41
+ none: false
42
+ requirements:
43
+ - - ! '>='
44
+ - !ruby/object:Gem::Version
45
+ version: '0'
46
+ - !ruby/object:Gem::Dependency
47
+ name: htmlentities
48
+ requirement: !ruby/object:Gem::Requirement
49
+ none: false
50
+ requirements:
51
+ - - ! '>='
52
+ - !ruby/object:Gem::Version
53
+ version: '0'
54
+ type: :runtime
55
+ prerelease: false
56
+ version_requirements: !ruby/object:Gem::Requirement
57
+ none: false
58
+ requirements:
59
+ - - ! '>='
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ - !ruby/object:Gem::Dependency
63
+ name: recaptcha
64
+ requirement: !ruby/object:Gem::Requirement
65
+ none: false
66
+ requirements:
67
+ - - ! '>='
68
+ - !ruby/object:Gem::Version
69
+ version: '0'
70
+ type: :runtime
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ none: false
74
+ requirements:
75
+ - - ! '>='
76
+ - !ruby/object:Gem::Version
77
+ version: '0'
78
+ - !ruby/object:Gem::Dependency
79
+ name: jquery-rails
80
+ requirement: !ruby/object:Gem::Requirement
81
+ none: false
82
+ requirements:
83
+ - - ! '>='
84
+ - !ruby/object:Gem::Version
85
+ version: '0'
86
+ type: :runtime
87
+ prerelease: false
88
+ version_requirements: !ruby/object:Gem::Requirement
89
+ none: false
90
+ requirements:
91
+ - - ! '>='
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ - !ruby/object:Gem::Dependency
95
+ name: sass-rails
96
+ requirement: !ruby/object:Gem::Requirement
97
+ none: false
98
+ requirements:
99
+ - - ! '>='
100
+ - !ruby/object:Gem::Version
101
+ version: '0'
102
+ type: :runtime
103
+ prerelease: false
104
+ version_requirements: !ruby/object:Gem::Requirement
105
+ none: false
106
+ requirements:
107
+ - - ! '>='
108
+ - !ruby/object:Gem::Version
109
+ version: '0'
110
+ - !ruby/object:Gem::Dependency
111
+ name: coffee-rails
112
+ requirement: !ruby/object:Gem::Requirement
113
+ none: false
114
+ requirements:
115
+ - - ! '>='
116
+ - !ruby/object:Gem::Version
117
+ version: '0'
118
+ type: :runtime
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ none: false
122
+ requirements:
123
+ - - ! '>='
124
+ - !ruby/object:Gem::Version
125
+ version: '0'
126
+ - !ruby/object:Gem::Dependency
127
+ name: uglifier
128
+ requirement: !ruby/object:Gem::Requirement
129
+ none: false
130
+ requirements:
131
+ - - ! '>='
132
+ - !ruby/object:Gem::Version
133
+ version: '0'
134
+ type: :runtime
135
+ prerelease: false
136
+ version_requirements: !ruby/object:Gem::Requirement
137
+ none: false
138
+ requirements:
139
+ - - ! '>='
140
+ - !ruby/object:Gem::Version
141
+ version: '0'
142
+ - !ruby/object:Gem::Dependency
143
+ name: bootstrap-sass
144
+ requirement: !ruby/object:Gem::Requirement
145
+ none: false
146
+ requirements:
147
+ - - ! '>='
148
+ - !ruby/object:Gem::Version
149
+ version: '0'
150
+ type: :runtime
151
+ prerelease: false
152
+ version_requirements: !ruby/object:Gem::Requirement
153
+ none: false
154
+ requirements:
155
+ - - ! '>='
156
+ - !ruby/object:Gem::Version
157
+ version: '0'
158
+ - !ruby/object:Gem::Dependency
159
+ name: will_paginate
160
+ requirement: !ruby/object:Gem::Requirement
161
+ none: false
162
+ requirements:
163
+ - - ! '>='
164
+ - !ruby/object:Gem::Version
165
+ version: '0'
166
+ type: :runtime
167
+ prerelease: false
168
+ version_requirements: !ruby/object:Gem::Requirement
169
+ none: false
170
+ requirements:
171
+ - - ! '>='
172
+ - !ruby/object:Gem::Version
173
+ version: '0'
174
+ - !ruby/object:Gem::Dependency
175
+ name: bootstrap-will_paginate
176
+ requirement: !ruby/object:Gem::Requirement
177
+ none: false
178
+ requirements:
179
+ - - ! '>='
180
+ - !ruby/object:Gem::Version
181
+ version: '0'
182
+ type: :runtime
183
+ prerelease: false
184
+ version_requirements: !ruby/object:Gem::Requirement
185
+ none: false
186
+ requirements:
187
+ - - ! '>='
188
+ - !ruby/object:Gem::Version
189
+ version: '0'
190
+ - !ruby/object:Gem::Dependency
191
+ name: sqlite3
192
+ requirement: !ruby/object:Gem::Requirement
193
+ none: false
194
+ requirements:
195
+ - - ! '>='
196
+ - !ruby/object:Gem::Version
197
+ version: '0'
198
+ type: :development
199
+ prerelease: false
200
+ version_requirements: !ruby/object:Gem::Requirement
201
+ none: false
202
+ requirements:
203
+ - - ! '>='
204
+ - !ruby/object:Gem::Version
205
+ version: '0'
206
+ - !ruby/object:Gem::Dependency
207
+ name: rspec-rails
208
+ requirement: !ruby/object:Gem::Requirement
209
+ none: false
210
+ requirements:
211
+ - - ~>
212
+ - !ruby/object:Gem::Version
213
+ version: 2.11.0
214
+ type: :development
215
+ prerelease: false
216
+ version_requirements: !ruby/object:Gem::Requirement
217
+ none: false
218
+ requirements:
219
+ - - ~>
220
+ - !ruby/object:Gem::Version
221
+ version: 2.11.0
222
+ - !ruby/object:Gem::Dependency
223
+ name: rails3-generators
224
+ requirement: !ruby/object:Gem::Requirement
225
+ none: false
226
+ requirements:
227
+ - - ! '>='
228
+ - !ruby/object:Gem::Version
229
+ version: '0'
230
+ type: :development
231
+ prerelease: false
232
+ version_requirements: !ruby/object:Gem::Requirement
233
+ none: false
234
+ requirements:
235
+ - - ! '>='
236
+ - !ruby/object:Gem::Version
237
+ version: '0'
238
+ description: Set of helpers that define widget methods for usage in a views.
239
+ email:
240
+ - andrew.kozin@gmail.com
241
+ executables: []
242
+ extensions: []
243
+ extra_rdoc_files: []
244
+ files:
245
+ - app/assets/javascripts/rails-bootstrap-widgets/application.js
246
+ - app/assets/javascripts/rails-bootstrap-widgets/filters.js.coffee
247
+ - app/assets/javascripts/rails-bootstrap-widgets/show_modal.js
248
+ - app/helpers/rails-bootstrap-widgets/application_helper.rb
249
+ - app/helpers/rails-bootstrap-widgets/filters_helper.rb
250
+ - app/helpers/rails-bootstrap-widgets/modal_helper.rb
251
+ - config/locales/en.yml
252
+ - config/locales/ru.yml
253
+ - lib/rails-bootstrap-widgets/engine.rb
254
+ - lib/rails-bootstrap-widgets/version.rb
255
+ - lib/rails-bootstrap-widgets.rb
256
+ - lib/tasks/rails-bootstrap-widgets_tasks.rake
257
+ - MIT-LICENSE
258
+ - Rakefile
259
+ - README.md
260
+ - spec/dummy/app/assets/javascripts/application.js
261
+ - spec/dummy/app/assets/stylesheets/application.css
262
+ - spec/dummy/app/controllers/application_controller.rb
263
+ - spec/dummy/app/helpers/application_helper.rb
264
+ - spec/dummy/app/views/layouts/application.html.erb
265
+ - spec/dummy/config/application.rb
266
+ - spec/dummy/config/boot.rb
267
+ - spec/dummy/config/database.yml
268
+ - spec/dummy/config/environment.rb
269
+ - spec/dummy/config/environments/development.rb
270
+ - spec/dummy/config/environments/production.rb
271
+ - spec/dummy/config/environments/test.rb
272
+ - spec/dummy/config/initializers/backtrace_silencers.rb
273
+ - spec/dummy/config/initializers/inflections.rb
274
+ - spec/dummy/config/initializers/mime_types.rb
275
+ - spec/dummy/config/initializers/secret_token.rb
276
+ - spec/dummy/config/initializers/session_store.rb
277
+ - spec/dummy/config/initializers/wrap_parameters.rb
278
+ - spec/dummy/config/locales/en.yml
279
+ - spec/dummy/config/routes.rb
280
+ - spec/dummy/config.ru
281
+ - spec/dummy/db/test.sqlite3
282
+ - spec/dummy/log/test.log
283
+ - spec/dummy/public/404.html
284
+ - spec/dummy/public/422.html
285
+ - spec/dummy/public/500.html
286
+ - spec/dummy/public/favicon.ico
287
+ - spec/dummy/Rakefile
288
+ - spec/dummy/README.rdoc
289
+ - spec/dummy/script/rails
290
+ - spec/helpers/rails-bootstrap-widgets/filters_helper_spec.rb
291
+ - spec/helpers/rails-bootstrap-widgets/modal_helper_spec.rb
292
+ - spec/spec_helper.rb
293
+ homepage: http://github.com/nepalez/rails-bootstrap-widgets
294
+ licenses: []
295
+ post_install_message:
296
+ rdoc_options: []
297
+ require_paths:
298
+ - lib
299
+ required_ruby_version: !ruby/object:Gem::Requirement
300
+ none: false
301
+ requirements:
302
+ - - ! '>='
303
+ - !ruby/object:Gem::Version
304
+ version: '0'
305
+ segments:
306
+ - 0
307
+ hash: -363547011
308
+ required_rubygems_version: !ruby/object:Gem::Requirement
309
+ none: false
310
+ requirements:
311
+ - - ! '>='
312
+ - !ruby/object:Gem::Version
313
+ version: '0'
314
+ segments:
315
+ - 0
316
+ hash: -363547011
317
+ requirements: []
318
+ rubyforge_project:
319
+ rubygems_version: 1.8.24
320
+ signing_key:
321
+ specification_version: 3
322
+ summary: Collection of widgets compatible with Bootstrap.
323
+ test_files:
324
+ - spec/dummy/app/assets/javascripts/application.js
325
+ - spec/dummy/app/assets/stylesheets/application.css
326
+ - spec/dummy/app/controllers/application_controller.rb
327
+ - spec/dummy/app/helpers/application_helper.rb
328
+ - spec/dummy/app/views/layouts/application.html.erb
329
+ - spec/dummy/config/application.rb
330
+ - spec/dummy/config/boot.rb
331
+ - spec/dummy/config/database.yml
332
+ - spec/dummy/config/environment.rb
333
+ - spec/dummy/config/environments/development.rb
334
+ - spec/dummy/config/environments/production.rb
335
+ - spec/dummy/config/environments/test.rb
336
+ - spec/dummy/config/initializers/backtrace_silencers.rb
337
+ - spec/dummy/config/initializers/inflections.rb
338
+ - spec/dummy/config/initializers/mime_types.rb
339
+ - spec/dummy/config/initializers/secret_token.rb
340
+ - spec/dummy/config/initializers/session_store.rb
341
+ - spec/dummy/config/initializers/wrap_parameters.rb
342
+ - spec/dummy/config/locales/en.yml
343
+ - spec/dummy/config/routes.rb
344
+ - spec/dummy/config.ru
345
+ - spec/dummy/db/test.sqlite3
346
+ - spec/dummy/log/test.log
347
+ - spec/dummy/public/404.html
348
+ - spec/dummy/public/422.html
349
+ - spec/dummy/public/500.html
350
+ - spec/dummy/public/favicon.ico
351
+ - spec/dummy/Rakefile
352
+ - spec/dummy/README.rdoc
353
+ - spec/dummy/script/rails
354
+ - spec/helpers/rails-bootstrap-widgets/filters_helper_spec.rb
355
+ - spec/helpers/rails-bootstrap-widgets/modal_helper_spec.rb
356
+ - spec/spec_helper.rb