diff options
author | Alfredo Sumaran <alfredo@gitlab.com> | 2017-01-06 00:08:35 +0000 |
---|---|---|
committer | Alfredo Sumaran <alfredo@gitlab.com> | 2017-01-06 00:08:35 +0000 |
commit | 6003f6ea93f8935ef4b6e9972f06a6a11aa48e69 (patch) | |
tree | b9595a7955ab5f9a1aef6f28e974af1907eb29d2 | |
parent | 81dfb1aa0259b3d13a8e4bea3ac6fae01e463a9f (diff) | |
parent | 55fe57ebe6c69355b727108366e558b9ac5fd142 (diff) | |
download | gitlab-ce-6003f6ea93f8935ef4b6e9972f06a6a11aa48e69.tar.gz |
Merge branch 'fix-timezone-due-date-picker' into 'master'
Fix timezone due date picker
Closes #24253
See merge request !8081
-rw-r--r-- | app/assets/javascripts/due_date_select.js.es6 | 7 | ||||
-rw-r--r-- | app/views/shared/issuable/_sidebar.html.haml | 2 | ||||
-rw-r--r-- | changelogs/unreleased/fix-timezone-due-date-picker.yml | 4 | ||||
-rw-r--r-- | spec/features/issues_spec.rb | 10 |
4 files changed, 18 insertions, 5 deletions
diff --git a/app/assets/javascripts/due_date_select.js.es6 b/app/assets/javascripts/due_date_select.js.es6 index 2b7d57d86c6..201f9fdc3fe 100644 --- a/app/assets/javascripts/due_date_select.js.es6 +++ b/app/assets/javascripts/due_date_select.js.es6 @@ -80,9 +80,12 @@ } parseSelectedDate() { - this.rawSelectedDate = $("input[name='" + this.fieldName + "']").val(); + this.rawSelectedDate = $(`input[name='${this.fieldName}']`).val(); + if (this.rawSelectedDate.length) { - let dateObj = new Date(this.rawSelectedDate); + // Construct Date object manually to avoid buggy dateString support within Date constructor + const dateArray = this.rawSelectedDate.split('-').map(v => parseInt(v, 10)); + const dateObj = new Date(dateArray[0], dateArray[1] - 1, dateArray[2]); this.displayedDate = $.datepicker.formatDate('M d, yy', dateObj); } else { this.displayedDate = 'No due date'; diff --git a/app/views/shared/issuable/_sidebar.html.haml b/app/views/shared/issuable/_sidebar.html.haml index bc57d48ae7c..5f199301364 100644 --- a/app/views/shared/issuable/_sidebar.html.haml +++ b/app/views/shared/issuable/_sidebar.html.haml @@ -97,7 +97,7 @@ remove due date - if can?(current_user, :"admin_#{issuable.to_ability_name}", @project) .selectbox.hide-collapsed - = f.hidden_field :due_date, value: issuable.due_date + = f.hidden_field :due_date, value: issuable.due_date.try(:strftime, 'yy-mm-dd') .dropdown %button.dropdown-menu-toggle.js-due-date-select{ type: 'button', data: { toggle: 'dropdown', field_name: "#{issuable.to_ability_name}[due_date]", ability_name: issuable.to_ability_name, issue_update: issuable_json_path(issuable) } } %span.dropdown-toggle-text Due date diff --git a/changelogs/unreleased/fix-timezone-due-date-picker.yml b/changelogs/unreleased/fix-timezone-due-date-picker.yml new file mode 100644 index 00000000000..2e6b71c70ca --- /dev/null +++ b/changelogs/unreleased/fix-timezone-due-date-picker.yml @@ -0,0 +1,4 @@ +--- +title: Fix date inconsistency on due date picker +merge_request: 7422 +author: Giuliano Varriale diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index b071fe480e6..394eb31aff8 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -619,14 +619,18 @@ describe 'Issues', feature: true do end it 'adds due date to issue' do + date = Date.today.at_beginning_of_month + 2.days + page.within '.due_date' do click_link 'Edit' page.within '.ui-datepicker-calendar' do - first('.ui-state-default').click + click_link date.day end - expect(page).to have_no_content 'None' + wait_for_ajax + + expect(find('.value').text).to have_content date.strftime('%b %-d, %Y') end end @@ -638,6 +642,8 @@ describe 'Issues', feature: true do first('.ui-state-default').click end + wait_for_ajax + expect(page).to have_no_content 'No due date' click_link 'remove due date' |