Merge branch 'rs-issue-1887' into 'master'
Reorder MergeRequestTabs constructor The tab was being activated before we set the `[commits|diffs]Loaded` variable, so even when the `/diffs` route is accessed directly, like from the "Side-by-side" link, the tab was being loaded from its default source. Fixes #1887 See merge request !892
This commit is contained in:
commit
06ab7d89f9
4 changed files with 27 additions and 28 deletions
|
@ -49,13 +49,15 @@ class @MergeRequestTabs
|
||||||
# Store the `location` object, allowing for easier stubbing in tests
|
# Store the `location` object, allowing for easier stubbing in tests
|
||||||
@_location = location
|
@_location = location
|
||||||
|
|
||||||
|
switch @opts.action
|
||||||
|
when 'commits'
|
||||||
|
@commitsLoaded = true
|
||||||
|
when 'diffs'
|
||||||
|
@diffsLoaded = true
|
||||||
|
|
||||||
@bindEvents()
|
@bindEvents()
|
||||||
@activateTab(@opts.action)
|
@activateTab(@opts.action)
|
||||||
|
|
||||||
switch @opts.action
|
|
||||||
when 'commits' then @commitsLoaded = true
|
|
||||||
when 'diffs' then @diffsLoaded = true
|
|
||||||
|
|
||||||
bindEvents: ->
|
bindEvents: ->
|
||||||
$(document).on 'shown.bs.tab', '.merge-request-tabs a[data-toggle="tab"]', @tabShown
|
$(document).on 'shown.bs.tab', '.merge-request-tabs a[data-toggle="tab"]', @tabShown
|
||||||
|
|
||||||
|
@ -67,6 +69,7 @@ class @MergeRequestTabs
|
||||||
@loadCommits($target.attr('href'))
|
@loadCommits($target.attr('href'))
|
||||||
else if action == 'diffs'
|
else if action == 'diffs'
|
||||||
@loadDiff($target.attr('href'))
|
@loadDiff($target.attr('href'))
|
||||||
|
@stickyDiffHeaders()
|
||||||
|
|
||||||
@setCurrentAction(action)
|
@setCurrentAction(action)
|
||||||
|
|
||||||
|
@ -134,12 +137,15 @@ class @MergeRequestTabs
|
||||||
url: "#{source}.json"
|
url: "#{source}.json"
|
||||||
success: (data) =>
|
success: (data) =>
|
||||||
document.getElementById('diffs').innerHTML = data.html
|
document.getElementById('diffs').innerHTML = data.html
|
||||||
$('.diff-header').trigger('sticky_kit:recalc')
|
@stickyDiffHeaders()
|
||||||
@diffsLoaded = true
|
@diffsLoaded = true
|
||||||
|
|
||||||
toggleLoading: ->
|
toggleLoading: ->
|
||||||
$('.mr-loading-status .loading').toggle()
|
$('.mr-loading-status .loading').toggle()
|
||||||
|
|
||||||
|
stickyDiffHeaders: ->
|
||||||
|
$('.diff-header').trigger('sticky_kit:recalc')
|
||||||
|
|
||||||
_get: (options) ->
|
_get: (options) ->
|
||||||
defaults = {
|
defaults = {
|
||||||
beforeSend: @toggleLoading
|
beforeSend: @toggleLoading
|
||||||
|
|
|
@ -63,7 +63,7 @@ Feature: Project Merge Requests
|
||||||
Scenario: I comment on a merge request diff
|
Scenario: I comment on a merge request diff
|
||||||
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
||||||
And I visit merge request page "Bug NS-05"
|
And I visit merge request page "Bug NS-05"
|
||||||
And I switch to the diff tab
|
And I click on the Changes tab
|
||||||
And I leave a comment like "Line is wrong" on diff
|
And I leave a comment like "Line is wrong" on diff
|
||||||
And I switch to the merge request's comments tab
|
And I switch to the merge request's comments tab
|
||||||
Then I should see a discussion has started on diff
|
Then I should see a discussion has started on diff
|
||||||
|
@ -114,7 +114,7 @@ Feature: Project Merge Requests
|
||||||
Scenario: I hide comments on a merge request diff with comments in a single file
|
Scenario: I hide comments on a merge request diff with comments in a single file
|
||||||
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
||||||
And I visit merge request page "Bug NS-05"
|
And I visit merge request page "Bug NS-05"
|
||||||
And I switch to the diff tab
|
And I click on the Changes tab
|
||||||
And I leave a comment like "Line is wrong" on line 39 of the second file
|
And I leave a comment like "Line is wrong" on line 39 of the second file
|
||||||
And I click link "Hide inline discussion" of the second file
|
And I click link "Hide inline discussion" of the second file
|
||||||
Then I should not see a comment like "Line is wrong here" in the second file
|
Then I should not see a comment like "Line is wrong here" in the second file
|
||||||
|
@ -123,7 +123,7 @@ Feature: Project Merge Requests
|
||||||
Scenario: I show comments on a merge request diff with comments in a single file
|
Scenario: I show comments on a merge request diff with comments in a single file
|
||||||
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
||||||
And I visit merge request page "Bug NS-05"
|
And I visit merge request page "Bug NS-05"
|
||||||
And I switch to the diff tab
|
And I click on the Changes tab
|
||||||
And I leave a comment like "Line is wrong" on line 39 of the second file
|
And I leave a comment like "Line is wrong" on line 39 of the second file
|
||||||
Then I should see a comment like "Line is wrong" in the second file
|
Then I should see a comment like "Line is wrong" in the second file
|
||||||
|
|
||||||
|
@ -131,7 +131,7 @@ Feature: Project Merge Requests
|
||||||
Scenario: I hide comments on a merge request diff with comments in multiple files
|
Scenario: I hide comments on a merge request diff with comments in multiple files
|
||||||
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
||||||
And I visit merge request page "Bug NS-05"
|
And I visit merge request page "Bug NS-05"
|
||||||
And I switch to the diff tab
|
And I click on the Changes tab
|
||||||
And I leave a comment like "Line is correct" on line 12 of the first file
|
And I leave a comment like "Line is correct" on line 12 of the first file
|
||||||
And I leave a comment like "Line is wrong" on line 39 of the second file
|
And I leave a comment like "Line is wrong" on line 39 of the second file
|
||||||
And I click link "Hide inline discussion" of the second file
|
And I click link "Hide inline discussion" of the second file
|
||||||
|
@ -142,7 +142,7 @@ Feature: Project Merge Requests
|
||||||
Scenario: I show comments on a merge request diff with comments in multiple files
|
Scenario: I show comments on a merge request diff with comments in multiple files
|
||||||
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
||||||
And I visit merge request page "Bug NS-05"
|
And I visit merge request page "Bug NS-05"
|
||||||
And I switch to the diff tab
|
And I click on the Changes tab
|
||||||
And I leave a comment like "Line is correct" on line 12 of the first file
|
And I leave a comment like "Line is correct" on line 12 of the first file
|
||||||
And I leave a comment like "Line is wrong" on line 39 of the second file
|
And I leave a comment like "Line is wrong" on line 39 of the second file
|
||||||
And I click link "Hide inline discussion" of the second file
|
And I click link "Hide inline discussion" of the second file
|
||||||
|
@ -154,7 +154,7 @@ Feature: Project Merge Requests
|
||||||
Scenario: I unfold diff
|
Scenario: I unfold diff
|
||||||
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
||||||
And I visit merge request page "Bug NS-05"
|
And I visit merge request page "Bug NS-05"
|
||||||
And I switch to the diff tab
|
And I click on the Changes tab
|
||||||
And I unfold diff
|
And I unfold diff
|
||||||
Then I should see additional file lines
|
Then I should see additional file lines
|
||||||
|
|
||||||
|
@ -162,7 +162,7 @@ Feature: Project Merge Requests
|
||||||
Scenario: I show comments on a merge request side-by-side diff with comments in multiple files
|
Scenario: I show comments on a merge request side-by-side diff with comments in multiple files
|
||||||
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
||||||
And I visit merge request page "Bug NS-05"
|
And I visit merge request page "Bug NS-05"
|
||||||
And I switch to the diff tab
|
And I click on the Changes tab
|
||||||
And I leave a comment like "Line is correct" on line 12 of the first file
|
And I leave a comment like "Line is correct" on line 12 of the first file
|
||||||
And I leave a comment like "Line is wrong" on line 39 of the second file
|
And I leave a comment like "Line is wrong" on line 39 of the second file
|
||||||
And I click Side-by-side Diff tab
|
And I click Side-by-side Diff tab
|
||||||
|
@ -172,7 +172,7 @@ Feature: Project Merge Requests
|
||||||
Scenario: I view diffs on a merge request
|
Scenario: I view diffs on a merge request
|
||||||
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
Given project "Shop" have "Bug NS-05" open merge request with diffs inside
|
||||||
And I visit merge request page "Bug NS-05"
|
And I visit merge request page "Bug NS-05"
|
||||||
And I click on the Changes tab via Javascript
|
And I click on the Changes tab
|
||||||
Then I should see the proper Inline and Side-by-side links
|
Then I should see the proper Inline and Side-by-side links
|
||||||
|
|
||||||
# Description preview
|
# Description preview
|
||||||
|
|
|
@ -118,25 +118,17 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
|
||||||
author: project.users.first)
|
author: project.users.first)
|
||||||
end
|
end
|
||||||
|
|
||||||
step 'I switch to the diff tab' do
|
step 'I click on the Changes tab' do
|
||||||
visit diffs_namespace_project_merge_request_path(project.namespace, project, merge_request)
|
|
||||||
end
|
|
||||||
|
|
||||||
step 'I click on the Changes tab via Javascript' do
|
|
||||||
page.within '.merge-request-tabs' do
|
page.within '.merge-request-tabs' do
|
||||||
click_link 'Changes'
|
click_link 'Changes'
|
||||||
end
|
end
|
||||||
|
|
||||||
sleep 2
|
# Waits for load
|
||||||
|
expect(page).to have_css('.tab-content #diffs.active')
|
||||||
end
|
end
|
||||||
|
|
||||||
step 'I should see the proper Inline and Side-by-side links' do
|
step 'I should see the proper Inline and Side-by-side links' do
|
||||||
buttons = page.all('#commit-diff-viewtype')
|
expect(page).to have_css('#commit-diff-viewtype', count: 2)
|
||||||
expect(buttons.count).to eq(2)
|
|
||||||
|
|
||||||
buttons.each do |b|
|
|
||||||
expect(b['href']).not_to have_content('json')
|
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
||||||
step 'I switch to the merge request\'s comments tab' do
|
step 'I switch to the merge request\'s comments tab' do
|
||||||
|
@ -301,6 +293,8 @@ class Spinach::Features::ProjectMergeRequests < Spinach::FeatureSteps
|
||||||
end
|
end
|
||||||
|
|
||||||
step 'I unfold diff' do
|
step 'I unfold diff' do
|
||||||
|
expect(page).to have_css('.js-unfold')
|
||||||
|
|
||||||
first('.js-unfold').click
|
first('.js-unfold').click
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
|
@ -223,8 +223,7 @@ describe 'Comments' do
|
||||||
sample_compare.changes.last[:line_code]
|
sample_compare.changes.last[:line_code]
|
||||||
end
|
end
|
||||||
|
|
||||||
def click_diff_line(data = nil)
|
def click_diff_line(data = line_code)
|
||||||
data ||= line_code
|
page.find(%Q{button[data-line-code="#{data}"]}, visible: false).click
|
||||||
find("button[data-line-code=\"#{data}\"]").click
|
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue