Commit 3276ef44 authored by Rémy Coutable's avatar Rémy Coutable

Merge remote-tracking branch 'ce/master' into rc/ce-to-ee-monday

Signed-off-by: default avatarRémy Coutable <remy@rymai.me>
parents e7a94601 19a44034
......@@ -108,8 +108,8 @@ knapsack:
stage: prepare
script:
- mkdir -p knapsack/${CI_PROJECT_NAME}/
- wget -O $KNAPSACK_RSPEC_SUITE_REPORT_PATH http://${KNAPSACK_S3_BUCKET}.s3.amazonaws.com/$KNAPSACK_RSPEC_SUITE_REPORT_PATH || true
- wget -O $KNAPSACK_SPINACH_SUITE_REPORT_PATH http://${KNAPSACK_S3_BUCKET}.s3.amazonaws.com/$KNAPSACK_SPINACH_SUITE_REPORT_PATH || true
- wget -O $KNAPSACK_RSPEC_SUITE_REPORT_PATH http://${KNAPSACK_S3_BUCKET}.s3.amazonaws.com/$KNAPSACK_RSPEC_SUITE_REPORT_PATH || rm $KNAPSACK_RSPEC_SUITE_REPORT_PATH
- wget -O $KNAPSACK_SPINACH_SUITE_REPORT_PATH http://${KNAPSACK_S3_BUCKET}.s3.amazonaws.com/$KNAPSACK_SPINACH_SUITE_REPORT_PATH || rm $KNAPSACK_SPINACH_SUITE_REPORT_PATH
- '[[ -f $KNAPSACK_RSPEC_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_RSPEC_SUITE_REPORT_PATH}'
- '[[ -f $KNAPSACK_SPINACH_SUITE_REPORT_PATH ]] || echo "{}" > ${KNAPSACK_SPINACH_SUITE_REPORT_PATH}'
......
......@@ -94,7 +94,7 @@ $(() => {
resp.json().forEach((board) => {
const list = Store.addList(board);
if (list.type === 'done') {
if (list.type === 'closed') {
list.position = Infinity;
}
});
......
......@@ -53,7 +53,7 @@ import Vue from 'vue';
template: `
<div
class="block list"
v-if="list.type !== 'done'">
v-if="list.type !== 'closed'">
<button
class="btn btn-default btn-block"
type="button"
......
......@@ -10,7 +10,7 @@ class List {
this.position = obj.position;
this.title = obj.title;
this.type = obj.list_type;
this.preset = ['done', 'blank'].indexOf(this.type) > -1;
this.preset = ['closed', 'blank'].indexOf(this.type) > -1;
this.page = 1;
this.loading = true;
this.loadingMore = false;
......
......@@ -50,7 +50,7 @@ import Cookies from 'js-cookie';
},
shouldAddBlankState () {
// Decide whether to add the blank state
return !(this.state.lists.filter(list => list.type !== 'done')[0]);
return !(this.state.lists.filter(list => list.type !== 'closed')[0]);
},
addBlankState () {
if (!this.shouldAddBlankState() || this.welcomeIsHidden() || this.disabled) return;
......@@ -103,7 +103,7 @@ import Cookies from 'js-cookie';
issueTo.removeLabel(listFrom.label);
}
if (listTo.type === 'done') {
if (listTo.type === 'closed') {
issueLists.forEach((list) => {
list.removeIssue(issue);
});
......
......@@ -25,6 +25,7 @@
bindEvents() {
$('.js-preferences-form').on('change.preference', 'input[type=radio]', this.submitForm);
$('#user_notification_email').on('change', this.submitForm);
$('#user_notified_of_own_activity').on('change', this.submitForm);
$('.update-username').on('ajax:before', this.beforeUpdateUsername);
$('.update-username').on('ajax:complete', this.afterUpdateUsername);
$('.update-notifications').on('ajax:success', this.onUpdateNotifs);
......
......@@ -263,14 +263,6 @@ header {
}
}
.page-sidebar-pinned.right-sidebar-expanded {
@media (max-width: $screen-md-max) {
.header-content .title {
width: 300px;
}
}
}
@media (max-width: $screen-xs-max) {
header .container-fluid {
font-size: 18px;
......
......@@ -243,22 +243,6 @@ ul.notes {
}
}
.page-sidebar-pinned.right-sidebar-expanded {
@media (max-width: $screen-md-max) {
.note-header {
.note-headline-light {
display: block;
}
.note-actions {
position: absolute;
right: 0;
top: 0;
}
}
}
}
// Diff code in discussion view
.discussion-body .diff-file {
.file-title {
......
......@@ -477,20 +477,6 @@ a.deploy-project-label {
}
}
.page-sidebar-pinned {
.project-stats .nav > li.right {
@media (min-width: $screen-lg-min) {
float: none;
}
}
.download-button {
@media (min-width: $screen-lg-min) {
margin-left: 0;
}
}
}
.project-stats {
font-size: 0;
text-align: center;
......
......@@ -17,6 +17,6 @@ class Profiles::NotificationsController < Profiles::ApplicationController
end
def user_params
params.require(:user).permit(:notification_email)
params.require(:user).permit(:notification_email, :notified_of_own_activity)
end
end
......@@ -130,6 +130,6 @@ class Projects::WikisController < Projects::ApplicationController
end
def wiki_params
params[:wiki].slice(:title, :content, :format, :message)
params.require(:wiki).permit(:title, :content, :format, :message)
end
end
......@@ -6,8 +6,8 @@ class Board < ActiveRecord::Base
validates :name, :project, presence: true
def done_list
lists.merge(List.done).take
def closed_list
lists.merge(List.closed).take
end
def milestone
......
......@@ -2,7 +2,7 @@ class List < ActiveRecord::Base
belongs_to :board
belongs_to :label
enum list_type: { label: 1, done: 2 }
enum list_type: { label: 1, closed: 2 }
validates :board, :list_type, presence: true
validates :label, :position, presence: true, if: :label?
......
......@@ -24,6 +24,7 @@ class User < ActiveRecord::Base
default_value_for :hide_no_ssh_key, false
default_value_for :hide_no_password, false
default_value_for :project_view, :files
default_value_for :notified_of_own_activity, false
attr_encrypted :otp_secret,
key: Gitlab::Application.secrets.otp_key_base,
......
......@@ -3,9 +3,17 @@ module Boards
def execute
board = project.boards.create(params)
<<<<<<< HEAD
if board.persisted?
board.lists.create(list_type: :done)
end
=======
private
def create_board!
board = project.boards.create
board.lists.create(list_type: :closed)
>>>>>>> ce/master
board
end
......
......@@ -41,7 +41,7 @@ module Boards
end
def set_state
params[:state] = list && list.done? ? 'closed' : 'opened'
params[:state] = list && list.closed? ? 'closed' : 'opened'
end
def board_label_ids
......
......@@ -48,8 +48,8 @@ module Boards
end
def issue_state
return 'reopen' if moving_from_list.done?
return 'close' if moving_to_list.done?
return 'reopen' if moving_from_list.closed?
return 'close' if moving_to_list.closed?
end
def add_label_ids
......
......@@ -38,7 +38,7 @@ class NotificationRecipientService
recipients = reject_unsubscribed_users(recipients, target)
recipients = reject_users_without_access(recipients, target)
recipients.delete(current_user) if skip_current_user
recipients.delete(current_user) if skip_current_user && !current_user.notified_of_own_activity?
recipients.uniq
end
......@@ -47,7 +47,7 @@ class NotificationRecipientService
recipients = add_labels_subscribers([], target, labels: labels)
recipients = reject_unsubscribed_users(recipients, target)
recipients = reject_users_without_access(recipients, target)
recipients.delete(current_user)
recipients.delete(current_user) unless current_user.notified_of_own_activity?
recipients.uniq
end
......@@ -88,7 +88,7 @@ class NotificationRecipientService
recipients = reject_unsubscribed_users(recipients, note.noteable)
recipients = reject_users_without_access(recipients, note.noteable)
recipients.delete(note.author)
recipients.delete(note.author) unless note.author.notified_of_own_activity?
recipients.uniq
end
......
......@@ -297,8 +297,9 @@ class NotificationService
recipients ||= NotificationRecipientService.new(pipeline.project).build_recipients(
pipeline,
nil, # The acting user, who won't be added to recipients
action: pipeline.status).map(&:notification_email)
pipeline.user,
action: pipeline.status,
skip_current_user: false).map(&:notification_email)
if recipients.any?
mailer.public_send(email_template, pipeline, recipients).deliver_later
......
......@@ -34,6 +34,11 @@
.clearfix
= form_for @user, url: profile_notifications_path, method: :put do |f|
%label{ for: 'user_notified_of_own_activity' }
= f.check_box :notified_of_own_activity
%span Receive notifications about your own activity
%hr
%h5
Groups (#{@group_notifications.count})
......
......@@ -7,12 +7,12 @@
data: { container: "body", placement: "bottom" } }
{{ list.title }}
.board-issue-count-holder.pull-right.clearfix{ "v-if" => 'list.type !== "blank"' }
%span.board-issue-count.pull-left{ ":class" => '{ "has-btn": list.type !== "done" && !disabled }' }
%span.board-issue-count.pull-left{ ":class" => '{ "has-btn": list.type !== "closed" && !disabled }' }
{{ list.issuesSize }}
- if can?(current_user, :admin_issue, @project)
%button.btn.btn-small.btn-default.pull-right.has-tooltip{ type: "button",
"@click" => "showNewIssueForm",
"v-if" => 'list.type !== "done"',
"v-if" => 'list.type !== "closed"',
"aria-label" => "Add an issue",
"title" => "Add an issue",
data: { placement: "top", container: "body" } }
......
......@@ -3,7 +3,7 @@
= icon("spinner spin")
- if can? current_user, :create_issue, @project
%board-new-issue{ ":list" => "list",
"v-if" => 'list.type !== "done" && showIssueForm' }
"v-if" => 'list.type !== "closed" && showIssueForm' }
%ul.board-list{ "ref" => "list",
"v-show" => "!loading",
":data-board" => "list.id",
......
......@@ -10,13 +10,13 @@
Pipelines
- if project_nav_tab? :builds
= nav_link(path: 'builds#index', controller: :builds) do
= nav_link(controller: :builds) do
= link_to project_builds_path(@project), title: 'Jobs', class: 'shortcuts-builds' do
%span
Jobs
- if project_nav_tab? :environments
= nav_link(path: 'environments#index', controller: :environments) do
= nav_link(controller: :environments) do
= link_to project_environments_path(@project), title: 'Environments', class: 'shortcuts-environments' do
%span
Environments
......
---
title: Update wikis_controller.rb to use strong params
merge_request:
author:
---
title: Fix sub-nav highlighting for `Environments` and `Jobs` pages
merge_request: 10254
author:
---
title: Add option to receive email notifications about your own activity
merge_request: 10032
author: Richard Macklin
---
title: Change Done column to Closed in issue boards
merge_request: 10198
author: blackst0ne
---
title: update test_bundle.js ignored files
merge_request:
author:
......@@ -118,7 +118,11 @@ var config = {
// create cacheable common library bundle for all d3 chunks
new webpack.optimize.CommonsChunkPlugin({
name: 'common_d3',
chunks: ['graphs', 'users', 'monitoring'],
chunks: [
'graphs',
'users',
'monitoring',
],
}),
// create cacheable common library bundles
......
class ReaddNotifiedOfOwnActivityToUsers < ActiveRecord::Migration
include Gitlab::Database::MigrationHelpers
disable_ddl_transaction!
DOWNTIME = false
def change
add_column :users, :notified_of_own_activity, :boolean
end
end
......@@ -1436,6 +1436,7 @@ ActiveRecord::Schema.define(version: 20170317203554) do
t.boolean "authorized_projects_populated"
t.boolean "auditor", default: false, null: false
t.boolean "ghost"
t.boolean "notified_of_own_activity"
end
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
......
......@@ -76,7 +76,7 @@ Example response:
## List board lists
Get a list of the board's lists.
Does not include `backlog` and `done` lists
Does not include `backlog` and `closed` lists
```
GET /projects/:id/boards/:board_id/lists
......
......@@ -318,7 +318,7 @@ variables:
IMAGE_TAG: $CI_REGISTRY_IMAGE:$CI_COMMIT_REF_NAME
before_script:
- docker login -u gitlab-ci-token -p $CI_COMMIT_TOKEN $CI_REGISTRY
- docker login -u gitlab-ci-token -p $CI_JOB_TOKEN $CI_REGISTRY
build:
stage: build
......
......@@ -352,7 +352,7 @@ Example values:
export CI_JOB_ID="50"
export CI_COMMIT_SHA="1ecfd275763eff1d6b4844ea3168962458c9f27a"
export CI_COMMIT_REF_NAME="master"
export CI_REPOSITORY="https://gitab-ci-token:abcde-1234ABCD5678ef@example.com/gitlab-org/gitlab-ce.git"
export CI_REPOSITORY_URL="https://gitab-ci-token:abcde-1234ABCD5678ef@example.com/gitlab-org/gitlab-ce.git"
export CI_COMMIT_TAG="1.0.0"
export CI_JOB_NAME="spec:other"
export CI_JOB_STAGE="test"
......
......@@ -200,7 +200,6 @@ See [our current .eslintrc][eslintrc] for specific rules and patterns.
#### Naming
- **Extensions**: Use `.vue` extension for Vue components.
- **Reference Naming**: Use PascalCase for Vue components and camelCase for their instances:
```javascript
// bad
import cardBoard from 'cardBoard';
......@@ -218,15 +217,23 @@ See [our current .eslintrc][eslintrc] for specific rules and patterns.
cardBoard: CardBoard
};
```
- **Props Naming**: Avoid using DOM component prop names.
- **Props Naming:**
- Avoid using DOM component prop names.
- Use kebab-case instead of camelCase to provide props in templates.
```javascript
// bad
<component class="btn">
// good
<component cssClass="btn">
```
<component css-class="btn">
// bad
<component myProp="prop" />
// good
<component my-prop="prop" />
```
#### Alignment
- Follow these alignment styles for the template method:
......
......@@ -19,14 +19,24 @@
---
## Tooltips
Tooltips identify elements or provide additional, useful information about the referring elements. Tooltips are different from ALT-attributes, which are intended primarily for static images. Tooltips are summoned by:
* Hovering over an element with a cursor
* Focusing on an element with a keyboard (usually the tab key)
* Upon touch
### Usage
A tooltip should only be added if additional information is required.
A tooltip should be used:
* When there isn’t enough space to show the information
* When it isn’t critical for the user to see the information
* For icons that don’t have a label
Tooltips shouldn’t repeat information that is shown near the referring element. However, they can show the same data in a different format (e.g. date or timestamps).
![Tooltip usage](img/tooltip-usage.png)
### Placement
By default, tooltips should be placed below the element that they refer to. However, if there is not enough space in the viewpoint, the tooltip should be moved to the side as needed.
By default, tooltips should be placed below the referring element. However, if there isn’t enough space in the viewport, the tooltip should be moved to the side as needed.
![Tooltip placement location](img/tooltip-placement.png)
......
require 'spec_helper'
describe Profiles::NotificationsController do
let(:user) do
create(:user) do |user|
user.emails.create(email: 'original@example.com')
user.emails.create(email: 'new@example.com')
user.notification_email = 'original@example.com'
user.save!
end
end
describe 'GET show' do
it 'renders' do
sign_in(user)
get :show
expect(response).to render_template :show
end
end
describe 'POST update' do
it 'updates only permitted attributes' do
sign_in(user)
put :update, user: { notification_email: 'new@example.com', notified_of_own_activity: true, admin: true }
user.reload
expect(user.notification_email).to eq('new@example.com')
expect(user.notified_of_own_activity).to eq(true)
expect(user.admin).to eq(false)
expect(controller).to set_flash[:notice].to('Notification settings saved')
end
it 'shows an error message if the params are invalid' do
sign_in(user)
put :update, user: { notification_email: '' }
expect(user.reload.notification_email).to eq('original@example.com')
expect(controller).to set_flash[:alert].to('Failed to save new settings')
end
end
end
......@@ -4,7 +4,7 @@ FactoryGirl.define do
project factory: :empty_project
after(:create) do |board|
board.lists.create(list_type: :done)
board.lists.create(list_type: :closed)
end
end
end
......@@ -6,8 +6,8 @@ FactoryGirl.define do
sequence(:position)
end
factory :done_list, parent: :list do
list_type :done
factory :closed_list, parent: :list do
list_type :closed
label nil
position nil
end
......
......@@ -42,7 +42,7 @@ describe 'Issue Boards', feature: true, js: true do
end
it 'creates default lists' do
lists = ['To Do', 'Doing', 'Done']
lists = ['To Do', 'Doing', 'Closed']
page.within(find('.board-blank-state')) do
click_button('Add default lists')
......@@ -65,7 +65,7 @@ describe 'Issue Boards', feature: true, js: true do
let(:testing) { create(:label, project: project, name: 'Testing') }
let(:bug) { create(:label, project: project, name: 'Bug') }
let!(:backlog) { create(:label, project: project, name: 'Backlog') }
let!(:done) { create(:label, project: project, name: 'Done') }
let!(:closed) { create(:label, project: project, name: 'Closed') }
let!(:accepting) { create(:label, project: project, name: 'Accepting Merge Requests') }
let!(:list1) { create(:list, board: board, label: planning, position: 0) }
......@@ -114,7 +114,7 @@ describe 'Issue Boards', feature: true, js: true do
end
end
it 'search done list' do
it 'search closed list' do
find('.filtered-search').set(issue8.title)
find('.filtered-search').native.send_keys(:enter)
......@@ -186,13 +186,13 @@ describe 'Issue Boards', feature: true, js: true do
end
end
context 'done' do
it 'shows list of done issues' do
context 'closed' do
it 'shows list of closed issues' do
wait_for_board_cards(3, 1)
wait_for_ajax
end
it 'moves issue to done' do
it 'moves issue to closed' do
drag(list_from_index: 0, list_to_index: 2)
wait_for_board_cards(1, 7)
......@@ -205,7 +205,7 @@ describe 'Issue Boards', feature: true, js: true do
expect(find('.board:nth-child(3)')).not_to have_content(planning.title)
end
it 'removes all of the same issue to done' do
it 'removes all of the same issue to closed' do
drag(list_from_index: 0, list_to_index: 2)
wait_for_board_cards(1, 7)
......@@ -252,7 +252,7 @@ describe 'Issue Boards', feature: true, js: true do
expect(find('.board:nth-child(1)').all('.card').first).not_to have_content(planning.title)
end
it 'issue moves from done' do
it 'issue moves from closed' do
drag(list_from_index: 2, list_to_index: 1)
expect(find('.board:nth-child(2)')).to have_content(issue8.title)
......@@ -308,12 +308,12 @@ describe 'Issue Boards', feature: true, js: true do
expect(page).to have_selector('.board', count: 4)
end
it 'creates new list for Done label' do
it 'creates new list for Closed label' do
click_button 'Add list'
wait_for_ajax
page.within('.dropdown-menu-issues-board-new') do
click_link done.title
click_link closed.title
end
wait_for_vue_resource
......@@ -326,7 +326,7 @@ describe 'Issue Boards', feature: true, js: true do
wait_for_ajax
page.within('.dropdown-menu-issues-board-new') do
click_link done.title
click_link closed.title
end
wait_for_vue_resource
......
......@@ -25,7 +25,7 @@ describe 'Issue Boards new issue', feature: true, js: true do
expect(page).to have_selector('.board-issue-count-holder .btn', count: 1)
end
it 'does not display new issue button in done list' do
it 'does not display new issue button in closed list' do
page.within('.board:nth-child(2)') do
expect(page).not_to have_selector('.board-issue-count-holder .btn')
end
......
require 'spec_helper'
feature 'Profile > Notifications > User changes notified_of_own_activity setting', feature: true, js: true do
let(:user) { create(:user) }
before do
login_as(user)
end
scenario 'User opts into receiving notifications about their own activity' do
visit profile_notifications_path
expect(page).not_to have_checked_field('user[notified_of_own_activity]')
check 'user[notified_of_own_activity]'
expect(page).to have_content('Notification settings saved')
expect(page).to have_checked_field('user[notified_of_own_activity]')
end
scenario 'User opts out of receiving notifications about their own activity' do
user.update!(notified_of_own_activity: true)
visit profile_notifications_path
expect(page).to have_checked_field('user[notified_of_own_activity]')
uncheck 'user[notified_of_own_activity]'
expect(page).to have_content('Notification settings saved')
expect(page).not_to have_checked_field('user[notified_of_own_activity]')
end
end
......@@ -10,7 +10,7 @@
"id": { "type": "integer" },
"list_type": {
"type": "string",
"enum": ["label", "done"]
"enum": ["label", "closed"]
},
"label": {
"type": ["object", "null"],
......
......@@ -106,9 +106,9 @@ describe('Store', () => {
expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(false);
});
it('check for blank state adding when done list exist', () => {
it('check for blank state adding when closed list exist', () => {
gl.issueBoards.BoardsStore.addList({
list_type: 'done'
list_type: 'closed'
});
expect(gl.issueBoards.BoardsStore.shouldAddBlankState()).toBe(true);
......
......@@ -37,14 +37,33 @@ if (process.env.BABEL_ENV === 'coverage') {
const troubleMakers = [
'./blob_edit/blob_bundle.js',
'./boards/boards_bundle.js',
'./cycle_analytics/cycle_analytics_bundle.js',
'./cycle_analytics/components/stage_plan_component.js',
'./cycle_analytics/components/stage_staging_component.js',
'./cycle_analytics/components/stage_test_component.js',
'./commit/pipelines/pipelines_bundle.js',
'./diff_notes/diff_notes_bundle.js',
'./diff_notes/components/jump_to_discussion.js',
'./diff_notes/components/resolve_count.js',
'./dispatcher.js',
'./environments/environments_bundle.js',
'./filtered_search/filtered_search_bundle.js',
'./graphs/graphs_bundle.js',
'./issuable/issuable_bundle.js',
'./issuable/time_tracking/time_tracking_bundle.js',
'./main.js',
'./merge_conflicts/merge_conflicts_bundle.js',
'./merge_conflicts/components/inline_conflict_lines.js',
'./merge_conflicts/components/parallel_conflict_lines.js',
'./merge_request_widget/ci_bundle.js',
'./monitoring/monitoring_bundle.js',
'./network/network_bundle.js',
'./network/branch_graph.js',
'./profile/profile_bundle.js',
'./protected_branches/protected_branches_bundle.js',
'./snippet/snippet_bundle.js',
'./terminal/terminal_bundle.js',
'./users/users_bundle.js',
];
describe('Uncovered files', function () {
......
......@@ -19,8 +19,8 @@ describe List do
expect(subject).to validate_uniqueness_of(:label_id).scoped_to(:board_id)
end
context 'when list_type is set to done' do
subject { described_class.new(list_type: :done) }
context 'when list_type is set to closed' do
subject { described_class.new(list_type: :closed) }
it { is_expected.not_to validate_presence_of(:label) }
it { is_expected.not_to validate_presence_of(:position) }
......@@ -34,8 +34,8 @@ describe List do
expect(subject.destroy).to be_truthy
end
it 'can not be destroyed when when list_type is set to done' do
subject = create(:done_list)
it 'can not be destroyed when when list_type is set to closed' do
subject = create(:closed_list)
expect(subject.destroy).to be_falsey
end
......@@ -48,8 +48,8 @@ describe List do
expect(subject).to be_destroyable
end
it 'returns false when list_type is set to done' do
subject.list_type = :done
it 'returns false when list_type is set to closed' do
subject.list_type = :closed
expect(subject).not_to be_destroyable
end
......@@ -62,8 +62,8 @@ describe List do
expect(subject).to be_movable
end
it 'returns false when list_type is set to done' do
subject.list_type = :done
it 'returns false when list_type is set to closed' do
subject.list_type = :closed
expect(subject).not_to be_movable
end
......@@ -77,10 +77,10 @@ describe List do
expect(subject.title).to eq 'Development'
end
it 'returns Done when list_type is set to done' do
subject.list_type = :done
it 'returns Closed when list_type is set to closed' do
subject.list_type = :closed
expect(subject.title).to eq 'Done'
expect(subject.title).to eq 'Closed'
end
end
end
require 'spec_helper'
describe AfterBranchDeleteService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
......
......@@ -15,7 +15,7 @@ describe Boards::CreateService, services: true do
board = service.execute
expect(board.lists.size).to eq 1
expect(board.lists.first).to be_done
expect(board.lists.first).to be_closed
end
end
......
......@@ -18,7 +18,11 @@ describe Boards::Issues::ListService, services: true do
let!(:list1) { create(:list, board: board, label: development, position: 0) }
let!(:list2) { create(:list, board: board, label: testing, position: 1) }
<<<<<<< HEAD
let!(:done) { board.done_list }
=======
let!(:closed) { create(:closed_list, board: board) }
>>>>>>> ce/master
let!(:opened_issue1) { create(:labeled_issue, project: project, milestone: m1, title: 'Issue 1', labels: [bug]) }
let!(:opened_issue2) { create(:labeled_issue, project: project, milestone: m2, title: 'Issue 2', labels: [p2]) }
......@@ -58,10 +62,15 @@ describe Boards::Issues::ListService, services: true do
end
end
<<<<<<< HEAD
context 'when board have a milestone' do
it 'returns opened issues without board labels and milestone applied' do
params = { board_id: board.id }
board.update_attribute(:milestone, m1)
=======
it 'returns closed issues when listing issues from Closed' do
params = { board_id: board.id, id: closed.id }
>>>>>>> ce/master
issues = described_class.new(project, user, params).execute
......
......@@ -12,7 +12,11 @@ describe Boards::Issues::MoveService, services: true do
let!(:list1) { create(:list, board: board1, label: development, position: 0) }
let!(:list2) { create(:list, board: board1, label: testing, position: 1) }
<<<<<<< HEAD
let!(:done) { board1.done_list }
=======
let!(:closed) { create(:closed_list, board: board1) }
>>>>>>> ce/master
before do
project.team << [user, :developer]
......@@ -35,13 +39,13 @@ describe Boards::Issues::MoveService, services: true do
end
end
context 'when moving to done' do
context 'when moving to closed' do
let(:board2) { create(:board, project: project) }
let(:regression) { create(:label, project: project, name: 'Regression') }
let!(:list3) { create(:list, board: board2, label: regression, position: 1) }
let(:issue) { create(:labeled_issue, project: project, labels: [bug, development, testing, regression]) }
let(:params) { { board_id: board1.id, from_list_id: list2.id, to_list_id: done.id } }
let(:params) { { board_id: board1.id, from_list_id: list2.id, to_list_id: closed.id } }
it 'delegates the close proceedings to Issues::CloseService' do
expect_any_instance_of(Issues::CloseService).to receive(:execute).with(issue).once
......@@ -58,9 +62,9 @@ describe Boards::Issues::MoveService, services: true do
end
end
context 'when moving from done' do
context 'when moving from closed' do
let(:issue) { create(:labeled_issue, :closed, project: project, labels: [bug]) }
let(:params) { { board_id: board1.id, from_list_id: done.id, to_list_id: list2.id } }
let(:params) { { board_id: board1.id, from_list_id: closed.id, to_list_id: list2.id } }
it 'delegates the re-open proceedings to Issues::ReopenService' do
expect_any_instance_of(Issues::ReopenService).to receive(:execute).with(issue).once
......
......@@ -18,18 +18,18 @@ describe Boards::Lists::DestroyService, services: true do
development = create(:list, board: board, position: 0)
review = create(:list, board: board, position: 1)
staging = create(:list, board: board, position: 2)
done = board.done_list
closed = board.closed_list
described_class.new(project, user).execute(development)
expect(review.reload.position).to eq 0
expect(staging.reload.position).to eq 1
expect(done.reload.position).to be_nil
expect(closed.reload.position).to be_nil
end
end
it 'does not remove list from board when list type is done' do
list = board.done_list
it 'does not remove list from board when list type is closed' do
list = board.closed_list
service = described_class.new(project, user)
expect { service.execute(list) }.not_to change(board.lists, :count)
......
......@@ -10,7 +10,7 @@ describe Boards::Lists::ListService, services: true do
service = described_class.new(project, double)
expect(service.execute(board)).to eq [list, board.done_list]
expect(service.execute(board)).to eq [list, board.closed_list]
end
end
end
......@@ -10,7 +10,11 @@ describe Boards::Lists::MoveService, services: true do
let!(:development) { create(:list, board: board, position: 1) }
let!(:review) { create(:list, board: board, position: 2) }
let!(:staging) { create(:list, board: board, position: 3) }
<<<<<<< HEAD
let!(:done) { board.done_list }
=======
let!(:closed) { create(:closed_list, board: board) }
>>>>>>> ce/master
context 'when list type is set to label' do
it 'keeps position of lists when new position is nil' do
......@@ -86,10 +90,10 @@ describe Boards::Lists::MoveService, services: true do
end
end
it 'keeps position of lists when list type is done' do
it 'keeps position of lists when list type is closed' do
service = described_class.new(project, user, position: 2)
service.execute(done)
service.execute(closed)
expect(current_list_positions).to eq [0, 1, 2, 3]
end
......
require 'spec_helper'
describe Ci::CreatePipelineService, services: true do
let(:project) { FactoryGirl.create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:admin) }
before do
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Ci::CreateTriggerRequestService, services: true do
let(:service) { described_class.new }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:trigger) { create(:ci_trigger, project: project) }
before do
......
require 'spec_helper'
describe Ci::StopEnvironmentsService, services: true do
let(:project) { create(:project, :private) }
let(:project) { create(:project, :private, :repository) }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
......
require 'spec_helper'
describe Ci::UpdateBuildQueueService, :services do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:build) { create(:ci_build, pipeline: pipeline) }
let(:pipeline) { create(:ci_pipeline, project: project) }
......
require 'spec_helper'
describe CompareService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:service) { described_class.new(project, 'feature') }
......
require 'spec_helper'
describe CreateReleaseService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:tag_name) { project.repository.tag_names.first }
let(:description) { 'Awesome release!' }
......
require 'spec_helper'
describe DeleteBranchService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe DeleteMergedBranchesService, services: true do
subject(:service) { described_class.new(project, project.owner) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
context '#execute' do
context 'unprotected branches' do
......
......@@ -3,7 +3,7 @@ require "spec_helper"
describe Files::UpdateService do
subject { described_class.new(project, user, commit_params) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:file_path) { 'files/ruby/popen.rb' }
let(:new_contents) { 'New Content' }
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
describe GitHooksService, services: true do
include RepoHelpers
let(:user) { create :user }
let(:project) { create :project }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:service) { GitHooksService.new }
before do
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
describe GitPushService, services: true do
include RepoHelpers
let(:user) { create :user }
let(:project) { create :project }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
before do
project.team << [user, :master]
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
describe GitTagPushService, services: true do
include RepoHelpers
let(:user) { create :user }
let(:project) { create :project }
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:service) { GitTagPushService.new(project, user, oldrev: oldrev, newrev: newrev, ref: ref) }
let(:oldrev) { Gitlab::Git::BLANK_SHA }
......
......@@ -6,7 +6,7 @@ describe Groups::DestroyService, services: true do
let!(:user) { create(:user) }
let!(:group) { create(:group) }
let!(:nested_group) { create(:group, parent: group) }
let!(:project) { create(:project, namespace: group) }
let!(:project) { create(:empty_project, namespace: group) }
let!(:gitlab_shell) { Gitlab::Shell.new }
let!(:remove_path) { group.path + "+#{group.id}+deleted" }
......
......@@ -13,7 +13,7 @@ describe Groups::UpdateService, services: true do
before do
public_group.add_user(user, Gitlab::Access::MASTER)
create(:project, :public, group: public_group)
create(:empty_project, :public, group: public_group)
end
it "does not change permission level" do
......@@ -27,7 +27,7 @@ describe Groups::UpdateService, services: true do
before do
internal_group.add_user(user, Gitlab::Access::MASTER)
create(:project, :internal, group: internal_group)
create(:empty_project, :internal, group: internal_group)
end
it "does not change permission level" do
......@@ -80,7 +80,7 @@ describe Groups::UpdateService, services: true do
before do
internal_group.add_user(user, Gitlab::Access::MASTER)
create(:project, :internal, group: internal_group)
create(:empty_project, :internal, group: internal_group)
end
it 'returns true' do
......
require 'spec_helper.rb'
describe Issues::BuildService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
......
......@@ -5,8 +5,8 @@ describe Issues::MoveService, services: true do
let(:author) { create(:user) }
let(:title) { 'Some issue' }
let(:description) { 'Some issue description' }
let(:old_project) { create(:project) }
let(:new_project) { create(:project) }
let(:old_project) { create(:empty_project) }
let(:new_project) { create(:empty_project) }
let(:milestone1) { create(:milestone, project_id: old_project.id, title: 'v9.0') }
let(:old_issue) do
......
......@@ -10,7 +10,7 @@ class DummyService < Issues::BaseService
end
describe DummyService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
before do
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Labels::FindOrCreateService, services: true do
describe '#execute' do
let(:group) { create(:group) }
let(:project) { create(:project, namespace: group) }
let(:project) { create(:empty_project, namespace: group) }
let(:params) do
{
......
......@@ -6,8 +6,8 @@ describe Labels::TransferService, services: true do
let(:group_1) { create(:group) }
let(:group_2) { create(:group) }
let(:group_3) { create(:group) }
let(:project_1) { create(:project, namespace: group_2) }
let(:project_2) { create(:project, namespace: group_3) }
let(:project_1) { create(:empty_project, namespace: group_2) }
let(:project_2) { create(:empty_project, namespace: group_3) }
let(:group_label_1) { create(:group_label, group: group_1, name: 'Group Label 1') }
let(:group_label_2) { create(:group_label, group: group_1, name: 'Group Label 2') }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Members::DestroyService, services: true do
let(:user) { create(:user) }
let(:member_user) { create(:user) }
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:group) { create(:group, :public) }
shared_examples 'a service raising ActiveRecord::RecordNotFound' do
......
......@@ -29,7 +29,7 @@ describe Members::RequestAccessService, services: true do
end
context 'when current user cannot request access to the project' do
%i[project group].each do |source_type|
%i[empty_project group].each do |source_type|
it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
let(:source) { create(source_type, :private) }
end
......@@ -37,7 +37,7 @@ describe Members::RequestAccessService, services: true do
end
context 'when access requests are disabled' do
%i[project group].each do |source_type|
%i[empty_project group].each do |source_type|
it_behaves_like 'a service raising Gitlab::Access::AccessDeniedError' do
let(:source) { create(source_type, :public) }
end
......@@ -45,7 +45,7 @@ describe Members::RequestAccessService, services: true do
end
context 'when current user can request access to the project' do
%i[project group].each do |source_type|
%i[empty_project group].each do |source_type|
it_behaves_like 'a service creating a access request' do
let(:source) { create(source_type, :public, :access_requestable) }
end
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe MergeRequests::AddTodoWhenBuildFailsService do
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:sha) { '1234567890abcdef1234567890abcdef12345678' }
let(:ref) { merge_request.source_branch }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe MergeRequests::AssignIssuesService, services: true do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, :simple, source_project: project, author: user, description: "fixes #{issue.to_reference}") }
let(:service) { described_class.new(project, user, merge_request: merge_request) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe MergeRequests::BuildService, services: true do
include RepoHelpers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:issue_confidential) { false }
let(:issue) { create(:issue, project: project, title: 'A bug', confidential: issue_confidential) }
......
require 'spec_helper'
describe MergeRequests::CreateService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:assignee) { create(:user) }
......
require "spec_helper"
describe MergeRequests::GetUrlsService do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:service) { MergeRequests::GetUrlsService.new(project) }
let(:source_branch) { "my_branch" }
let(:new_merge_request_url) { "http://#{Gitlab.config.gitlab.host}/#{project.namespace.name}/#{project.path}/merge_requests/new?merge_request%5Bsource_branch%5D=#{source_branch}" }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe MergeRequests::MergeWhenPipelineSucceedsService do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:mr_merge_if_green_enabled) do
create(:merge_request, merge_when_pipeline_succeeds: true, merge_user: user,
......
require 'spec_helper'
describe MergeRequests::RefreshService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:service) { MergeRequests::RefreshService }
......@@ -11,7 +11,11 @@ describe MergeRequests::RefreshService, services: true do
group = create(:group)
group.add_owner(@user)
<<<<<<< HEAD
@project = create(:project, namespace: group, approvals_before_merge: 1, reset_approvals_on_push: true)
=======
@project = create(:project, :repository, namespace: group)
>>>>>>> ce/master
@fork_project = Projects::ForkService.new(@project, @user).execute
# The call to project.repository.after_import in RepositoryForkWorker does
# not reset the @exists variable of @fork_project.repository so we have to
......@@ -351,7 +355,7 @@ describe MergeRequests::RefreshService, services: true do
context 'when the merge request is sourced from a different project' do
it 'creates a `MergeRequestsClosingIssues` record for each issue closed by a commit' do
forked_project = create(:project)
forked_project = create(:project, :repository)
create(:forked_project_link, forked_to_project: forked_project, forked_from_project: @project)
merge_request = create(:merge_request,
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe MergeRequests::ResolveService do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:fork_project) do
create(:forked_project_with_submodules) do |fork_project|
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe MergeRequests::UpdateService, services: true do
include EmailHelpers
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:user2) { create(:user) }
let(:user3) { create(:user) }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Milestones::CloseService, services: true do
let(:user) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:milestone) { create(:milestone, title: "Milestone v1.2", project: project) }
before do
......
require 'spec_helper'
describe Notes::DiffPositionUpdateService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:create_commit) { project.commit("913c66a37b4a45b9769037c55c2d238bd0942d2e") }
let(:modify_commit) { project.commit("874797c3a73b60d2187ed6e2fcabd289ff75171e") }
let(:edit_commit) { project.commit("570e7b2abdd848b95f2f578043fc23bd6f6fd24d") }
......
......@@ -146,6 +146,16 @@ describe NotificationService, services: true do
should_not_email(@u_lazy_participant)
end
it "emails the note author if they've opted into notifications about their activity" do
add_users_with_subscription(note.project, issue)
note.author.notified_of_own_activity = true
reset_delivered_emails!
notification.new_note(note)
should_email(note.author)
end
it 'filters out "mentioned in" notes' do
mentioned_note = SystemNoteService.cross_reference(mentioned_issue, issue, issue.author)
......@@ -362,7 +372,7 @@ describe NotificationService, services: true do
end
context 'commit note' do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:note) { create(:note_on_commit, project: project) }
before do
......@@ -411,7 +421,7 @@ describe NotificationService, services: true do
end
context "merge request diff note" do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:merge_request) { create(:merge_request, source_project: project, assignee: user) }
let(:note) { create(:diff_note_on_merge_request, project: project, noteable: merge_request) }
......@@ -476,6 +486,20 @@ describe NotificationService, services: true do
should_not_email(issue.assignee)
end
it "emails the author if they've opted into notifications about their activity" do
issue.author.notified_of_own_activity = true
notification.new_issue(issue, issue.author)
should_email(issue.author)
end
it "doesn't email the author if they haven't opted into notifications about their activity" do
notification.new_issue(issue, issue.author)
should_not_email(issue.author)
end
it "emails subscribers of the issue's labels" do
user_1 = create(:user)
user_2 = create(:user)
......@@ -665,6 +689,19 @@ describe NotificationService, services: true do
should_email(subscriber_to_label_2)
end
it "emails the current user if they've opted into notifications about their activity" do
subscriber_to_label_2.notified_of_own_activity = true
notification.relabeled_issue(issue, [group_label_2, label_2], subscriber_to_label_2)
should_email(subscriber_to_label_2)
end
it "doesn't email the current user if they haven't opted into notifications about their activity" do
notification.relabeled_issue(issue, [group_label_2, label_2], subscriber_to_label_2)
should_not_email(subscriber_to_label_2)
end
it "doesn't send email to anyone but subscribers of the given labels" do
notification.relabeled_issue(issue, [group_label_2, label_2], @u_disabled)
......@@ -812,7 +849,7 @@ describe NotificationService, services: true do
describe 'Merge Requests' do
let(:group) { create(:group) }
let(:project) { create(:project, :public, namespace: group) }
let(:project) { create(:project, :public, :repository, namespace: group) }
let(:another_project) { create(:empty_project, :public, namespace: group) }
let(:merge_request) { create :merge_request, source_project: project, assignee: create(:user), description: 'cc @participant' }
......@@ -845,6 +882,20 @@ describe NotificationService, services: true do
should_not_email(@u_lazy_participant)
end
it "emails the author if they've opted into notifications about their activity" do
merge_request.author.notified_of_own_activity = true
notification.new_merge_request(merge_request, merge_request.author)
should_email(merge_request.author)
end
it "doesn't email the author if they haven't opted into notifications about their activity" do
notification.new_merge_request(merge_request, merge_request.author)
should_not_email(merge_request.author)
end
it "emails subscribers of the merge request's labels" do
user_1 = create(:user)
user_2 = create(:user)
......@@ -1075,6 +1126,14 @@ describe NotificationService, services: true do
should_not_email(@u_watcher)
end
it "notifies the merger when the pipeline succeeds is false but they've opted into notifications about their activity" do
merge_request.merge_when_pipeline_succeeds = false
@u_watcher.notified_of_own_activity = true
notification.merge_mr(merge_request, @u_watcher)
should_email(@u_watcher)
end
it_behaves_like 'participating notifications' do
let(:participant) { create(:user, username: 'user-participant') }
let(:issuable) { merge_request }
......@@ -1137,7 +1196,7 @@ describe NotificationService, services: true do
end
describe 'Projects' do
let(:project) { create :project }
let(:project) { create(:empty_project) }
before do
build_team(project)
......@@ -1182,7 +1241,7 @@ describe NotificationService, services: true do
describe 'ProjectMember' do
describe '#decline_group_invite' do
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:member) { create(:user) }
before(:each) do
......@@ -1256,7 +1315,7 @@ describe NotificationService, services: true do
describe 'Pipelines' do
describe '#pipeline_finished' do
let(:project) { create(:project, :public) }
let(:project) { create(:project, :public, :repository) }
let(:current_user) { create(:user) }
let(:u_member) { create(:user) }
let(:u_other) { create(:user) }
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::DestroyService, services: true do
let!(:user) { create(:user) }
let!(:project) { create(:project, namespace: user.namespace) }
let!(:project) { create(:project, :repository, namespace: user.namespace) }
let!(:path) { project.repository.path_to_repo }
let!(:remove_path) { path.sub(/\.git\Z/, "+#{project.id}+deleted.git") }
let!(:async) { false } # execute or async_execute
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
describe Projects::DownloadService, services: true do
describe 'File service' do
before do
@user = create :user
@project = create :project, creator_id: @user.id, namespace: @user.namespace
@user = create(:user)
@project = create(:empty_project, creator_id: @user.id, namespace: @user.namespace)
end
context 'for a URL that is not on whitelist' do
......
......@@ -7,6 +7,7 @@ describe Projects::ForkService, services: true do
@from_user = create(:user, namespace: @from_namespace )
avatar = fixture_file_upload(Rails.root + "spec/fixtures/dk.png", "image/png")
@from_project = create(:project,
:repository,
creator_id: @from_user.id,
namespace: @from_namespace,
star_count: 107,
......@@ -54,7 +55,7 @@ describe Projects::ForkService, services: true do
context 'project already exists' do
it "fails due to validation, not transaction failure" do
@existing_project = create(:project, creator_id: @to_user.id, name: @from_project.name, namespace: @to_namespace)
@existing_project = create(:project, :repository, creator_id: @to_user.id, name: @from_project.name, namespace: @to_namespace)
@to_project = fork_project(@from_project, @to_user)
expect(@existing_project).to be_persisted
......@@ -104,9 +105,10 @@ describe Projects::ForkService, services: true do
before do
@group_owner = create(:user)
@developer = create(:user)
@project = create(:project, creator_id: @group_owner.id,
star_count: 777,
description: 'Wow, such a cool project!')
@project = create(:project, :repository,
creator_id: @group_owner.id,
star_count: 777,
description: 'Wow, such a cool project!')
@group = create(:group)
@group.add_user(@group_owner, GroupMember::OWNER)
@group.add_user(@developer, GroupMember::DEVELOPER)
......@@ -139,8 +141,9 @@ describe Projects::ForkService, services: true do
context 'project already exists in group' do
it 'fails due to validation, not transaction failure' do
existing_project = create(:project, name: @project.name,
namespace: @group)
existing_project = create(:project, :repository,
name: @project.name,
namespace: @group)
to_project = fork_project(@project, @group_owner, @opts)
expect(existing_project.persisted?).to be_truthy
expect(to_project.errors[:name]).to eq(['has already been taken'])
......
......@@ -2,7 +2,7 @@ require 'spec_helper'
describe Projects::HousekeepingService do
subject { Projects::HousekeepingService.new(project) }
let(:project) { create :project }
let(:project) { create(:project, :repository) }
before do
project.reset_pushes_since_gc
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::TransferService, services: true do
let(:user) { create(:user) }
let(:group) { create(:group) }
let(:project) { create(:project, namespace: user.namespace) }
let(:project) { create(:project, :repository, namespace: user.namespace) }
context 'namespace -> namespace' do
before do
......@@ -58,7 +58,7 @@ describe Projects::TransferService, services: true do
before { internal_group.add_owner(user) }
context 'when namespace visibility level < project visibility level' do
let(:public_project) { create(:project, :public, namespace: user.namespace) }
let(:public_project) { create(:project, :public, :repository, namespace: user.namespace) }
before { transfer_project(public_project, user, internal_group) }
......@@ -66,7 +66,7 @@ describe Projects::TransferService, services: true do
end
context 'when namespace visibility level > project visibility level' do
let(:private_project) { create(:project, :private, namespace: user.namespace) }
let(:private_project) { create(:project, :private, :repository, namespace: user.namespace) }
before { transfer_project(private_project, user, internal_group) }
......
require "spec_helper"
describe Projects::UpdatePagesService do
let(:project) { create :project }
let(:pipeline) { create :ci_pipeline, project: project, sha: project.commit('HEAD').sha }
let(:build) { create :ci_build, pipeline: pipeline, ref: 'HEAD' }
let(:project) { create(:project, :repository) }
let(:pipeline) { create(:ci_pipeline, project: project, sha: project.commit('HEAD').sha) }
let(:build) { create(:ci_build, pipeline: pipeline, ref: 'HEAD') }
let(:invalid_file) { fixture_file_upload(Rails.root + 'spec/fixtures/dk.png') }
subject { described_class.new(project, build) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe Projects::UpdateService, services: true do
let(:user) { create(:user) }
let(:admin) { create(:admin) }
let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
let(:project) { create(:empty_project, creator_id: user.id, namespace: user.namespace) }
describe 'update_by_user' do
context 'when visibility_level is INTERNAL' do
......@@ -56,7 +56,7 @@ describe Projects::UpdateService, services: true do
end
describe 'visibility_level' do
let(:project) { create(:project, :internal) }
let(:project) { create(:empty_project, :internal) }
let(:forked_project) { create(:forked_project_with_submodules, :internal) }
before do
......
......@@ -3,8 +3,8 @@ require 'spec_helper'
describe Projects::UploadService, services: true do
describe 'File service' do
before do
@user = create :user
@project = create :project, creator_id: @user.id, namespace: @user.namespace
@user = create(:user)
@project = create(:empty_project, creator_id: @user.id, namespace: @user.namespace)
end
context 'for valid gif file' do
......
......@@ -44,7 +44,7 @@ describe 'Search::GlobalService', services: true do
context 'nested group' do
let!(:nested_group) { create(:group, :nested) }
let!(:project) { create(:project, namespace: nested_group) }
let!(:project) { create(:empty_project, namespace: nested_group) }
before { project.add_master(user) }
......
require 'spec_helper'
describe SlashCommands::InterpretService, services: true do
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:developer) { create(:user) }
let(:issue) { create(:issue, project: project) }
let(:milestone) { create(:milestone, project: project, title: '9.10') }
......@@ -260,6 +260,8 @@ describe SlashCommands::InterpretService, services: true do
end
shared_examples 'merge command' do
let(:project) { create(:project, :repository) }
it 'runs merge command if content contains /merge' do
_, updates = service.execute(content, issuable)
......@@ -339,6 +341,7 @@ describe SlashCommands::InterpretService, services: true do
end
context 'when sha is missing' do
let(:project) { create(:project, :repository) }
let(:service) { described_class.new(project, developer, {}) }
it 'precheck passes and returns merge command' do
......@@ -721,7 +724,7 @@ describe SlashCommands::InterpretService, services: true do
end
context '/target_branch command' do
let(:non_empty_project) { create(:project) }
let(:non_empty_project) { create(:project, :repository) }
let(:another_merge_request) { create(:merge_request, author: developer, source_project: non_empty_project) }
let(:service) { described_class.new(non_empty_project, developer)}
......
......@@ -15,7 +15,7 @@ describe SpamService, services: true do
end
context 'when recaptcha was not verified' do
let(:project) { create(:project, :public) }
let(:project) { create(:empty_project, :public) }
let(:issue) { create(:issue, project: project) }
let(:request) { double(:request, env: {}) }
......
require 'spec_helper'
describe SystemHooksService, services: true do
let(:user) { create :user }
let(:project) { create :project }
let(:project_member) { create :project_member }
let(:key) { create(:key, user: user) }
let(:deploy_key) { create(:key) }
let(:group) { create(:group) }
let(:group_member) { create(:group_member) }
let(:user) { create(:user) }
let(:project) { create(:empty_project) }
let(:project_member) { create(:project_member) }
let(:key) { create(:key, user: user) }
let(:deploy_key) { create(:key) }
let(:group) { create(:group) }
let(:group_member) { create(:group_member) }
context 'event data' do
it { expect(event_data(user, :create)).to include(:event_name, :name, :created_at, :updated_at, :email, :user_id, :username) }
......
......@@ -3,7 +3,7 @@ require 'spec_helper'
describe SystemNoteService, services: true do
include Gitlab::Routing.url_helpers
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:author) { create(:user) }
let(:noteable) { create(:issue, project: project) }
......@@ -32,6 +32,7 @@ describe SystemNoteService, services: true do
describe '.add_commits' do
subject { described_class.add_commits(noteable, project, author, new_commits, old_commits, oldrev) }
let(:project) { create(:project, :repository) }
let(:noteable) { create(:merge_request, source_project: project) }
let(:new_commits) { noteable.commits }
let(:old_commits) { [] }
......@@ -216,6 +217,7 @@ describe SystemNoteService, services: true do
end
describe '.merge_when_pipeline_succeeds' do
let(:project) { create(:project, :repository) }
let(:pipeline) { build(:ci_pipeline_without_jobs )}
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
......@@ -226,11 +228,12 @@ describe SystemNoteService, services: true do
it_behaves_like 'a system note'
it "posts the 'merge when pipeline succeeds' system note" do
expect(subject.note).to match /enabled an automatic merge when the pipeline for (\w+\/\w+@)?\h{40} succeeds/
expect(subject.note).to match(/enabled an automatic merge when the pipeline for (\w+\/\w+@)?\h{40} succeeds/)
end
end
describe '.cancel_merge_when_pipeline_succeeds' do
let(:project) { create(:project, :repository) }
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
end
......@@ -273,6 +276,8 @@ describe SystemNoteService, services: true do
describe '.change_branch' do
subject { described_class.change_branch(noteable, project, author, 'target', old_branch, new_branch) }
let(:project) { create(:project, :repository) }
let(:old_branch) { 'old_branch'}
let(:new_branch) { 'new_branch'}
......@@ -288,6 +293,8 @@ describe SystemNoteService, services: true do
describe '.change_branch_presence' do
subject { described_class.change_branch_presence(noteable, project, author, :source, 'feature', :delete) }
let(:project) { create(:project, :repository) }
it_behaves_like 'a system note'
context 'when source branch deleted' do
......@@ -300,11 +307,13 @@ describe SystemNoteService, services: true do
describe '.new_issue_branch' do
subject { described_class.new_issue_branch(noteable, project, author, "1-mepmep") }
let(:project) { create(:project, :repository) }
it_behaves_like 'a system note'
context 'when a branch is created from the new branch button' do
it 'sets the note text' do
expect(subject.note).to match /\Acreated branch [`1-mepmep`]/
expect(subject.note).to start_with("created branch [`1-mepmep`]")
end
end
end
......@@ -333,7 +342,7 @@ describe SystemNoteService, services: true do
describe 'note_body' do
context 'cross-project' do
let(:project2) { create(:project) }
let(:project2) { create(:project, :repository) }
let(:mentioner) { create(:issue, project: project2) }
context 'from Commit' do
......@@ -353,6 +362,7 @@ describe SystemNoteService, services: true do
context 'within the same project' do
context 'from Commit' do
let(:project) { create(:project, :repository) }
let(:mentioner) { project.repository.commit }
it 'references the mentioning commit' do
......@@ -394,6 +404,7 @@ describe SystemNoteService, services: true do
end
context 'when mentioner is a MergeRequest' do
let(:project) { create(:project, :repository) }
let(:mentioner) { create(:merge_request, :simple, source_project: project) }
let(:noteable) { project.commit }
......@@ -421,6 +432,7 @@ describe SystemNoteService, services: true do
end
describe '.cross_reference_exists?' do
let(:project) { create(:project, :repository) }
let(:commit0) { project.commit }
let(:commit1) { project.commit('HEAD~2') }
......@@ -520,7 +532,7 @@ describe SystemNoteService, services: true do
end
describe '.noteable_moved' do
let(:new_project) { create(:project) }
let(:new_project) { create(:empty_project) }
let(:new_noteable) { create(:issue, project: new_project) }
subject do
......@@ -549,7 +561,7 @@ describe SystemNoteService, services: true do
it_behaves_like 'cross project mentionable'
it 'notifies about noteable being moved to' do
expect(subject.note).to match /moved to/
expect(subject.note).to match('moved to')
end
end
......@@ -559,7 +571,7 @@ describe SystemNoteService, services: true do
it_behaves_like 'cross project mentionable'
it 'notifies about noteable being moved from' do
expect(subject.note).to match /moved from/
expect(subject.note).to match('moved from')
end
end
......@@ -581,13 +593,13 @@ describe SystemNoteService, services: true do
end
end
include JiraServiceHelper
describe 'JIRA integration' do
include JiraServiceHelper
let(:project) { create(:jira_project) }
let(:author) { create(:user) }
let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, :simple, target_project: project, source_project: project) }
let(:merge_request) { create(:merge_request, :simple, target_project: project, source_project: project) }
let(:jira_issue) { ExternalIssue.new("JIRA-1", project)}
let(:jira_tracker) { project.jira_service }
let(:commit) { project.commit }
......@@ -894,6 +906,7 @@ describe SystemNoteService, services: true do
end
describe '.add_merge_request_wip_from_commit' do
let(:project) { create(:project, :repository) }
let(:noteable) do
create(:merge_request, source_project: project, target_project: project)
end
......
require 'spec_helper'
describe Tags::CreateService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
......
require 'spec_helper'
describe Tags::DestroyService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:repository) { project.repository }
let(:user) { create(:user) }
let(:service) { described_class.new(project, user) }
......
require 'spec_helper'
describe TestHookService, services: true do
<<<<<<< HEAD
let(:user) { create :user }
let(:group) { create :group }
let(:project) { create :project, group: group }
let(:project_hook) { create :project_hook, project: project }
let(:group_hook) { create :group_hook, group: group }
=======
let(:user) { create(:user) }
let(:project) { create(:project, :repository) }
let(:hook) { create(:project_hook, project: project) }
>>>>>>> ce/master
describe '#execute' do
it "successfully executes the project hook" do
......
......@@ -8,7 +8,7 @@ describe TodoService, services: true do
let(:guest) { create(:user) }
let(:admin) { create(:admin) }
let(:john_doe) { create(:user) }
let(:project) { create(:project) }
let(:project) { create(:empty_project) }
let(:mentions) { 'FYI: ' + [author, assignee, john_doe, member, guest, non_member, admin].map(&:to_reference).join(' ') }
let(:directly_addressed) { [author, assignee, john_doe, member, guest, non_member, admin].map(&:to_reference).join(' ') }
let(:directly_addressed_and_mentioned) { member.to_reference + ", what do you think? cc: " + [guest, admin].map(&:to_reference).join(' ') }
......@@ -99,9 +99,9 @@ describe TodoService, services: true do
end
context 'when a private group is mentioned' do
let(:group) { create :group, :private }
let(:project) { create :project, :private, group: group }
let(:issue) { create :issue, author: author, project: project, description: group.to_reference }
let(:group) { create(:group, :private) }
let(:project) { create(:empty_project, :private, group: group) }
let(:issue) { create(:issue, author: author, project: project, description: group.to_reference) }
before do
group.add_owner(author)
......@@ -422,22 +422,26 @@ describe TodoService, services: true do
should_create_todo(user: john_doe, target: confidential_issue, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_confidential_issue)
end
it 'creates a todo for each valid mentioned user when leaving a note on commit' do
service.new_note(note_on_commit, john_doe)
context 'on commit' do
let(:project) { create(:project, :repository) }
should_create_todo(user: member, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_create_todo(user: author, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_create_todo(user: john_doe, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_not_create_todo(user: non_member, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
end
it 'creates a todo for each valid mentioned user when leaving a note on commit' do
service.new_note(note_on_commit, john_doe)
should_create_todo(user: member, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_create_todo(user: author, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_create_todo(user: john_doe, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
should_not_create_todo(user: non_member, target_id: nil, target_type: 'Commit', commit_id: note_on_commit.commit_id, author: john_doe, action: Todo::MENTIONED, note: note_on_commit)
end
it 'creates a directly addressed todo for each valid mentioned user when leaving a note on commit' do
service.new_note(addressed_note_on_commit, john_doe)
it 'creates a directly addressed todo for each valid mentioned user when leaving a note on commit' do
service.new_note(addressed_note_on_commit, john_doe)
should_create_todo(user: member, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_create_todo(user: author, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_create_todo(user: john_doe, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_not_create_todo(user: non_member, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_create_todo(user: member, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_create_todo(user: author, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_create_todo(user: john_doe, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
should_not_create_todo(user: non_member, target_id: nil, target_type: 'Commit', commit_id: addressed_note_on_commit.commit_id, author: john_doe, action: Todo::DIRECTLY_ADDRESSED, note: addressed_note_on_commit)
end
end
it 'does not create todo when leaving a note on snippet' do
......@@ -750,6 +754,7 @@ describe TodoService, services: true do
end
describe '#new_note' do
let(:project) { create(:project, :repository) }
let(:mention) { john_doe.to_reference }
let(:diff_note_on_merge_request) { create(:diff_note_on_merge_request, project: project, noteable: mr_unassigned, author: author, note: "Hey #{mention}") }
let(:addressed_diff_note_on_merge_request) { create(:diff_note_on_merge_request, project: project, noteable: mr_unassigned, author: author, note: "#{mention}, hey!") }
......
require 'spec_helper'
describe UpdateReleaseService, services: true do
let(:project) { create(:project) }
let(:project) { create(:project, :repository) }
let(:user) { create(:user) }
let(:tag_name) { project.repository.tag_names.first }
let(:description) { 'Awesome release!' }
......
......@@ -5,7 +5,7 @@ describe Users::DestroyService, services: true do
let!(:user) { create(:user) }
let!(:admin) { create(:admin) }
let!(:namespace) { create(:namespace, owner: user) }
let!(:project) { create(:project, namespace: namespace) }
let!(:project) { create(:empty_project, namespace: namespace) }
let(:service) { described_class.new(admin) }
context 'no options are given' do
......@@ -25,7 +25,7 @@ describe Users::DestroyService, services: true do
end
context "a deleted user's issues" do
let(:project) { create :project }
let(:project) { create(:project) }
before do
project.add_developer(user)
......
......@@ -152,7 +152,7 @@ describe Users::RefreshAuthorizedProjectsService do
context 'projects of groups the user is a member of' do
let(:group) { create(:group) }
let!(:other_project) { create(:project, group: group) }
let!(:other_project) { create(:empty_project, group: group) }
before do
group.add_owner(user)
......@@ -166,7 +166,7 @@ describe Users::RefreshAuthorizedProjectsService do
context 'projects of subgroups of groups the user is a member of' do
let(:group) { create(:group) }
let(:nested_group) { create(:group, parent: group) }
let!(:other_project) { create(:project, group: nested_group) }
let!(:other_project) { create(:empty_project, group: nested_group) }
before do
group.add_master(user)
......
......@@ -2,7 +2,7 @@
# It can take a `default_params`.
shared_examples 'new issuable record that supports slash commands' do
let!(:project) { create(:project) }
let!(:project) { create(:project, :repository) }
let(:user) { create(:user).tap { |u| project.team << [u, :master] } }
let(:assignee) { create(:user) }
let!(:milestone) { create(:milestone, project: project) }
......
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