releaf-core 1.1.4 → 1.1.5

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: f146db6882b2fc3d7df0e83bf19ede7412ddcc16
4
- data.tar.gz: 80f33cde890701059860e44c7be419809fc4b2ab
3
+ metadata.gz: 208fad5bcbaa64e78d3b0881d3efc6504138dcb4
4
+ data.tar.gz: 0bfd9a1dfc5617558e882595e771de9be5f13e4b
5
5
  SHA512:
6
- metadata.gz: 65b010d4b06dca9e83012e5078c75e4c61daeb4eea9b45f9887568a044a32d6ad98514097103e9890c916a4d7ec97767fa44a4dbcc535592c7eda89c65fffe40
7
- data.tar.gz: dcc3b2485c2c1514e0b12769d1c62dd2666cc2af3de7b621842ffe96e1c13697c4ec8edb96c5a04f771e736fd6d649b9914099559c6e4d487d2d217a76bd58dc
6
+ metadata.gz: 32621f06c94c10d0eb82dfce9b746141d8c350791f4adb1c4dbb123cba2bcd349445b8b63daf540d39d9eea6f143890187a1ebf0b98cf03199f29620ec0982a1
7
+ data.tar.gz: a2192cc44b4bb5feda3efa7345e93d8d5e63a191b9143fd20b31aee7e8027b6113dbc2e0728aaca76c2a26ad5903f213284aa96855455522ff1e51e9c9220ae5
@@ -156,12 +156,13 @@ class Releaf::Builders::TableBuilder
156
156
 
157
157
  def format_date_content(resource, column)
158
158
  value = column_value(resource, column)
159
- I18n.l(value, format: :default, default: '%Y-%m-%d') unless value.nil?
159
+ I18n.l(value, format: :default) unless value.nil?
160
160
  end
161
161
 
162
162
  def format_datetime_content(resource, column)
163
163
  value = column_value(resource, column)
164
- I18n.l(value, format: :default, default: '%Y-%m-%d %H:%M:%S') unless value.nil?
164
+ format = Releaf::Builders::Utilities::DateFields.date_or_time_default_format(:datetime)
165
+ I18n.l(value, format: format) unless value.nil?
165
166
  end
166
167
 
167
168
  def format_association_content(resource, column)
@@ -72,7 +72,7 @@ module Releaf::Builders::Utilities
72
72
  if type == :time
73
73
  value.strftime(default_format)
74
74
  else
75
- I18n.l(value, default: default_format)
75
+ I18n.l(value, format: default_format)
76
76
  end
77
77
  end
78
78
 
@@ -407,7 +407,7 @@ describe Releaf::Builders::TableBuilder, type: :class do
407
407
  allow(subject).to receive(:column_value).with(resource, :birth_date)
408
408
  .and_return(value)
409
409
 
410
- expect(I18n).to receive(:l).with(value, format: :default, default: "%Y-%m-%d")
410
+ expect(I18n).to receive(:l).with(value, format: :default)
411
411
  .and_call_original
412
412
 
413
413
  expect(subject.format_date_content(resource, :birth_date)).to eq("2012-12-29")
@@ -420,7 +420,7 @@ describe Releaf::Builders::TableBuilder, type: :class do
420
420
  allow(subject).to receive(:column_value).with(resource, :created_at)
421
421
  .and_return(value)
422
422
 
423
- allow(I18n).to receive(:l).with(value, format: :default, default: "%Y-%m-%d %H:%M:%S")
423
+ allow(I18n).to receive(:l).with(value, format: "%Y-%m-%d %H:%M")
424
424
  .and_return("2012-12-29 17:12:07")
425
425
 
426
426
  expect(subject.format_datetime_content(resource, :created_at)).to eq("2012-12-29 17:12:07")
@@ -48,13 +48,13 @@ describe Releaf::Builders::Utilities::DateFields do
48
48
 
49
49
  allow(described_class).to receive(:date_or_time_default_format).with(:date).and_return("_format_")
50
50
  allow(described_class).to receive(:normalize_date_or_time_value).with(value, :date).and_return(time)
51
- allow(I18n).to receive(:l).with(time, default: "_format_").and_return("x")
51
+ allow(I18n).to receive(:l).with(time, format: "_format_").and_return("x")
52
52
  expect(described_class.format_date_or_time_value(value, :date)).to eq("x")
53
53
 
54
54
 
55
55
  allow(described_class).to receive(:date_or_time_default_format).with(:datetime).and_return("_format_")
56
56
  allow(described_class).to receive(:normalize_date_or_time_value).with(value, :datetime).and_return(time)
57
- allow(I18n).to receive(:l).with(time, default: "_format_").and_return("y")
57
+ allow(I18n).to receive(:l).with(time, format: "_format_").and_return("y")
58
58
  expect(described_class.format_date_or_time_value(value, :datetime)).to eq("y")
59
59
  end
60
60
  end
@@ -139,4 +139,48 @@ feature "Base controller edit", js: true do
139
139
  expect( new_book.chapters.count ).to eq 1
140
140
  expect( new_book.chapters.first.title ).to eq "Chapter 1"
141
141
  end
142
+
143
+ scenario "using datetime picker widget" do
144
+ visit new_admin_book_path
145
+
146
+ create_resource do
147
+ fill_in "Title", with: "Mustard and Margarine"
148
+ expect(page).to have_css('.field.type-datetime[data-name="published_at"] input.hasDatepicker')
149
+ expect(find_field('Published at').value).to eq ''
150
+ expect(page.document).to have_no_css '#ui-datepicker-div'
151
+ find('label', text: 'Published at').click
152
+ within page.document.find('#ui-datepicker-div') do
153
+ find('.ui-datepicker-month option', text: 'Apr').select_option
154
+ find('.ui-datepicker-year option', text: '2018').select_option
155
+ date_cell_selector = '.ui-datepicker-calendar tbody td[data-month="3"][data-year="2018"]'
156
+ find(date_cell_selector, text: '20').click
157
+ expect(page).to have_css("#{date_cell_selector}.ui-datepicker-current-day", text: '20')
158
+
159
+ find('.ui_tpicker_hour select option', text: '23').select_option
160
+ find('.ui_tpicker_minute select option', text: '45').select_option
161
+ expect(page).to have_no_css('.ui_tpicker_second select')
162
+ expect(page).to have_no_css('.ui_tpicker_millisec select')
163
+ expect(page).to have_no_css('.ui_tpicker_timezone select')
164
+ click_on 'Done'
165
+ end
166
+ expect(page.document).to have_no_css '#ui-datepicker-div'
167
+ expect(find_field('Published at').value).to eq '2018-04-20 23:45'
168
+ end
169
+
170
+ visit admin_books_path
171
+ expect(page).to have_css 'tr', text: /\AMustard and Margarine No 2018-04-20 23:45\z/
172
+ click_on "Mustard and Margarine"
173
+ expect(find_field('Published at').value).to eq '2018-04-20 23:45'
174
+ find('label', text: 'Published at').click
175
+ within page.document.find('#ui-datepicker-div') do
176
+ expect(find('select.ui-datepicker-month option:checked').text).to eq 'Apr'
177
+ expect(find('select.ui-datepicker-year option:checked').text).to eq '2018'
178
+ expect(page).to have_css('.ui-datepicker-calendar tbody td[data-month="3"][data-year="2018"].ui-datepicker-current-day', text: '20')
179
+
180
+ expect(find('.ui_tpicker_hour select option:checked').text).to eq '23'
181
+ expect(find('.ui_tpicker_minute select option:checked').text).to eq '45'
182
+ end
183
+
184
+ end
185
+
142
186
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: releaf-core
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.1.4
4
+ version: 1.1.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - CubeSystems