date-input-rails 0.0.2 → 0.0.3
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/lib/date-input-rails.rb +10 -1
- data/spec/helpers/date_field_helper_spec.rb +37 -0
- data/spec/internal/log/test.log +144 -0
- metadata +6 -4
data/lib/date-input-rails.rb
CHANGED
@@ -15,10 +15,19 @@ module ActionView
|
|
15
15
|
module Helpers
|
16
16
|
module FormHelper
|
17
17
|
def date_field(object_name, method, options = {})
|
18
|
-
InstanceTag.new(object_name, method, self, options.delete(:object)).
|
18
|
+
InstanceTag.new(object_name, method, self, options.delete(:object)).to_date_field_tag(options)
|
19
19
|
end unless instance_methods.include?(:date_field)
|
20
20
|
end
|
21
21
|
|
22
|
+
class InstanceTag
|
23
|
+
def to_date_field_tag(options = {})
|
24
|
+
options = options.stringify_keys
|
25
|
+
options["value"] = options.fetch("value") { value(object).try(:to_date) }
|
26
|
+
options["size"] = nil
|
27
|
+
to_input_field_tag("date", options)
|
28
|
+
end
|
29
|
+
end if defined?(InstanceTag)
|
30
|
+
|
22
31
|
# http://blog.lrdesign.com/2011/04/extending-form_for-in-rails-3-with-your-own-methods/
|
23
32
|
class FormBuilder
|
24
33
|
def date_field(method, options = {})
|
@@ -0,0 +1,37 @@
|
|
1
|
+
require "spec_helper"
|
2
|
+
|
3
|
+
describe ActionView::Helpers::FormHelper do
|
4
|
+
describe "#date_field" do
|
5
|
+
it "returns HTML for a date input" do
|
6
|
+
assign(:post, double(:written_on => Date.new(2004, 6, 15)))
|
7
|
+
expected = %{<input id="post_written_on" name="post[written_on]" type="date" value="2004-06-15" />}
|
8
|
+
assert_dom_equal(expected, helper.date_field("post", "written_on"))
|
9
|
+
end
|
10
|
+
|
11
|
+
it "converts the value to a date using #to_date" do
|
12
|
+
assign(:post, double(:written_on => double(:to_date => Date.new(2004, 6, 15))))
|
13
|
+
expected = %{<input id="post_written_on" name="post[written_on]" type="date" value="2004-06-15" />}
|
14
|
+
assert_dom_equal(expected, helper.date_field("post", "written_on"))
|
15
|
+
end
|
16
|
+
|
17
|
+
it "omits a value when it is nil" do
|
18
|
+
assign(:post, double(:written_on => nil))
|
19
|
+
expected = %{<input id="post_written_on" name="post[written_on]" type="date" />}
|
20
|
+
assert_dom_equal(expected, helper.date_field("post", "written_on"))
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe ActionView::Helpers::FormTagHelper do
|
26
|
+
describe "#date_field_tag" do
|
27
|
+
it "returns HTML for a date input" do
|
28
|
+
expected = %{<input id="written_on" name="written_on" type="date" value="2004-06-15" />}
|
29
|
+
assert_dom_equal(expected, helper.date_field_tag("written_on", Date.new(2004, 6, 15)))
|
30
|
+
end
|
31
|
+
|
32
|
+
it "omits a value when it is nil" do
|
33
|
+
expected = %{<input id="written_on" name="written_on" type="date" />}
|
34
|
+
assert_dom_equal(expected, helper.date_field_tag("written_on"))
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
data/spec/internal/log/test.log
CHANGED
@@ -1396,3 +1396,147 @@ Processing by TestModelsController#create as HTML
|
|
1396
1396
|
Parameters: {"utf8"=>"✓", "authenticity_token"=>"0NbIMp9TOwD8SavjO/m67+J5DttTgK4dm8iAARRt79c=", "date"=>"2012-10-28", "commit"=>"Submit"}
|
1397
1397
|
Rendered test_models/test.html.erb (1.1ms)
|
1398
1398
|
Completed 200 OK in 2ms (Views: 1.6ms)
|
1399
|
+
Started GET "/test" for 127.0.0.1 at 2013-01-10 13:28:32 -0800
|
1400
|
+
Processing by TestModelsController#test as HTML
|
1401
|
+
Rendered test_models/test.html.erb (6.0ms)
|
1402
|
+
Completed 200 OK in 28ms (Views: 27.6ms)
|
1403
|
+
Started GET "/assets/application.css" for 127.0.0.1 at 2013-01-10 13:28:32 -0800
|
1404
|
+
Served asset /application.css - 200 OK (49ms)
|
1405
|
+
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-10 13:28:32 -0800
|
1406
|
+
Served asset /application.js - 200 OK (178ms)
|
1407
|
+
Started GET "/test?date=2012-10-28&commit=Submit" for 127.0.0.1 at 2013-01-10 13:28:33 -0800
|
1408
|
+
Processing by TestModelsController#test as HTML
|
1409
|
+
Parameters: {"date"=>"2012-10-28", "commit"=>"Submit"}
|
1410
|
+
Rendered test_models/test.html.erb (0.8ms)
|
1411
|
+
Completed 200 OK in 1ms (Views: 1.3ms)
|
1412
|
+
Started GET "/test" for 127.0.0.1 at 2013-01-10 13:28:39 -0800
|
1413
|
+
Processing by TestModelsController#test as HTML
|
1414
|
+
Rendered test_models/test.html.erb (14.2ms)
|
1415
|
+
Completed 200 OK in 16ms (Views: 15.5ms)
|
1416
|
+
Started GET "/assets/application.css" for 127.0.0.1 at 2013-01-10 13:28:40 -0800
|
1417
|
+
Served asset /application.css - 200 OK (0ms)
|
1418
|
+
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-10 13:28:40 -0800
|
1419
|
+
Served asset /application.js - 200 OK (0ms)
|
1420
|
+
Started GET "/assets/jquery-ui/ui-bg_flat_75_ffffff_40x100.png" for 127.0.0.1 at 2013-01-10 13:28:41 -0800
|
1421
|
+
Served asset /jquery-ui/ui-bg_flat_75_ffffff_40x100.png - 200 OK (3ms)
|
1422
|
+
Started GET "/assets/jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png" for 127.0.0.1 at 2013-01-10 13:28:41 -0800
|
1423
|
+
Served asset /jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png - 200 OK (2ms)
|
1424
|
+
Started GET "/assets/jquery-ui/ui-icons_222222_256x240.png" for 127.0.0.1 at 2013-01-10 13:28:41 -0800
|
1425
|
+
Served asset /jquery-ui/ui-icons_222222_256x240.png - 200 OK (2ms)
|
1426
|
+
Started GET "/assets/jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png" for 127.0.0.1 at 2013-01-10 13:28:41 -0800
|
1427
|
+
Served asset /jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png - 200 OK (48ms)
|
1428
|
+
Started GET "/assets/jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png" for 127.0.0.1 at 2013-01-10 13:28:41 -0800
|
1429
|
+
Served asset /jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png - 200 OK (2ms)
|
1430
|
+
Started GET "/assets/jquery-ui/ui-bg_glass_65_ffffff_1x400.png" for 127.0.0.1 at 2013-01-10 13:28:41 -0800
|
1431
|
+
Served asset /jquery-ui/ui-bg_glass_65_ffffff_1x400.png - 200 OK (2ms)
|
1432
|
+
Started GET "/test?date=2012-10-28&commit=Submit" for 127.0.0.1 at 2013-01-10 13:28:41 -0800
|
1433
|
+
Processing by TestModelsController#test as HTML
|
1434
|
+
Parameters: {"date"=>"2012-10-28", "commit"=>"Submit"}
|
1435
|
+
Rendered test_models/test.html.erb (0.7ms)
|
1436
|
+
Completed 200 OK in 1ms (Views: 1.2ms)
|
1437
|
+
Started GET "/test_models/new" for 127.0.0.1 at 2013-01-10 13:28:41 -0800
|
1438
|
+
Processing by TestModelsController#new as HTML
|
1439
|
+
Rendered test_models/builder_test.html.erb (3.4ms)
|
1440
|
+
Completed 200 OK in 5ms (Views: 5.0ms)
|
1441
|
+
Started GET "/assets/application.css" for 127.0.0.1 at 2013-01-10 13:28:41 -0800
|
1442
|
+
Served asset /application.css - 304 Not Modified (0ms)
|
1443
|
+
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-10 13:28:41 -0800
|
1444
|
+
Served asset /application.js - 304 Not Modified (0ms)
|
1445
|
+
Started POST "/test_models" for 127.0.0.1 at 2013-01-10 13:28:42 -0800
|
1446
|
+
Processing by TestModelsController#create as HTML
|
1447
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"+Q6av6G6ZME9RpSzzlnWJzhXNK43ijzJwbnRjrLQ8g4=", "date"=>"2012-10-28", "commit"=>"Submit"}
|
1448
|
+
Rendered test_models/test.html.erb (0.7ms)
|
1449
|
+
Completed 200 OK in 1ms (Views: 1.2ms)
|
1450
|
+
Started GET "/assets/application.css" for 127.0.0.1 at 2013-01-10 13:28:42 -0800
|
1451
|
+
Served asset /application.css - 304 Not Modified (0ms)
|
1452
|
+
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-10 13:28:42 -0800
|
1453
|
+
Served asset /application.js - 304 Not Modified (0ms)
|
1454
|
+
Started GET "/test_models/new" for 127.0.0.1 at 2013-01-10 13:28:42 -0800
|
1455
|
+
Processing by TestModelsController#new as HTML
|
1456
|
+
Rendered test_models/builder_test.html.erb (2.3ms)
|
1457
|
+
Completed 200 OK in 3ms (Views: 3.0ms)
|
1458
|
+
Started POST "/test_models" for 127.0.0.1 at 2013-01-10 13:28:43 -0800
|
1459
|
+
Processing by TestModelsController#create as HTML
|
1460
|
+
Parameters: {"utf8"=>"✓", "authenticity_token"=>"vL/aL1mHUqUQ5j6mNPZlhngOfFYEabdJVaDN+9y0LtI=", "date"=>"2012-10-28", "commit"=>"Submit"}
|
1461
|
+
Rendered test_models/test.html.erb (0.8ms)
|
1462
|
+
Completed 200 OK in 1ms (Views: 1.3ms)
|
1463
|
+
Started GET "/test" for 127.0.0.1 at 2013-01-10 13:30:33 -0800
|
1464
|
+
Processing by TestModelsController#test as HTML
|
1465
|
+
Rendered test_models/test.html.erb (4.2ms)
|
1466
|
+
Completed 200 OK in 16ms (Views: 15.5ms)
|
1467
|
+
Started GET "/assets/application.css" for 127.0.0.1 at 2013-01-10 13:30:33 -0800
|
1468
|
+
Compiled jquery.ui.core.css (1ms) (pid 30292)
|
1469
|
+
Compiled jquery.ui.theme.css (7ms) (pid 30292)
|
1470
|
+
Compiled jquery.ui.datepicker.css (47ms) (pid 30292)
|
1471
|
+
Compiled application.css (55ms) (pid 30292)
|
1472
|
+
Served asset /application.css - 200 OK (67ms)
|
1473
|
+
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-10 13:30:33 -0800
|
1474
|
+
Compiled jquery.ui.core.js (1ms) (pid 30292)
|
1475
|
+
Compiled jquery.ui.datepicker.js (8ms) (pid 30292)
|
1476
|
+
Compiled date-input-polyfill.js (15ms) (pid 30292)
|
1477
|
+
Compiled application.js (22ms) (pid 30292)
|
1478
|
+
Served asset /application.js - 200 OK (69ms)
|
1479
|
+
Started GET "/test?date=2012-10-28&commit=Submit" for 127.0.0.1 at 2013-01-10 13:30:33 -0800
|
1480
|
+
Processing by TestModelsController#test as HTML
|
1481
|
+
Parameters: {"date"=>"2012-10-28", "commit"=>"Submit"}
|
1482
|
+
Rendered test_models/test.html.erb (0.8ms)
|
1483
|
+
Completed 200 OK in 1ms (Views: 1.2ms)
|
1484
|
+
Started GET "/test" for 127.0.0.1 at 2013-01-10 13:30:37 -0800
|
1485
|
+
Processing by TestModelsController#test as HTML
|
1486
|
+
Rendered test_models/test.html.erb (1.7ms)
|
1487
|
+
Completed 200 OK in 3ms (Views: 2.7ms)
|
1488
|
+
Started GET "/assets/application.css" for 127.0.0.1 at 2013-01-10 13:30:37 -0800
|
1489
|
+
Served asset /application.css - 200 OK (0ms)
|
1490
|
+
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-10 13:30:37 -0800
|
1491
|
+
Served asset /application.js - 200 OK (0ms)
|
1492
|
+
Started GET "/assets/jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png" for 127.0.0.1 at 2013-01-10 13:30:38 -0800
|
1493
|
+
Served asset /jquery-ui/ui-bg_highlight-soft_75_cccccc_1x100.png - 200 OK (23ms)
|
1494
|
+
Started GET "/assets/jquery-ui/ui-bg_flat_75_ffffff_40x100.png" for 127.0.0.1 at 2013-01-10 13:30:38 -0800
|
1495
|
+
Served asset /jquery-ui/ui-bg_flat_75_ffffff_40x100.png - 200 OK (7ms)
|
1496
|
+
Started GET "/assets/jquery-ui/ui-icons_222222_256x240.png" for 127.0.0.1 at 2013-01-10 13:30:38 -0800
|
1497
|
+
Served asset /jquery-ui/ui-icons_222222_256x240.png - 200 OK (6ms)
|
1498
|
+
Started GET "/assets/jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png" for 127.0.0.1 at 2013-01-10 13:30:38 -0800
|
1499
|
+
Served asset /jquery-ui/ui-bg_glass_75_e6e6e6_1x400.png - 200 OK (47ms)
|
1500
|
+
Started GET "/assets/jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png" for 127.0.0.1 at 2013-01-10 13:30:38 -0800
|
1501
|
+
Served asset /jquery-ui/ui-bg_glass_55_fbf9ee_1x400.png - 200 OK (7ms)
|
1502
|
+
Started GET "/assets/jquery-ui/ui-bg_glass_65_ffffff_1x400.png" for 127.0.0.1 at 2013-01-10 13:30:38 -0800
|
1503
|
+
Served asset /jquery-ui/ui-bg_glass_65_ffffff_1x400.png - 200 OK (6ms)
|
1504
|
+
Started GET "/test?date=2012-10-28&commit=Submit" for 127.0.0.1 at 2013-01-10 13:30:38 -0800
|
1505
|
+
Processing by TestModelsController#test as HTML
|
1506
|
+
Parameters: {"date"=>"2012-10-28", "commit"=>"Submit"}
|
1507
|
+
Rendered test_models/test.html.erb (0.8ms)
|
1508
|
+
Completed 200 OK in 1ms (Views: 1.3ms)
|
1509
|
+
Started GET "/test_models/new" for 127.0.0.1 at 2013-01-10 13:30:39 -0800
|
1510
|
+
Processing by TestModelsController#new as HTML
|
1511
|
+
Rendered test_models/builder_test.html.erb (3.0ms)
|
1512
|
+
Completed 200 OK in 5ms (Views: 5.0ms)
|
1513
|
+
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-10 13:30:39 -0800
|
1514
|
+
Served asset /application.js - 304 Not Modified (0ms)
|
1515
|
+
Started GET "/assets/application.css" for 127.0.0.1 at 2013-01-10 13:30:39 -0800
|
1516
|
+
Served asset /application.css - 304 Not Modified (0ms)
|
1517
|
+
Started POST "/test_models" for 127.0.0.1 at 2013-01-10 13:30:40 -0800
|
1518
|
+
Processing by TestModelsController#create as HTML
|
1519
|
+
Parameters: {"utf8"=>"✓", "date"=>"2012-10-28", "commit"=>"Submit"}
|
1520
|
+
Rendered test_models/test.html.erb (0.8ms)
|
1521
|
+
Completed 200 OK in 1ms (Views: 1.2ms)
|
1522
|
+
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-10 13:30:40 -0800
|
1523
|
+
Served asset /application.js - 304 Not Modified (0ms)
|
1524
|
+
Started GET "/assets/application.css" for 127.0.0.1 at 2013-01-10 13:30:40 -0800
|
1525
|
+
Served asset /application.css - 304 Not Modified (0ms)
|
1526
|
+
Started GET "/test_models/new" for 127.0.0.1 at 2013-01-10 13:30:40 -0800
|
1527
|
+
Processing by TestModelsController#new as HTML
|
1528
|
+
Rendered test_models/builder_test.html.erb (1.4ms)
|
1529
|
+
Completed 200 OK in 2ms (Views: 1.9ms)
|
1530
|
+
Started GET "/assets/application.css" for 127.0.0.1 at 2013-01-10 13:30:40 -0800
|
1531
|
+
Served asset /application.css - 304 Not Modified (0ms)
|
1532
|
+
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-10 13:30:40 -0800
|
1533
|
+
Served asset /application.js - 304 Not Modified (0ms)
|
1534
|
+
Started POST "/test_models" for 127.0.0.1 at 2013-01-10 13:30:41 -0800
|
1535
|
+
Processing by TestModelsController#create as HTML
|
1536
|
+
Parameters: {"utf8"=>"✓", "date"=>"2012-10-28", "commit"=>"Submit"}
|
1537
|
+
Rendered test_models/test.html.erb (1.1ms)
|
1538
|
+
Completed 200 OK in 2ms (Views: 1.7ms)
|
1539
|
+
Started GET "/assets/application.css" for 127.0.0.1 at 2013-01-10 13:30:41 -0800
|
1540
|
+
Served asset /application.css - 304 Not Modified (0ms)
|
1541
|
+
Started GET "/assets/application.js" for 127.0.0.1 at 2013-01-10 13:30:41 -0800
|
1542
|
+
Served asset /application.js - 304 Not Modified (0ms)
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: date-input-rails
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
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:
|
12
|
+
date: 2013-01-10 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: rails
|
@@ -184,6 +184,7 @@ files:
|
|
184
184
|
- Rakefile
|
185
185
|
- README.md
|
186
186
|
- spec/features/date_input_spec.rb
|
187
|
+
- spec/helpers/date_field_helper_spec.rb
|
187
188
|
- spec/internal/app/assets/javascripts/application.js
|
188
189
|
- spec/internal/app/assets/stylesheets/application.css
|
189
190
|
- spec/internal/app/controllers/test_models_controller.rb
|
@@ -208,7 +209,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
208
209
|
version: '0'
|
209
210
|
segments:
|
210
211
|
- 0
|
211
|
-
hash:
|
212
|
+
hash: 376516012887663096
|
212
213
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
213
214
|
none: false
|
214
215
|
requirements:
|
@@ -217,7 +218,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
217
218
|
version: '0'
|
218
219
|
segments:
|
219
220
|
- 0
|
220
|
-
hash:
|
221
|
+
hash: 376516012887663096
|
221
222
|
requirements: []
|
222
223
|
rubyforge_project:
|
223
224
|
rubygems_version: 1.8.24
|
@@ -226,6 +227,7 @@ specification_version: 3
|
|
226
227
|
summary: Rails support for <input type='date'> with a jQuery UI datepicker polyfill
|
227
228
|
test_files:
|
228
229
|
- spec/features/date_input_spec.rb
|
230
|
+
- spec/helpers/date_field_helper_spec.rb
|
229
231
|
- spec/internal/app/assets/javascripts/application.js
|
230
232
|
- spec/internal/app/assets/stylesheets/application.css
|
231
233
|
- spec/internal/app/controllers/test_models_controller.rb
|