Commit bc0eb3b4 authored by Fabio Huser's avatar Fabio Huser

Make suggestion custom commit message spec DRY

parent 2b376292
...@@ -49,30 +49,30 @@ describe Suggestions::ApplyService do ...@@ -49,30 +49,30 @@ describe Suggestions::ApplyService do
expect(commit.author_name).to eq(user.name) expect(commit.author_name).to eq(user.name)
end end
context 'without a custom suggestion commit messge' do context 'when a custom suggestion commit message' do
before do before do
project.update!(suggestion_commit_message: nil) project.update!(suggestion_commit_message: message)
end
it 'sets default commit message' do
apply(suggestion) apply(suggestion)
end
context 'is not specified' do
let(:message) { nil }
it 'sets default commit message' do
expect(project.repository.commit.message).to eq("Apply suggestion to files/ruby/popen.rb") expect(project.repository.commit.message).to eq("Apply suggestion to files/ruby/popen.rb")
end end
end end
context 'with a custom suggestion commit message' do context 'is specified' do
before do let(:message) { 'refactor: %{project_path} %{project_name} %{file_path} %{branch_name} %{user_name}' }
project.update!(suggestion_commit_message: 'refactor: %{project_path} %{project_name} %{file_path} %{branch_name} %{user_name}')
end
it 'sets custom commit message' do it 'sets custom commit message' do
apply(suggestion)
expect(project.repository.commit.message).to eq("refactor: project-1 Project_1 files/ruby/popen.rb master Test User") expect(project.repository.commit.message).to eq("refactor: project-1 Project_1 files/ruby/popen.rb master Test User")
end end
end end
end end
end
let(:project) { create(:project, :repository, path: 'project-1', name: 'Project_1') } let(:project) { create(:project, :repository, path: 'project-1', name: 'Project_1') }
let(:user) { create(:user, :commit_email, name: 'Test User') } let(:user) { create(:user, :commit_email, name: 'Test User') }
......
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