diff options
author | Adam Niedzielski <adamsunday@gmail.com> | 2016-08-06 19:09:04 +0200 |
---|---|---|
committer | Adam Niedzielski <adamsunday@gmail.com> | 2016-08-06 19:09:04 +0200 |
commit | 9accb302f6c1887374f4147c5316091b48c68f25 (patch) | |
tree | 2e4c6d99b30ad46836c0bd61c589d74d6a8f1148 /spec | |
parent | f564535579af71af599696a039801195a5c30f78 (diff) | |
download | gitlab-ce-9accb302f6c1887374f4147c5316091b48c68f25.tar.gz |
Set explicit time in tests so they return consistent results regardless of the hour of execution.
Diffstat (limited to 'spec')
-rw-r--r-- | spec/features/projects/members/master_adds_member_with_expiration_date_spec.rb | 41 |
1 files changed, 23 insertions, 18 deletions
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 8d706f015cf..400c7e477d2 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 @@ -2,6 +2,7 @@ require 'spec_helper' feature 'Projects > Members > Master adds member with expiration date', feature: true, js: true do include Select2Helper + include ActiveSupport::Testing::TimeHelpers let!(:master) { create(:user) } let!(:project) { create(:project) } @@ -13,28 +14,32 @@ feature 'Projects > Members > Master adds member with expiration date', feature: end scenario 'expiration date is displayed in the members list' do - 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 'Access expiration date', with: 4.days.from_now - click_on 'Add users to project' - end - - page.within '.project_member:first-child' do - expect(page).to have_content('Expires in 4 days') + travel_to Time.zone.parse("2016-08-06 08:00") do + 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 'Access expiration date', with: "2016-08-10" + click_on 'Add users to project' + end + + page.within '.project_member:first-child' do + expect(page).to have_content('Expires in 4 days') + end end end scenario 'change expiration date' do - project.team.add_users([new_member.id], :developer, expires_at: 1.month.from_now) - visit namespace_project_project_members_path(project.namespace, project) - - page.within '.project_member:first-child' do - click_on 'Edit' - fill_in 'Access expiration date', with: 2.days.from_now - click_on 'Save' - expect(page).to have_content('Expires in 2 days') + travel_to Time.zone.parse("2016-08-06 08:00") do + project.team.add_users([new_member.id], :developer, expires_at: "2016-09-06") + visit namespace_project_project_members_path(project.namespace, project) + + page.within '.project_member:first-child' do + click_on 'Edit' + fill_in 'Access expiration date', with: "2016-08-09" + click_on 'Save' + expect(page).to have_content('Expires in 3 days') + end end end end |