2019-07-25 01:24:42 -04:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2016-08-07 23:29:23 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2020-06-16 14:09:01 -04:00
|
|
|
RSpec.describe 'Projects > Files > User wants to edit a file' do
|
2017-07-24 18:51:14 -04:00
|
|
|
let(:project) { create(:project, :repository) }
|
2022-01-24 19:11:49 -05:00
|
|
|
let(:user) { project.first_owner }
|
2016-08-07 23:29:23 -04:00
|
|
|
let(:commit_params) do
|
|
|
|
{
|
2017-01-06 10:50:08 -05:00
|
|
|
start_branch: project.default_branch,
|
2017-04-19 20:37:44 -04:00
|
|
|
branch_name: project.default_branch,
|
2016-08-07 23:29:23 -04:00
|
|
|
commit_message: "Committing First Update",
|
|
|
|
file_path: ".gitignore",
|
|
|
|
file_content: "First Update",
|
|
|
|
last_commit_sha: Gitlab::Git::Commit.last_for_path(project.repository, project.default_branch,
|
|
|
|
".gitignore").sha
|
|
|
|
}
|
|
|
|
end
|
|
|
|
|
2018-04-06 08:40:33 -04:00
|
|
|
before do
|
2017-06-21 19:44:10 -04:00
|
|
|
sign_in user
|
2017-06-29 13:06:35 -04:00
|
|
|
visit project_edit_blob_path(project,
|
2016-08-07 23:29:23 -04:00
|
|
|
File.join(project.default_branch, '.gitignore'))
|
|
|
|
end
|
|
|
|
|
2018-04-06 08:40:33 -04:00
|
|
|
it 'file has been updated since the user opened the edit page' do
|
2016-08-07 23:29:23 -04:00
|
|
|
Files::UpdateService.new(project, user, commit_params).execute
|
|
|
|
|
2017-04-04 14:06:32 -04:00
|
|
|
click_button 'Commit changes'
|
2016-08-07 23:29:23 -04:00
|
|
|
|
|
|
|
expect(page).to have_content 'Someone edited the file the same time you did.'
|
|
|
|
end
|
|
|
|
end
|