Commit 5d5457c2 authored by GitLab Bot's avatar GitLab Bot

Merge remote-tracking branch 'upstream/master' into ce-to-ee-2018-05-10

parents aa689b23 93498185
...@@ -82,7 +82,6 @@ export default () => { ...@@ -82,7 +82,6 @@ export default () => {
this.service this.service
.fetchCycleAnalyticsData(fetchOptions) .fetchCycleAnalyticsData(fetchOptions)
.then(resp => resp.json())
.then((response) => { .then((response) => {
this.store.setCycleAnalyticsData(response); this.store.setCycleAnalyticsData(response);
this.selectDefaultStage(); this.selectDefaultStage();
...@@ -116,7 +115,6 @@ export default () => { ...@@ -116,7 +115,6 @@ export default () => {
stage, stage,
startDate: this.startDate, startDate: this.startDate,
}) })
.then(resp => resp.json())
.then((response) => { .then((response) => {
this.isEmptyStage = !response.events.length; this.isEmptyStage = !response.events.length;
this.store.setStageEvents(response.events, stage); this.store.setStageEvents(response.events, stage);
......
import Vue from 'vue'; import axios from '~/lib/utils/axios_utils';
import VueResource from 'vue-resource';
Vue.use(VueResource);
export default class CycleAnalyticsService { export default class CycleAnalyticsService {
constructor(options) { constructor(options) {
this.requestPath = options.requestPath; this.axios = axios.create({
this.cycleAnalytics = Vue.resource(this.requestPath); baseURL: options.requestPath,
});
} }
fetchCycleAnalyticsData(options = { startDate: 30 }) { fetchCycleAnalyticsData(options = { startDate: 30 }) {
return this.cycleAnalytics.get({ cycle_analytics: { start_date: options.startDate } }); return this.axios
.get('', {
params: {
'cycle_analytics[start_date]': options.startDate,
},
})
.then(x => x.data);
} }
fetchStageData(options) { fetchStageData(options) {
...@@ -19,12 +23,12 @@ export default class CycleAnalyticsService { ...@@ -19,12 +23,12 @@ export default class CycleAnalyticsService {
startDate, startDate,
} = options; } = options;
return Vue.http.get(`${this.requestPath}/events/${stage.name}.json`, { return this.axios
params: { .get(`events/${stage.name}.json`, {
cycle_analytics: { params: {
start_date: startDate, 'cycle_analytics[start_date]': startDate,
}, },
}, })
}); .then(x => x.data);
} }
} }
...@@ -44,7 +44,7 @@ class Repository ...@@ -44,7 +44,7 @@ class Repository
changelog license_blob license_key gitignore koding_yml changelog license_blob license_key gitignore koding_yml
gitlab_ci_yml branch_names tag_names branch_count gitlab_ci_yml branch_names tag_names branch_count
tag_count avatar exists? root_ref has_visible_content? tag_count avatar exists? root_ref has_visible_content?
issue_template_names merge_request_template_names).freeze issue_template_names merge_request_template_names xcode_project?).freeze
# Methods that use cache_method but only memoize the value # Methods that use cache_method but only memoize the value
MEMOIZED_CACHED_METHODS = %i(license).freeze MEMOIZED_CACHED_METHODS = %i(license).freeze
...@@ -62,7 +62,8 @@ class Repository ...@@ -62,7 +62,8 @@ class Repository
gitlab_ci: :gitlab_ci_yml, gitlab_ci: :gitlab_ci_yml,
avatar: :avatar, avatar: :avatar,
issue_template: :issue_template_names, issue_template: :issue_template_names,
merge_request_template: :merge_request_template_names merge_request_template: :merge_request_template_names,
xcode_config: :xcode_project?
}.freeze }.freeze
def initialize(full_path, project, disk_path: nil, is_wiki: false) def initialize(full_path, project, disk_path: nil, is_wiki: false)
...@@ -601,6 +602,11 @@ class Repository ...@@ -601,6 +602,11 @@ class Repository
end end
cache_method :gitlab_ci_yml cache_method :gitlab_ci_yml
def xcode_project?
file_on_head(:xcode_config).present?
end
cache_method :xcode_project?
def head_commit def head_commit
@head_commit ||= commit(self.root_ref) @head_commit ||= commit(self.root_ref)
end end
......
---
title: 'Replace the `project/issues/references.feature` spinach test with an rspec analog'
merge_request: 18769
author: '@blackst0ne'
type: other
@project_issues
Feature: Project Issues References
Background:
Given I sign in as "John Doe"
And public project "Community"
And "John Doe" owns public project "Community"
And project "Community" has "Community issue" open issue
And I logout
And I sign in as "Mary Jane"
And private project "Enterprise"
And "Mary Jane" owns private project "Enterprise"
And project "Enterprise" has "Enterprise issue" open issue
And project "Enterprise" has "Enterprise fix" open merge request
And I visit issue page "Enterprise issue"
And I leave a comment referencing issue "Community issue"
And I visit merge request page "Enterprise fix"
And I leave a comment referencing issue "Community issue"
And I logout
@javascript
Scenario: Viewing the public issue as a "John Doe"
Given I sign in as "John Doe"
When I visit issue page "Community issue"
Then I should not see any related merge requests
And I should see no notes at all
@javascript
Scenario: Viewing the public issue as "Mary Jane"
Given I sign in as "Mary Jane"
When I visit issue page "Community issue"
Then I should see the "Enterprise fix" related merge request
And I should see a note linking to "Enterprise fix" merge request
And I should see a note linking to "Enterprise issue" issue
...@@ -6,13 +6,6 @@ module SharedIssuable ...@@ -6,13 +6,6 @@ module SharedIssuable
find('.js-issuable-edit', visible: true).click find('.js-issuable-edit', visible: true).click
end end
step 'project "Community" has "Community issue" open issue' do
create_issuable_for_project(
project_name: 'Community',
title: 'Community issue'
)
end
step 'project "Community" has "Community fix" open merge request' do step 'project "Community" has "Community fix" open merge request' do
create_issuable_for_project( create_issuable_for_project(
project_name: 'Community', project_name: 'Community',
...@@ -61,32 +54,11 @@ module SharedIssuable ...@@ -61,32 +54,11 @@ module SharedIssuable
wait_for_requests wait_for_requests
end end
step 'I visit issue page "Community issue"' do
issue = Issue.find_by(title: 'Community issue')
visit project_issue_path(issue.project, issue)
end
step 'I visit issue page "Community fix"' do step 'I visit issue page "Community fix"' do
mr = MergeRequest.find_by(title: 'Community fix') mr = MergeRequest.find_by(title: 'Community fix')
visit project_merge_request_path(mr.target_project, mr) visit project_merge_request_path(mr.target_project, mr)
end end
step 'I should not see any related merge requests' do
page.within '.issue-details' do
expect(page).not_to have_content('#merge-requests .merge-requests-title')
end
end
step 'I should see the "Enterprise fix" related merge request' do
page.within '#merge-requests .merge-requests-title' do
expect(page).to have_content('1 Related Merge Request')
end
page.within '#merge-requests ul' do
expect(page).to have_content('Enterprise fix')
end
end
step 'I should see a note linking to "Enterprise fix" merge request' do step 'I should see a note linking to "Enterprise fix" merge request' do
visible_note( visible_note(
issuable: MergeRequest.find_by(title: 'Enterprise fix'), issuable: MergeRequest.find_by(title: 'Enterprise fix'),
......
...@@ -14,6 +14,7 @@ module Gitlab ...@@ -14,6 +14,7 @@ module Gitlab
avatar: /\Alogo\.(png|jpg|gif)\z/, avatar: /\Alogo\.(png|jpg|gif)\z/,
issue_template: %r{\A\.gitlab/issue_templates/[^/]+\.md\z}, issue_template: %r{\A\.gitlab/issue_templates/[^/]+\.md\z},
merge_request_template: %r{\A\.gitlab/merge_request_templates/[^/]+\.md\z}, merge_request_template: %r{\A\.gitlab/merge_request_templates/[^/]+\.md\z},
xcode_config: %r{\A[^/]*\.(xcodeproj|xcworkspace)\z},
# Configuration files # Configuration files
gitignore: '.gitignore', gitignore: '.gitignore',
......
require "rails_helper"
describe "Internal references", :js do
include Spec::Support::Helpers::Features::NotesHelpers
let(:private_project_user) { private_project.owner }
let(:private_project) { create(:project, :private, :repository) }
let(:private_project_issue) { create(:issue, project: private_project) }
let(:private_project_merge_request) { create(:merge_request, source_project: private_project) }
let(:public_project_user) { public_project.owner }
let(:public_project) { create(:project, :public, :repository) }
let(:public_project_issue) { create(:issue, project: public_project) }
context "when referencing to open issue" do
context "from private project" do
context "from issue" do
before do
sign_in(private_project_user)
visit(project_issue_path(private_project, private_project_issue))
add_note("##{public_project_issue.to_reference(private_project)}")
end
context "when user doesn't have access to private project" do
before do
sign_in(public_project_user)
visit(project_issue_path(public_project, public_project_issue))
end
it { expect(page).not_to have_css(".note") }
end
end
context "from merge request" do
before do
sign_in(private_project_user)
visit(project_merge_request_path(private_project, private_project_merge_request))
add_note("##{public_project_issue.to_reference(private_project)}")
end
context "when user doesn't have access to private project" do
before do
sign_in(public_project_user)
visit(project_issue_path(public_project, public_project_issue))
end
it "doesn't show any references" do
page.within(".issue-details") do
expect(page).not_to have_content("#merge-requests .merge-requests-title")
end
end
end
context "when user has access to private project" do
before do
visit(project_issue_path(public_project, public_project_issue))
end
it "shows references" do
page.within("#merge-requests .merge-requests-title") do
expect(page).to have_content("1 Related Merge Request")
end
page.within("#merge-requests ul") do
expect(page).to have_content(private_project_merge_request.title)
end
expect(page).to have_content("mentioned in merge request #{private_project_merge_request.to_reference(public_project)}")
.and have_content(private_project_user.name)
end
end
end
end
end
end
...@@ -1733,7 +1733,8 @@ describe Repository do ...@@ -1733,7 +1733,8 @@ describe Repository do
:gitlab_ci, :gitlab_ci,
:avatar, :avatar,
:issue_template, :issue_template,
:merge_request_template :merge_request_template,
:xcode_config
]) ])
repository.after_change_head repository.after_change_head
...@@ -2058,6 +2059,36 @@ describe Repository do ...@@ -2058,6 +2059,36 @@ describe Repository do
end end
end end
describe '#xcode_project?' do
before do
allow(repository).to receive(:tree).with(:head).and_return(double(:tree, blobs: [blob]))
end
context 'when the root contains a *.xcodeproj file' do
let(:blob) { double(:blob, path: 'Foo.xcodeproj') }
it 'returns true' do
expect(repository.xcode_project?).to be_truthy
end
end
context 'when the root contains a *.xcworkspace file' do
let(:blob) { double(:blob, path: 'Foo.xcworkspace') }
it 'returns true' do
expect(repository.xcode_project?).to be_truthy
end
end
context 'when the root contains no XCode config file' do
let(:blob) { double(:blob, path: 'subdir/Foo.xcworkspace') }
it 'returns false' do
expect(repository.xcode_project?).to be_falsey
end
end
end
describe "#keep_around" do describe "#keep_around" do
it "does not fail if we attempt to reference bad commit" do it "does not fail if we attempt to reference bad commit" do
expect(repository.kept_around?('abc1234')).to be_falsey expect(repository.kept_around?('abc1234')).to be_falsey
......
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