diff options
author | Phil Hughes <me@iamphill.com> | 2017-01-30 16:56:04 +0300 |
---|---|---|
committer | Phil Hughes <me@iamphill.com> | 2017-02-06 12:38:53 +0300 |
commit | 12cc9a530c6540075c78239416027eb706fac386 (patch) | |
tree | f6846d1a9033eb767b19a9236a16ee0d5c7c6eaa | |
parent | 5942247dd6f73f5e92a3c635873e62d0efbf9ea8 (diff) |
Changed date check test
6 files changed, 29 insertions, 31 deletions
diff --git a/app/assets/javascripts/application.js b/app/assets/javascripts/application.js index 0a09f1c7578..ef65875d276 100644 --- a/app/assets/javascripts/application.js +++ b/app/assets/javascripts/application.js @@ -34,7 +34,7 @@ require('bootstrap/js/transition'); require('bootstrap/js/tooltip'); require('bootstrap/js/popover'); require('select2/select2.js'); -require('pikaday'); +window.Pikaday = require('pikaday'); window._ = require('underscore'); window.Dropzone = require('dropzone'); require('mousetrap'); diff --git a/app/assets/javascripts/due_date_select.js.es6 b/app/assets/javascripts/due_date_select.js.es6 index b3def37ad66..ab5ce23d261 100644 --- a/app/assets/javascripts/due_date_select.js.es6 +++ b/app/assets/javascripts/due_date_select.js.es6 @@ -48,7 +48,7 @@ const calendar = new Pikaday({ field: $dueDateInput.get(0), theme: 'gitlab-theme', - format: 'yyyy-mm-dd', + format: 'YYYY-MM-DD', onSelect: (dateText) => { const formattedDate = dateFormat(new Date(dateText), 'yyyy-mm-dd'); @@ -63,8 +63,6 @@ } }); - calendar.setDate(new Date($dueDateInput.val())); - this.$datePicker.append(calendar.el); this.$datePicker.data('pikaday', calendar); } @@ -171,12 +169,11 @@ const calendar = new Pikaday({ field: $datePicker.get(0), theme: 'gitlab-theme', - format: 'yyyy-mm-dd', + format: 'YYYY-MM-DD', onSelect(dateText) { $datePicker.val(dateFormat(new Date(dateText), 'yyyy-mm-dd')); } }); - calendar.setDate(new Date($datePicker.val())); $datePicker.data('pikaday', calendar); }); diff --git a/app/assets/javascripts/issuable_form.js b/app/assets/javascripts/issuable_form.js index c7c744ef61f..2ec545db665 100644 --- a/app/assets/javascripts/issuable_form.js +++ b/app/assets/javascripts/issuable_form.js @@ -40,12 +40,11 @@ calendar = new Pikaday({ field: $issuableDueDate.get(0), theme: 'gitlab-theme', - format: 'yyyy-mm-dd', + format: 'YYYY-MM-DD', onSelect: function(dateText) { $issuableDueDate.val(dateFormat(new Date(dateText), 'yyyy-mm-dd')); } }); - calendar.setDate(new Date($issuableDueDate.val())); } } diff --git a/app/assets/javascripts/member_expiration_date.js.es6 b/app/assets/javascripts/member_expiration_date.js.es6 index 8b045dfc134..f57d4a20498 100644 --- a/app/assets/javascripts/member_expiration_date.js.es6 +++ b/app/assets/javascripts/member_expiration_date.js.es6 @@ -19,7 +19,7 @@ const calendar = new Pikaday({ field: $input.get(0), theme: 'gitlab-theme', - format: 'yyyy-mm-dd', + format: 'YYYY-MM-DD', minDate: new Date(), onSelect(dateText) { $input.val(dateFormat(new Date(dateText), 'yyyy-mm-dd')); @@ -30,8 +30,6 @@ }, }); - calendar.setDate(new Date($input.val())); - $input.data('pikaday', calendar); }); diff --git a/app/views/profiles/personal_access_tokens/index.html.haml b/app/views/profiles/personal_access_tokens/index.html.haml index b10f5fc08e2..2c006e1712d 100644 --- a/app/views/profiles/personal_access_tokens/index.html.haml +++ b/app/views/profiles/personal_access_tokens/index.html.haml @@ -91,7 +91,7 @@ new Pikaday({ field: $dateField.get(0), theme: 'gitlab-theme', - format: 'yyyy-mm-dd', + format: 'YYYY-MM-DD', minDate: new Date(), onSelect: function(dateText) { $dateField.val(dateFormat(new Date(dateText), 'yyyy-mm-dd')); diff --git a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb index 6c37a344251..c3f45be6e4b 100644 --- a/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb +++ b/spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb @@ -15,29 +15,33 @@ feature 'Projects > Members > Master adds member with expiration date', feature: end scenario 'expiration date is displayed in the members list' do - date = 5.days.from_now - visit namespace_project_project_members_path(project.namespace, project) - - page.within '.users-project-form' do - select2(new_member.id, from: '#user_ids', multiple: true) - fill_in 'expires_at', with: date.to_s(:medium) - click_on 'Add to project' - end - - page.within "#project_member_#{new_member.project_members.first.id}" do - expect(page).to have_content('Expires in 4 days') + travel_to Time.zone.parse('2016-08-06 08:00') do + date = 4.days.from_now + visit namespace_project_project_members_path(project.namespace, project) + + page.within '.users-project-form' do + select2(new_member.id, from: '#user_ids', multiple: true) + fill_in 'expires_at', with: date.to_s(:medium) + click_on 'Add to project' + end + + page.within "#project_member_#{new_member.project_members.first.id}" do + expect(page).to have_content('Expires in 4 days') + end end end scenario 'change expiration date' do - date = 4.days.from_now - project.team.add_users([new_member.id], :developer, expires_at: Date.today.to_s(:medium)) - visit namespace_project_project_members_path(project.namespace, project) - - page.within "#project_member_#{new_member.project_members.first.id}" do - find('.js-access-expiration-date').set date.to_s(:medium) - wait_for_ajax - expect(page).to have_content('Expires in 3 days') + travel_to Time.zone.parse('2016-08-06 08:00') do + date = 3.days.from_now + project.team.add_users([new_member.id], :developer, expires_at: Date.today.to_s(:medium)) + visit namespace_project_project_members_path(project.namespace, project) + + page.within "#project_member_#{new_member.project_members.first.id}" do + find('.js-access-expiration-date').set date.to_s(:medium) + wait_for_ajax + expect(page).to have_content('Expires in 3 days') + end end end end |