Commit 9accb302 authored by Adam Niedzielski's avatar Adam Niedzielski

Set explicit time in tests so they return consistent results regardless of the hour of execution.

parent f5645355
...@@ -2,6 +2,7 @@ require 'spec_helper' ...@@ -2,6 +2,7 @@ require 'spec_helper'
feature 'Projects > Members > Master adds member with expiration date', feature: true, js: true do feature 'Projects > Members > Master adds member with expiration date', feature: true, js: true do
include Select2Helper include Select2Helper
include ActiveSupport::Testing::TimeHelpers
let!(:master) { create(:user) } let!(:master) { create(:user) }
let!(:project) { create(:project) } let!(:project) { create(:project) }
...@@ -13,28 +14,32 @@ feature 'Projects > Members > Master adds member with expiration date', feature: ...@@ -13,28 +14,32 @@ feature 'Projects > Members > Master adds member with expiration date', feature:
end end
scenario 'expiration date is displayed in the members list' do scenario 'expiration date is displayed in the members list' do
visit namespace_project_project_members_path(project.namespace, project) 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) page.within '.users-project-form' do
fill_in 'Access expiration date', with: 4.days.from_now select2(new_member.id, from: '#user_ids', multiple: true)
click_on 'Add users to project' fill_in 'Access expiration date', with: "2016-08-10"
end click_on 'Add users to project'
end
page.within '.project_member:first-child' do
expect(page).to have_content('Expires in 4 days') page.within '.project_member:first-child' do
expect(page).to have_content('Expires in 4 days')
end
end end
end end
scenario 'change expiration date' do scenario 'change expiration date' do
project.team.add_users([new_member.id], :developer, expires_at: 1.month.from_now) travel_to Time.zone.parse("2016-08-06 08:00") do
visit namespace_project_project_members_path(project.namespace, project) 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' page.within '.project_member:first-child' do
fill_in 'Access expiration date', with: 2.days.from_now click_on 'Edit'
click_on 'Save' fill_in 'Access expiration date', with: "2016-08-09"
expect(page).to have_content('Expires in 2 days') click_on 'Save'
expect(page).to have_content('Expires in 3 days')
end
end end
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment