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 +4 -4
- data/app/builders/releaf/builders/table_builder.rb +3 -2
- data/app/builders/releaf/builders/utilities/date_fields.rb +1 -1
- data/spec/builders/releaf/builders/table_builder_spec.rb +2 -2
- data/spec/builders/releaf/builders/utilities/date_fields_spec.rb +2 -2
- data/spec/features/edit_actions_spec.rb +44 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 208fad5bcbaa64e78d3b0881d3efc6504138dcb4
|
4
|
+
data.tar.gz: 0bfd9a1dfc5617558e882595e771de9be5f13e4b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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
|
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
|
-
|
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)
|
@@ -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
|
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:
|
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,
|
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,
|
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
|