datetime_picker_input 4.0.0 → 4.17.37
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CONTRIBUTING.md +7 -0
- data/Gemfile +1 -0
- data/{LICENSE → LICENSE.md} +0 -0
- data/README.md +57 -9
- data/app/inputs/date_time_picker_input.rb +7 -4
- data/datetime_picker_input.gemspec +2 -2
- data/lib/datetime_picker_input/version.rb +1 -1
- data/lib/generators/templates/inputs/date_time_picker_input.rb +3 -3
- data/spec/app/inputs/date_time_picker_input_spec.rb +36 -0
- data/spec/dummy/app/assets/stylesheets/application.scss +4 -0
- data/spec/dummy/app/controllers/appointments_controller.rb +30 -2
- data/spec/dummy/app/helpers/application_helper.rb +3 -0
- data/spec/dummy/app/views/appointments/_form.html.slim +6 -0
- data/spec/dummy/app/views/appointments/edit.html.slim +4 -0
- data/spec/dummy/app/views/appointments/index.html.slim +1 -1
- data/spec/dummy/app/views/appointments/new.html.slim +1 -3
- data/spec/dummy/config/routes.rb +1 -1
- data/spec/dummy/log/development.log +261 -3344
- data/spec/dummy/log/test.log +7259 -1819
- data/spec/feature_helper.rb +1 -0
- data/spec/features/datetime_picker_input_spec.rb +90 -7
- metadata +17 -14
- data/spec/dummy/db/development.sqlite3 +0 -0
- data/spec/dummy/db/test.sqlite3 +0 -0
data/spec/feature_helper.rb
CHANGED
@@ -1,12 +1,95 @@
|
|
1
1
|
require "feature_helper"
|
2
2
|
|
3
3
|
feature "datetime input", js: true do
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
4
|
+
let(:datetime_value) { Time.parse("2015-10-25 00:00:00") }
|
5
|
+
|
6
|
+
[
|
7
|
+
[
|
8
|
+
"default", # context
|
9
|
+
nil, # no server timezone
|
10
|
+
{ data: { date_format: "YYYY-MM-DD HH:mm:ss ZZ" } },
|
11
|
+
"%F %H:%M:%S %z", # date_format
|
12
|
+
],
|
13
|
+
|
14
|
+
[
|
15
|
+
"default with server tz", # context
|
16
|
+
'Central Time (US & Canada)',# server timezone does not matter
|
17
|
+
{ data: { date_format: "YYYY-MM-DD HH:mm:ss ZZ" } },
|
18
|
+
"%F %H:%M:%S %z", # date_format
|
19
|
+
],
|
20
|
+
|
21
|
+
[
|
22
|
+
"custom with tz", # context
|
23
|
+
nil, # no server timezone
|
24
|
+
{ data: { date_format: "DD.MM.YYYY hh:mm A ZZ" } },
|
25
|
+
"%d.%m.%Y %I:%M %p %z", # date_format
|
26
|
+
],
|
27
|
+
|
28
|
+
[
|
29
|
+
"custom with tz & server tz",# context
|
30
|
+
'Central Time (US & Canada)',# server timezone does not matter
|
31
|
+
{ data: { date_format: "DD.MM.YYYY hh:mm A ZZ" } },
|
32
|
+
"%d.%m.%Y %I:%M %p %z", # date_format
|
33
|
+
],
|
34
|
+
|
35
|
+
[
|
36
|
+
"custom no timezone", # context
|
37
|
+
TimeZone::Local.get().name, # server timezone required!
|
38
|
+
{ data: { date_format: "YYYY.MM.DD hh:mm A" } },
|
39
|
+
"%Y.%m.%d %I:%M %p", # date_format
|
40
|
+
],
|
41
|
+
|
42
|
+
].each do |context_name, server_timezone, input_html_options, date_format|
|
43
|
+
|
44
|
+
context context_name do
|
45
|
+
let(:date_format_output) { datetime_value.strftime(date_format) }
|
46
|
+
|
47
|
+
before do
|
48
|
+
Appointment.delete_all
|
49
|
+
allow_any_instance_of(ApplicationHelper).to receive(:input_html_options).and_return(input_html_options)
|
50
|
+
allow_any_instance_of(AppointmentsController).to receive(:current_timezone).and_return(server_timezone)
|
51
|
+
end
|
52
|
+
|
53
|
+
context 'create' do
|
54
|
+
|
55
|
+
before do
|
56
|
+
visit new_appointment_path
|
57
|
+
page.execute_script("$('input.date_time_picker').val('#{date_format_output}')")
|
58
|
+
page.find("body").click # blur
|
59
|
+
expect(find_field('Scheduled at').value).to eq(date_format_output)
|
60
|
+
end
|
61
|
+
|
62
|
+
scenario 'accepted form post' do
|
63
|
+
expect {
|
64
|
+
click_button 'Create Appointment'
|
65
|
+
}.to change {
|
66
|
+
Appointment.last.try(:scheduled_at)
|
67
|
+
}.to eq(datetime_value)
|
68
|
+
# value set in db must be correct
|
69
|
+
end
|
70
|
+
|
71
|
+
scenario 'rejected form post' do
|
72
|
+
allow_any_instance_of(Appointment).to receive(:save).and_return(false)
|
73
|
+
expect {
|
74
|
+
click_button 'Create Appointment'
|
75
|
+
}.not_to change {
|
76
|
+
Appointment.count
|
77
|
+
}
|
78
|
+
expect(find_field('Scheduled at').value).to eq(date_format_output)
|
79
|
+
# re-rendered input value should be identical to given value
|
80
|
+
end
|
81
|
+
end
|
82
|
+
|
83
|
+
context 'edit' do
|
84
|
+
let(:appointment) { Appointment.create(scheduled_at: datetime_value) }
|
85
|
+
|
86
|
+
scenario 'should convert raw_input_value to date_format_output' do
|
87
|
+
visit edit_appointment_path(appointment)
|
88
|
+
expect(find_field('Scheduled at').value).to eq(date_format_output)
|
89
|
+
expect(find_field('Scheduled at')[:value]).to eq(datetime_value.utc.strftime("%Y-%m-%d %H:%M:%S %z"))
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
|
11
94
|
end
|
12
95
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: datetime_picker_input
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 4.
|
4
|
+
version: 4.17.37
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Juanito
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2015-
|
12
|
+
date: 2015-10-26 00:00:00.000000000 Z
|
13
13
|
dependencies:
|
14
14
|
- !ruby/object:Gem::Dependency
|
15
15
|
name: bootstrap3-datetimepicker-rails
|
@@ -17,28 +17,28 @@ dependencies:
|
|
17
17
|
requirements:
|
18
18
|
- - "~>"
|
19
19
|
- !ruby/object:Gem::Version
|
20
|
-
version: 4.
|
20
|
+
version: 4.17.37
|
21
21
|
type: :runtime
|
22
22
|
prerelease: false
|
23
23
|
version_requirements: !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
25
|
- - "~>"
|
26
26
|
- !ruby/object:Gem::Version
|
27
|
-
version: 4.
|
27
|
+
version: 4.17.37
|
28
28
|
- !ruby/object:Gem::Dependency
|
29
29
|
name: momentjs-rails
|
30
30
|
requirement: !ruby/object:Gem::Requirement
|
31
31
|
requirements:
|
32
|
-
- - "
|
32
|
+
- - "~>"
|
33
33
|
- !ruby/object:Gem::Version
|
34
|
-
version: 2.
|
34
|
+
version: 2.10.6
|
35
35
|
type: :runtime
|
36
36
|
prerelease: false
|
37
37
|
version_requirements: !ruby/object:Gem::Requirement
|
38
38
|
requirements:
|
39
|
-
- - "
|
39
|
+
- - "~>"
|
40
40
|
- !ruby/object:Gem::Version
|
41
|
-
version: 2.
|
41
|
+
version: 2.10.6
|
42
42
|
description: Datetime picker wrapper of https://github.com/TrevorS/bootstrap3-datetimepicker-rails,
|
43
43
|
for use with simple_form on Rails 4+.
|
44
44
|
email:
|
@@ -49,8 +49,9 @@ extra_rdoc_files: []
|
|
49
49
|
files:
|
50
50
|
- ".gitignore"
|
51
51
|
- ".travis.yml"
|
52
|
+
- CONTRIBUTING.md
|
52
53
|
- Gemfile
|
53
|
-
- LICENSE
|
54
|
+
- LICENSE.md
|
54
55
|
- README.md
|
55
56
|
- Rakefile
|
56
57
|
- app/inputs/date_time_picker_input.rb
|
@@ -59,6 +60,7 @@ files:
|
|
59
60
|
- lib/datetime_picker_input/version.rb
|
60
61
|
- lib/generators/datetime_picker_input.rb/install_generator.rb
|
61
62
|
- lib/generators/templates/inputs/date_time_picker_input.rb
|
63
|
+
- spec/app/inputs/date_time_picker_input_spec.rb
|
62
64
|
- spec/dummy/README.rdoc
|
63
65
|
- spec/dummy/Rakefile
|
64
66
|
- spec/dummy/app/assets/images/.keep
|
@@ -72,6 +74,8 @@ files:
|
|
72
74
|
- spec/dummy/app/models/.keep
|
73
75
|
- spec/dummy/app/models/appointment.rb
|
74
76
|
- spec/dummy/app/models/concerns/.keep
|
77
|
+
- spec/dummy/app/views/appointments/_form.html.slim
|
78
|
+
- spec/dummy/app/views/appointments/edit.html.slim
|
75
79
|
- spec/dummy/app/views/appointments/index.html.slim
|
76
80
|
- spec/dummy/app/views/appointments/new.html.slim
|
77
81
|
- spec/dummy/app/views/layouts/application.html.slim
|
@@ -100,10 +104,8 @@ files:
|
|
100
104
|
- spec/dummy/config/locales/simple_form.en.yml
|
101
105
|
- spec/dummy/config/routes.rb
|
102
106
|
- spec/dummy/config/secrets.yml
|
103
|
-
- spec/dummy/db/development.sqlite3
|
104
107
|
- spec/dummy/db/migrate/20150224051923_create_appointments.rb
|
105
108
|
- spec/dummy/db/schema.rb
|
106
|
-
- spec/dummy/db/test.sqlite3
|
107
109
|
- spec/dummy/lib/assets/.keep
|
108
110
|
- spec/dummy/lib/templates/erb/scaffold/_form.html.erb
|
109
111
|
- spec/dummy/log/.keep
|
@@ -138,18 +140,21 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
138
140
|
version: '0'
|
139
141
|
requirements: []
|
140
142
|
rubyforge_project:
|
141
|
-
rubygems_version: 2.4.5
|
143
|
+
rubygems_version: 2.4.5.1
|
142
144
|
signing_key:
|
143
145
|
specification_version: 4
|
144
146
|
summary: Datetime picker wrapper of https://github.com/TrevorS/bootstrap3-datetimepicker-rails,
|
145
147
|
for use with simple_form on Rails 4+.
|
146
148
|
test_files:
|
149
|
+
- spec/app/inputs/date_time_picker_input_spec.rb
|
147
150
|
- spec/dummy/app/assets/javascripts/application.js
|
148
151
|
- spec/dummy/app/assets/stylesheets/application.scss
|
149
152
|
- spec/dummy/app/controllers/application_controller.rb
|
150
153
|
- spec/dummy/app/controllers/appointments_controller.rb
|
151
154
|
- spec/dummy/app/helpers/application_helper.rb
|
152
155
|
- spec/dummy/app/models/appointment.rb
|
156
|
+
- spec/dummy/app/views/appointments/_form.html.slim
|
157
|
+
- spec/dummy/app/views/appointments/edit.html.slim
|
153
158
|
- spec/dummy/app/views/appointments/index.html.slim
|
154
159
|
- spec/dummy/app/views/appointments/new.html.slim
|
155
160
|
- spec/dummy/app/views/layouts/application.html.slim
|
@@ -178,10 +183,8 @@ test_files:
|
|
178
183
|
- spec/dummy/config/routes.rb
|
179
184
|
- spec/dummy/config/secrets.yml
|
180
185
|
- spec/dummy/config.ru
|
181
|
-
- spec/dummy/db/development.sqlite3
|
182
186
|
- spec/dummy/db/migrate/20150224051923_create_appointments.rb
|
183
187
|
- spec/dummy/db/schema.rb
|
184
|
-
- spec/dummy/db/test.sqlite3
|
185
188
|
- spec/dummy/lib/templates/erb/scaffold/_form.html.erb
|
186
189
|
- spec/dummy/log/development.log
|
187
190
|
- spec/dummy/log/test.log
|
Binary file
|
data/spec/dummy/db/test.sqlite3
DELETED
Binary file
|