merge_commit_message_toggle_spec.rb 1.68 KB
Newer Older
1 2
require 'spec_helper'

3
feature 'Clicking toggle commit message link', js: true do
4
  let(:user) { create(:user) }
5
  let(:project) { create(:project, :public, :repository) }
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20
  let(:issue_1) { create(:issue, project: project)}
  let(:issue_2) { create(:issue, project: project)}
  let(:merge_request) do
    create(
      :merge_request,
      :simple,
      source_project: project,
      description: "Description\n\nclosing #{issue_1.to_reference}, #{issue_2.to_reference}"
    )
  end
  let(:textbox) { page.find(:css, '.js-commit-message', visible: false) }
  let(:default_message) do
    [
      "Merge branch 'feature' into 'master'",
      merge_request.title,
21
      "Closes #{issue_1.to_reference} and #{issue_2.to_reference}",
22
      "See merge request #{merge_request.to_reference(full: true)}"
23 24 25 26 27 28 29
    ].join("\n\n")
  end
  let(:message_with_description) do
    [
      "Merge branch 'feature' into 'master'",
      merge_request.title,
      merge_request.description,
30
      "See merge request #{merge_request.to_reference(full: true)}"
31 32 33 34 35 36
    ].join("\n\n")
  end

  before do
    project.team << [user, :master]

37
    sign_in user
38

39
    visit project_merge_request_path(project, merge_request)
40

Fatih Acet's avatar
Fatih Acet committed
41
    expect(page).not_to have_selector('.js-commit-message')
42
    click_button "Modify commit message"
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57
    expect(textbox).to be_visible
  end

  it "toggles commit message between message with description and without description " do
    expect(textbox.value).to eq(default_message)

    click_link "Include description in commit message"

    expect(textbox.value).to eq(message_with_description)

    click_link "Don't include description in commit message"

    expect(textbox.value).to eq(default_message)
  end
end