Commit ed3f2674 authored by Kamil Trzcinski's avatar Kamil Trzcinski

Merge branch 'ci-commit-as-pipeline' into with-pipeline-view

* ci-commit-as-pipeline: (131 commits)
  Optimise Merge Request builds rendering
  Fix migrations on MySQL
  Update db/schema.rb
  Cleanup changes
  Cleanup required migrations
  Add indexes concurrently on PostgreSQL
  Fix CiStatus implementation and tests
  Fix group_member_spec to not leak information
  Fix doc for moving an issue
  Update tests for moving issues via API
  Tie example config to JIRA screenshot
  API: Ability to move an issue
  Added ability to add custom tags to transactions
  API: Avoid group leak while updating the group
  API: Return 404 if user does not have access to group
  Move 'New branch from issue' feature doc to web_editor.md
  Fix repository cache invalidation issue when project is recreated with an empty repo
  improve formatting
  Add `Gitlab.com?` method
  (doc) fix typo to ssh keys doc url
  ...

Conflicts:
	app/controllers/projects/pipelines_controller.rb
	app/helpers/ci_status_helper.rb
	app/helpers/gitlab_routing_helper.rb
	app/views/projects/ci/commits/_commit.html.haml
	app/views/projects/commit/_ci_commit.html.haml
parents f5d24e60 9e68109f
Please view this file on the master branch, on stable branches it's out of date. Please view this file on the master branch, on stable branches it's out of date.
v 8.7.0 (unreleased) v 8.7.0 (unreleased)
- All service classes (those residing in app/services) are now instrumented (Yorick Peterse)
- Developers can now add custom tags to transactions (Yorick Peterse)
- Enable gzip for assets, makes the page size significantly smaller. !3544 / !3632 (Connor Shea) - Enable gzip for assets, makes the page size significantly smaller. !3544 / !3632 (Connor Shea)
- Load award emoji images separately unless opening the full picker. Saves several hundred KBs of data for most pages. (Connor Shea) - Load award emoji images separately unless opening the full picker. Saves several hundred KBs of data for most pages. (Connor Shea)
- All images in discussions and wikis now link to their source files !3464 (Connor Shea). - All images in discussions and wikis now link to their source files !3464 (Connor Shea).
- Return status code 303 after a branch DELETE operation to avoid project deletion (Stan Hu) - Return status code 303 after a branch DELETE operation to avoid project deletion (Stan Hu)
- Add setting for customizing the list of trusted proxies !3524
- Fix `signed_in_ip` being set to 127.0.0.1 when using a reverse proxy !3524
- Improved Markdown rendering performance !3389 (Yorick Peterse) - Improved Markdown rendering performance !3389 (Yorick Peterse)
- Don't attempt to look up an avatar in repo if repo directory does not exist (Stan Hu) - Don't attempt to look up an avatar in repo if repo directory does not exist (Stan Hu)
- Expose project badges in project settings - Expose project badges in project settings
...@@ -12,28 +16,46 @@ v 8.7.0 (unreleased) ...@@ -12,28 +16,46 @@ v 8.7.0 (unreleased)
- Make HTTP(s) label consistent on clone bar (Stan Hu) - Make HTTP(s) label consistent on clone bar (Stan Hu)
- Expose label description in API (Mariusz Jachimowicz) - Expose label description in API (Mariusz Jachimowicz)
- Allow back dating on issues when created through the API - Allow back dating on issues when created through the API
- API: Ability to update a group (Robert Schilling)
- API: Ability to move issues (Robert Schilling)
- Fix Error 500 after renaming a project path (Stan Hu) - Fix Error 500 after renaming a project path (Stan Hu)
- Fix avatar stretching by providing a cropping feature - Fix avatar stretching by providing a cropping feature
- API: Expose `subscribed` for issues and merge requests (Robert Schilling) - API: Expose `subscribed` for issues and merge requests (Robert Schilling)
- Allow SAML to handle external users based on user's information !3530 - Allow SAML to handle external users based on user's information !3530
- Allow Omniauth providers to be marked as `external` !3657
- Add endpoints to archive or unarchive a project !3372 - Add endpoints to archive or unarchive a project !3372
- Add links to CI setup documentation from project settings and builds pages - Add links to CI setup documentation from project settings and builds pages
- Handle nil descriptions in Slack issue messages (Stan Hu) - Handle nil descriptions in Slack issue messages (Stan Hu)
- API: Expose open_issues_count, closed_issues_count, open_merge_requests_count for labels (Robert Schilling)
- Add default scope to projects to exclude projects pending deletion - Add default scope to projects to exclude projects pending deletion
- Allow to close merge requests which source projects(forks) are deleted.
- Ensure empty recipients are rejected in BuildsEmailService - Ensure empty recipients are rejected in BuildsEmailService
- API: Ability to filter milestones by state `active` and `closed` (Robert Schilling) - API: Ability to filter milestones by state `active` and `closed` (Robert Schilling)
- API: Fix milestone filtering by `iid` (Robert Schilling)
- API: Delete notes of issues, snippets, and merge requests (Robert Schilling)
- Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.) - Implement 'Groups View' as an option for dashboard preferences !3379 (Elias W.)
- Better errors handling when creating milestones inside groups - Better errors handling when creating milestones inside groups
- Hide `Create a group` help block when creating a new project in a group
- Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.) - Implement 'TODOs View' as an option for dashboard preferences !3379 (Elias W.)
- Gracefully handle notes on deleted commits in merge requests (Stan Hu) - Gracefully handle notes on deleted commits in merge requests (Stan Hu)
- Decouple membership and notifications
- Fix creation of merge requests for orphaned branches (Stan Hu) - Fix creation of merge requests for orphaned branches (Stan Hu)
- API: Ability to retrieve a single tag (Robert Schilling)
- Fall back to `In-Reply-To` and `References` headers when sub-addressing is not available (David Padilla) - Fall back to `In-Reply-To` and `References` headers when sub-addressing is not available (David Padilla)
- Remove "Congratulations!" tweet button on newly-created project. (Connor Shea) - Remove "Congratulations!" tweet button on newly-created project. (Connor Shea)
- Fix admin/projects when using visibility levels on search (PotHix) - Fix admin/projects when using visibility levels on search (PotHix)
- Build status notifications - Build status notifications
- API: Expose user location (Robert Schilling) - API: Expose user location (Robert Schilling)
- API: Do not leak group existence via return code (Robert Schilling)
- ClosingIssueExtractor regex now also works with colons. e.g. "Fixes: #1234" !3591 - ClosingIssueExtractor regex now also works with colons. e.g. "Fixes: #1234" !3591
- Update number of Todos in the sidebar when it's marked as "Done". !3600 - Update number of Todos in the sidebar when it's marked as "Done". !3600
- API: Expose 'updated_at' for issue, snippet, and merge request notes (Robert Schilling)
- API: User can leave a project through the API when not master or owner. !3613
- Fix repository cache invalidation issue when project is recreated with an empty repo (Stan Hu)
v 8.6.6
- Fix error on language detection when repository has no HEAD (e.g., master branch). !3654 (Jeroen Bobbeldijk)
- Project switcher uses new dropdown styling
v 8.6.5 v 8.6.5
- Fix importing from GitHub Enterprise. !3529 - Fix importing from GitHub Enterprise. !3529
......
...@@ -285,9 +285,9 @@ group :development, :test do ...@@ -285,9 +285,9 @@ group :development, :test do
gem 'teaspoon', '~> 1.1.0' gem 'teaspoon', '~> 1.1.0'
gem 'teaspoon-jasmine', '~> 2.2.0' gem 'teaspoon-jasmine', '~> 2.2.0'
gem 'spring', '~> 1.6.4' gem 'spring', '~> 1.7.0'
gem 'spring-commands-rspec', '~> 1.0.4' gem 'spring-commands-rspec', '~> 1.0.4'
gem 'spring-commands-spinach', '~> 1.0.0' gem 'spring-commands-spinach', '~> 1.1.0'
gem 'spring-commands-teaspoon', '~> 0.0.2' gem 'spring-commands-teaspoon', '~> 0.0.2'
gem 'rubocop', '~> 0.38.0', require: false gem 'rubocop', '~> 0.38.0', require: false
......
...@@ -769,10 +769,10 @@ GEM ...@@ -769,10 +769,10 @@ GEM
spinach (>= 0.4) spinach (>= 0.4)
spinach-rerun-reporter (0.0.2) spinach-rerun-reporter (0.0.2)
spinach (~> 0.8) spinach (~> 0.8)
spring (1.6.4) spring (1.7.1)
spring-commands-rspec (1.0.4) spring-commands-rspec (1.0.4)
spring (>= 0.9.1) spring (>= 0.9.1)
spring-commands-spinach (1.0.0) spring-commands-spinach (1.1.0)
spring (>= 0.9.1) spring (>= 0.9.1)
spring-commands-teaspoon (0.0.2) spring-commands-teaspoon (0.0.2)
spring (>= 0.9.1) spring (>= 0.9.1)
...@@ -1030,9 +1030,9 @@ DEPENDENCIES ...@@ -1030,9 +1030,9 @@ DEPENDENCIES
slack-notifier (~> 1.2.0) slack-notifier (~> 1.2.0)
spinach-rails (~> 0.2.1) spinach-rails (~> 0.2.1)
spinach-rerun-reporter (~> 0.0.2) spinach-rerun-reporter (~> 0.0.2)
spring (~> 1.6.4) spring (~> 1.7.0)
spring-commands-rspec (~> 1.0.4) spring-commands-rspec (~> 1.0.4)
spring-commands-spinach (~> 1.0.0) spring-commands-spinach (~> 1.1.0)
spring-commands-teaspoon (~> 0.0.2) spring-commands-teaspoon (~> 0.0.2)
sprockets (~> 3.6.0) sprockets (~> 3.6.0)
state_machines-activerecord (~> 0.3.0) state_machines-activerecord (~> 0.3.0)
......
...@@ -41,6 +41,7 @@ ...@@ -41,6 +41,7 @@
#= require shortcuts_issuable #= require shortcuts_issuable
#= require shortcuts_network #= require shortcuts_network
#= require jquery.nicescroll #= require jquery.nicescroll
#= require date.format
#= require_tree . #= require_tree .
#= require fuzzaldrin-plus #= require fuzzaldrin-plus
#= require cropper #= require cropper
...@@ -163,7 +164,7 @@ $ -> ...@@ -163,7 +164,7 @@ $ ->
$('.trigger-submit').on 'change', -> $('.trigger-submit').on 'change', ->
$(@).parents('form').submit() $(@).parents('form').submit()
$('abbr.timeago, .js-timeago').timeago() gl.utils.localTimeAgo($('abbr.timeago, .js-timeago'), false)
# Flash # Flash
if (flash = $(".flash-container")).length > 0 if (flash = $(".flash-container")).length > 0
......
...@@ -35,4 +35,18 @@ $.fn.requiresInput = -> ...@@ -35,4 +35,18 @@ $.fn.requiresInput = ->
$form.on 'change input', fieldSelector, requireInput $form.on 'change input', fieldSelector, requireInput
$ -> $ ->
$('form.js-requires-input').requiresInput() $form = $('form.js-requires-input')
$form.requiresInput()
# Hide or Show the help block when creating a new project
# based on the option selected
hideOrShowHelpBlock = (form) ->
selected = $('.js-select-namespace option:selected')
if selected.length and selected.data('options-parent') is 'groups'
return form.find('.help-block').hide()
else if selected.length
form.find('.help-block').show()
hideOrShowHelpBlock($form)
$('.select2.js-select-namespace').change -> hideOrShowHelpBlock($form)
...@@ -122,7 +122,9 @@ class GitLabDropdown ...@@ -122,7 +122,9 @@ class GitLabDropdown
FILTER_INPUT = '.dropdown-input .dropdown-input-field' FILTER_INPUT = '.dropdown-input .dropdown-input-field'
constructor: (@el, @options) -> constructor: (@el, @options) ->
@dropdown = $(@el).parent() self = @
selector = $(@el).data "target"
@dropdown = if selector? then $(selector) else $(@el).parent()
# Set Defaults # Set Defaults
{ {
......
...@@ -218,7 +218,7 @@ class @LabelsSelect ...@@ -218,7 +218,7 @@ class @LabelsSelect
selectable: true selectable: true
toggleLabel: (selected) -> toggleLabel: (selected) ->
if selected and selected.title isnt 'Any Label' if selected and selected.title?
selected.title selected.title
else else
defaultLabel defaultLabel
......
((w) ->
w.gl ?= {}
w.gl.utils ?= {}
w.gl.utils.formatDate = (datetime) ->
dateFormat(datetime, 'mmm d, yyyy h:MMtt Z')
w.gl.utils.localTimeAgo = ($timeagoEls, setTimeago = true) ->
$timeagoEls.each( ->
$el = $(@)
$el.attr('title', gl.utils.formatDate($el.attr('datetime')))
)
$timeagoEls.timeago() if setTimeago
) window
...@@ -2,6 +2,11 @@ ...@@ -2,6 +2,11 @@
notificationGranted = (message, opts, onclick) -> notificationGranted = (message, opts, onclick) ->
notification = new Notification(message, opts) notification = new Notification(message, opts)
# Hide the notification after X amount of seconds
setTimeout ->
notification.close()
, 8000
if onclick if onclick
notification.onclick = onclick notification.onclick = onclick
......
...@@ -142,7 +142,7 @@ class @MergeRequestTabs ...@@ -142,7 +142,7 @@ class @MergeRequestTabs
url: "#{source}.json" url: "#{source}.json"
success: (data) => success: (data) =>
document.querySelector("div#commits").innerHTML = data.html document.querySelector("div#commits").innerHTML = data.html
$('.js-timeago').timeago() gl.utils.localTimeAgo($('.js-timeago', 'div#commits'))
@commitsLoaded = true @commitsLoaded = true
@scrollToElement("#commits") @scrollToElement("#commits")
...@@ -153,7 +153,7 @@ class @MergeRequestTabs ...@@ -153,7 +153,7 @@ class @MergeRequestTabs
url: "#{source}.json" + @_location.search url: "#{source}.json" + @_location.search
success: (data) => success: (data) =>
document.querySelector("div#diffs").innerHTML = data.html document.querySelector("div#diffs").innerHTML = data.html
$('.js-timeago').timeago() gl.utils.localTimeAgo($('.js-timeago', 'div#diffs'))
$('div#diffs .js-syntax-highlight').syntaxHighlight() $('div#diffs .js-syntax-highlight').syntaxHighlight()
@expandViewContainer() if @diffViewType() is 'parallel' @expandViewContainer() if @diffViewType() is 'parallel'
@diffsLoaded = true @diffsLoaded = true
...@@ -166,7 +166,7 @@ class @MergeRequestTabs ...@@ -166,7 +166,7 @@ class @MergeRequestTabs
url: "#{source}.json" url: "#{source}.json"
success: (data) => success: (data) =>
document.querySelector("div#builds").innerHTML = data.html document.querySelector("div#builds").innerHTML = data.html
$('.js-timeago').timeago() gl.utils.localTimeAgo($('.js-timeago', 'div#builds'))
@buildsLoaded = true @buildsLoaded = true
@scrollToElement("#builds") @scrollToElement("#builds")
......
...@@ -12,10 +12,19 @@ class @MergeRequestWidget ...@@ -12,10 +12,19 @@ class @MergeRequestWidget
@readyForCICheck = true @readyForCICheck = true
clearInterval @fetchBuildStatusInterval clearInterval @fetchBuildStatusInterval
@clearEventListeners()
@addEventListeners()
@pollCIStatus() @pollCIStatus()
notifyPermissions() notifyPermissions()
setOpts: (@opts) -> clearEventListeners: ->
$(document).off 'page:change.merge_request'
addEventListeners: ->
$(document).on 'page:change.merge_request', =>
if $('body').data('page') isnt 'projects:merge_requests:show'
clearInterval @fetchBuildStatusInterval
@clearEventListeners()
mergeInProgress: (deleteSourceBranch = false)-> mergeInProgress: (deleteSourceBranch = false)->
$.ajax $.ajax
...@@ -38,7 +47,7 @@ class @MergeRequestWidget ...@@ -38,7 +47,7 @@ class @MergeRequestWidget
$('.mr-state-widget').replaceWith(data) $('.mr-state-widget').replaceWith(data)
ciLabelForStatus: (status) -> ciLabelForStatus: (status) ->
if status == 'success' if status is 'success'
'passed' 'passed'
else else
status status
...@@ -67,18 +76,28 @@ class @MergeRequestWidget ...@@ -67,18 +76,28 @@ class @MergeRequestWidget
@opts.ci_status = data.status @opts.ci_status = data.status
return return
if data.status isnt @opts.ci_status if data.status isnt @opts.ci_status and data.status?
@showCIStatus data.status @showCIStatus data.status
if data.coverage if data.coverage
@showCICoverage data.coverage @showCICoverage data.coverage
if showNotification if showNotification
message = @opts.ci_message.replace('{{status}}', @ciLabelForStatus(data.status)) status = @ciLabelForStatus(data.status)
if status is "preparing"
title = @opts.ci_title.preparing
status = status.charAt(0).toUpperCase() + status.slice(1);
message = @opts.ci_message.preparing.replace('{{status}}', status)
else
title = @opts.ci_title.normal
message = @opts.ci_message.normal.replace('{{status}}', status)
title = title.replace('{{status}}', status)
message = message.replace('{{sha}}', data.sha) message = message.replace('{{sha}}', data.sha)
message = message.replace('{{title}}', data.title) message = message.replace('{{title}}', data.title)
notify( notify(
"Build #{@ciLabelForStatus(data.status)}", title,
message, message,
@opts.gitlab_icon, @opts.gitlab_icon,
-> ->
...@@ -98,6 +117,8 @@ class @MergeRequestWidget ...@@ -98,6 +117,8 @@ class @MergeRequestWidget
@setMergeButtonClass('btn-danger') @setMergeButtonClass('btn-danger')
when "running", "pending" when "running", "pending"
@setMergeButtonClass('btn-warning') @setMergeButtonClass('btn-warning')
when "success"
@setMergeButtonClass('btn-create')
else else
$('.ci_widget.ci-error').show() $('.ci_widget.ci-error').show()
@setMergeButtonClass('btn-danger') @setMergeButtonClass('btn-danger')
...@@ -107,4 +128,6 @@ class @MergeRequestWidget ...@@ -107,4 +128,6 @@ class @MergeRequestWidget
$('.ci_widget:visible .ci-coverage').text(text) $('.ci_widget:visible .ci-coverage').text(text)
setMergeButtonClass: (css_class) -> setMergeButtonClass: (css_class) ->
$('.accept_merge_request').removeClass("btn-create").addClass(css_class) $('.accept_merge_request')
.removeClass('btn-danger btn-warning btn-create')
.addClass(css_class)
...@@ -163,9 +163,15 @@ class @Notes ...@@ -163,9 +163,15 @@ class @Notes
else if @isNewNote(note) else if @isNewNote(note)
@note_ids.push(note.id) @note_ids.push(note.id)
$('ul.main-notes-list') $notesList = $('ul.main-notes-list')
$notesList
.append(note.html) .append(note.html)
.syntaxHighlight() .syntaxHighlight()
# Update datetime format on the recent note
gl.utils.localTimeAgo($notesList.find("#note_#{note.id} .js-timeago"), false)
@initTaskList() @initTaskList()
@updateNotesCount(1) @updateNotesCount(1)
...@@ -217,6 +223,8 @@ class @Notes ...@@ -217,6 +223,8 @@ class @Notes
# append new note to all matching discussions # append new note to all matching discussions
discussionContainer.append note_html discussionContainer.append note_html
gl.utils.localTimeAgo($('.js-timeago', note_html), false)
@updateNotesCount(1) @updateNotesCount(1)
### ###
...@@ -345,7 +353,9 @@ class @Notes ...@@ -345,7 +353,9 @@ class @Notes
updateNote: (_xhr, note, _status) => updateNote: (_xhr, note, _status) =>
# Convert returned HTML to a jQuery object so we can modify it further # Convert returned HTML to a jQuery object so we can modify it further
$html = $(note.html) $html = $(note.html)
$('.js-timeago', $html).timeago()
gl.utils.localTimeAgo($('.js-timeago', $html))
$html.syntaxHighlight() $html.syntaxHighlight()
$html.find('.js-task-list-container').taskList('enable') $html.find('.js-task-list-container').taskList('enable')
......
...@@ -18,8 +18,11 @@ class @Profile ...@@ -18,8 +18,11 @@ class @Profile
$(this).find('.btn-save').enable() $(this).find('.btn-save').enable()
$(this).find('.loading-gif').hide() $(this).find('.loading-gif').hide()
$('.update-notifications').on 'ajax:complete', -> $('.update-notifications').on 'ajax:success', (e, data) ->
$(this).find('.btn-save').enable() if data.saved
new Flash("Notification settings saved", "notice")
else
new Flash("Failed to save new settings", "alert")
@bindEvents() @bindEvents()
......
...@@ -37,19 +37,20 @@ class @Project ...@@ -37,19 +37,20 @@ class @Project
$('.update-notification').on 'click', (e) -> $('.update-notification').on 'click', (e) ->
e.preventDefault() e.preventDefault()
notification_level = $(@).data 'notification-level' notification_level = $(@).data 'notification-level'
$('#notification_level').val(notification_level) label = $(@).data 'notification-title'
$('#notification_setting_level').val(notification_level)
$('#notification-form').submit() $('#notification-form').submit()
label = null
switch notification_level
when 0 then label = ' Disabled '
when 1 then label = ' Participating '
when 2 then label = ' Watching '
when 3 then label = ' Global '
when 4 then label = ' On Mention '
$('#notifications-button').empty().append("<i class='fa fa-bell'></i>" + label + "<i class='fa fa-angle-down'></i>") $('#notifications-button').empty().append("<i class='fa fa-bell'></i>" + label + "<i class='fa fa-angle-down'></i>")
$(@).parents('ul').find('li.active').removeClass 'active' $(@).parents('ul').find('li.active').removeClass 'active'
$(@).parent().addClass 'active' $(@).parent().addClass 'active'
$('#notification-form').on 'ajax:success', (e, data) ->
if data.saved
new Flash("Notification settings saved", "notice")
else
new Flash("Failed to save new settings", "alert")
@projectSelectDropdown() @projectSelectDropdown()
projectSelectDropdown: -> projectSelectDropdown: ->
......
class @ProjectSelect class @ProjectSelect
constructor: -> constructor: ->
$('.js-projects-dropdown-toggle').each (i, dropdown) ->
$dropdown = $(dropdown)
$dropdown.glDropdown(
filterable: true
filterRemote: true
search:
fields: ['name_with_namespace']
data: (term, callback) ->
finalCallback = (projects) ->
callback projects
if @includeGroups
projectsCallback = (projects) ->
groupsCallback = (groups) ->
data = groups.concat(projects)
finalCallback(data)
Api.groups term, false, groupsCallback
else
projectsCallback = finalCallback
if @groupId
Api.groupProjects @groupId, term, projectsCallback
else
Api.projects term, @orderBy, projectsCallback
url: (project) ->
project.web_url
text: (project) ->
project.name_with_namespace
)
$('.ajax-project-select').each (i, select) -> $('.ajax-project-select').each (i, select) ->
@groupId = $(select).data('group-id') @groupId = $(select).data('group-id')
@includeGroups = $(select).data('include-groups') @includeGroups = $(select).data('include-groups')
......
...@@ -59,6 +59,8 @@ class @Todos ...@@ -59,6 +59,8 @@ class @Todos
goToTodoUrl: (e)-> goToTodoUrl: (e)->
todoLink = $(this).data('url') todoLink = $(this).data('url')
return unless todoLink
if e.metaKey if e.metaKey
e.preventDefault() e.preventDefault()
window.open(todoLink,'_blank') window.open(todoLink,'_blank')
......
...@@ -69,6 +69,7 @@ header { ...@@ -69,6 +69,7 @@ header {
} }
.header-content { .header-content {
position: relative;
height: $header-height; height: $header-height;
padding-right: 20px; padding-right: 20px;
...@@ -76,6 +77,10 @@ header { ...@@ -76,6 +77,10 @@ header {
padding-right: 0; padding-right: 0;
} }
.dropdown-menu {
margin-top: -5px;
}
.title { .title {
margin: 0; margin: 0;
font-size: 19px; font-size: 19px;
......
...@@ -58,12 +58,12 @@ ...@@ -58,12 +58,12 @@
.nav-search { .nav-search {
display: inline-block; display: inline-block;
width: 50%; width: 100%;
padding: 11px 0; padding: 11px 0;
/* Small devices (phones, tablets, 768px and lower) */ /* Small devices (phones, tablets, 768px and lower) */
@media (max-width: $screen-sm-min) { @media (min-width: $screen-sm-min) {
width: 100%; width: 50%;
} }
} }
......
...@@ -28,6 +28,7 @@ $gl-link-color: #3084bb; ...@@ -28,6 +28,7 @@ $gl-link-color: #3084bb;
$gl-dark-link-color: #333; $gl-dark-link-color: #333;
$gl-placeholder-color: #8f8f8f; $gl-placeholder-color: #8f8f8f;
$gl-icon-color: $gl-placeholder-color; $gl-icon-color: $gl-placeholder-color;
$gl-grayish-blue: #7f8fa4;
$gl-gray: $gl-text-color; $gl-gray: $gl-text-color;
$gl-header-color: $gl-title-color; $gl-header-color: $gl-title-color;
......
...@@ -41,8 +41,17 @@ ...@@ -41,8 +41,17 @@
word-wrap: break-word; word-wrap: break-word;
.md { .md {
color: #7f8fa4; color: $gl-grayish-blue;
font-size: $gl-font-size; font-size: $gl-font-size;
.label {
color: $gl-text-color;
font-size: inherit;
}
iframe.twitter-share-button {
vertical-align: bottom;
}
} }
pre { pre {
......
...@@ -263,6 +263,12 @@ ...@@ -263,6 +263,12 @@
} }
} }
.dropdown-content {
a:hover {
color: inherit;
}
}
.dropdown-menu-toggle { .dropdown-menu-toggle {
width: 100%; width: 100%;
padding-top: 6px; padding-top: 6px;
......
...@@ -142,6 +142,7 @@ ...@@ -142,6 +142,7 @@
overflow: hidden; overflow: hidden;
font-size: 90%; font-size: 90%;
margin: 0 3px; margin: 0 3px;
word-break: break-all;
} }
.mr-list { .mr-list {
......
...@@ -71,12 +71,24 @@ ...@@ -71,12 +71,24 @@
border-color: $focus-border-color; border-color: $focus-border-color;
} }
} }
p {
code {
white-space: normal;
}
pre {
code {
white-space: pre;
}
}
}
} }
} }
.discussion-form { .discussion-form {
padding: $gl-padding-top $gl-padding; padding: $gl-padding-top $gl-padding;
background-color: #fff; background-color: $white-light;
} }
.note-edit-form { .note-edit-form {
......
...@@ -81,9 +81,15 @@ ul.notes { ...@@ -81,9 +81,15 @@ ul.notes {
@include md-typography; @include md-typography;
// On diffs code should wrap nicely and not overflow // On diffs code should wrap nicely and not overflow
pre { p {
code { code {
white-space: pre; white-space: normal;
}
pre {
code {
white-space: pre;
}
} }
} }
...@@ -112,6 +118,10 @@ ul.notes { ...@@ -112,6 +118,10 @@ ul.notes {
margin: 10px 0; margin: 10px 0;
} }
} }
a {
word-break: break-all;
}
} }
.note-header { .note-header {
...@@ -127,7 +137,7 @@ ul.notes { ...@@ -127,7 +137,7 @@ ul.notes {
margin-right: 10px; margin-right: 10px;
} }
.line_content { .line_content {
white-space: pre-wrap; white-space: pre;
} }
} }
...@@ -145,19 +155,27 @@ ul.notes { ...@@ -145,19 +155,27 @@ ul.notes {
background: $background-color; background: $background-color;
color: $text-color; color: $text-color;
} }
&.notes_line2 { &.notes_line2 {
text-align: center; text-align: center;
padding: 10px 0; padding: 10px 0;
border-left: 1px solid #ddd !important; border-left: 1px solid #ddd !important;
} }
&.notes_content { &.notes_content {
background-color: #fff; background-color: $background-color;
border-width: 1px 0; border-width: 1px 0;
padding: 0; padding: 0;
vertical-align: top; vertical-align: top;
white-space: normal;
&.parallel { &.parallel {
border-width: 1px; border-width: 1px;
} }
.notes {
background-color: $white-light;
}
} }
} }
} }
......
...@@ -34,6 +34,11 @@ ...@@ -34,6 +34,11 @@
color: #7f8fa4; color: #7f8fa4;
font-size: $gl-font-size; font-size: $gl-font-size;
.label {
color: $gl-text-color;
font-size: inherit;
}
p { p {
color: #5c5d5e; color: #5c5d5e;
} }
......
class Groups::NotificationSettingsController < Groups::ApplicationController
before_action :authenticate_user!
def update
notification_setting = current_user.notification_settings_for(group)
saved = notification_setting.update_attributes(notification_setting_params)
render json: { saved: saved }
end
private
def notification_setting_params
params.require(:notification_setting).permit(:level)
end
end
...@@ -60,6 +60,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -60,6 +60,8 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
continue_login_process continue_login_process
end end
rescue Gitlab::OAuth::SignupDisabledError
handle_signup_error
end end
def omniauth_error def omniauth_error
...@@ -92,16 +94,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -92,16 +94,7 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
continue_login_process continue_login_process
end end
rescue Gitlab::OAuth::SignupDisabledError rescue Gitlab::OAuth::SignupDisabledError
label = Gitlab::OAuth::Provider.label_for(oauth['provider']) handle_signup_error
message = "Signing in using your #{label} account without a pre-existing GitLab account is not allowed."
if current_application_settings.signup_enabled?
message << " Create a GitLab account first, and then connect it to your #{label} account."
end
flash[:notice] = message
redirect_to new_user_session_path
end end
def handle_service_ticket provider, ticket def handle_service_ticket provider, ticket
...@@ -122,6 +115,19 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController ...@@ -122,6 +115,19 @@ class OmniauthCallbacksController < Devise::OmniauthCallbacksController
end end
end end
def handle_signup_error
label = Gitlab::OAuth::Provider.label_for(oauth['provider'])
message = "Signing in using your #{label} account without a pre-existing GitLab account is not allowed."
if current_application_settings.signup_enabled?
message << " Create a GitLab account first, and then connect it to your #{label} account."
end
flash[:notice] = message
redirect_to new_user_session_path
end
def oauth def oauth
@oauth ||= request.env['omniauth.auth'] @oauth ||= request.env['omniauth.auth']
end end
......
class Profiles::NotificationsController < Profiles::ApplicationController class Profiles::NotificationsController < Profiles::ApplicationController
def show def show
@user = current_user @user = current_user
@notification = current_user.notification @group_notifications = current_user.notification_settings.for_groups
@project_members = current_user.project_members @project_notifications = current_user.notification_settings.for_projects
@group_members = current_user.group_members
end end
def update def update
type = params[:notification_type] if current_user.update_attributes(user_params)
flash[:notice] = "Notification settings saved"
@saved = if type == 'global' else
current_user.update_attributes(user_params) flash[:alert] = "Failed to save new settings"
elsif type == 'group'
group_member = current_user.group_members.find(params[:notification_id])
group_member.notification_level = params[:notification_level]
group_member.save
else
project_member = current_user.project_members.find(params[:notification_id])
project_member.notification_level = params[:notification_level]
project_member.save
end
respond_to do |format|
format.html do
if @saved
flash[:notice] = "Notification settings saved"
else
flash[:alert] = "Failed to save new settings"
end
redirect_back_or_default(default: profile_notifications_path)
end
format.js
end end
redirect_back_or_default(default: profile_notifications_path)
end end
def user_params def user_params
......
...@@ -118,7 +118,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -118,7 +118,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@diffs = @merge_request.compare.diffs(diff_options) if @merge_request.compare @diffs = @merge_request.compare.diffs(diff_options) if @merge_request.compare
@ci_commit = @merge_request.ci_commit @ci_commit = @merge_request.ci_commit
@ci_commits = [@ci_commit].compact
@statuses = @ci_commit.statuses if @ci_commit @statuses = @ci_commit.statuses if @ci_commit
@note_counts = Note.where(commit_id: @commits.map(&:id)). @note_counts = Note.where(commit_id: @commits.map(&:id)).
...@@ -238,6 +237,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -238,6 +237,8 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
end end
status = "preparing" if status.nil?
response = { response = {
title: merge_request.title, title: merge_request.title,
sha: merge_request.last_commit_short_sha, sha: merge_request.last_commit_short_sha,
...@@ -309,7 +310,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -309,7 +310,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request_diff = @merge_request.merge_request_diff @merge_request_diff = @merge_request.merge_request_diff
@ci_commit = @merge_request.ci_commit @ci_commit = @merge_request.ci_commit
@ci_commits = [@ci_commit].compact
@statuses = @ci_commit.statuses if @ci_commit @statuses = @ci_commit.statuses if @ci_commit
if @merge_request.locked_long_ago? if @merge_request.locked_long_ago?
......
...@@ -39,8 +39,7 @@ class Projects::NotesController < Projects::ApplicationController ...@@ -39,8 +39,7 @@ class Projects::NotesController < Projects::ApplicationController
def destroy def destroy
if note.editable? if note.editable?
note.destroy Notes::DeleteService.new(project, current_user).execute(note)
note.reset_events_cache
end end
respond_to do |format| respond_to do |format|
......
class Projects::NotificationSettingsController < Projects::ApplicationController
before_action :authenticate_user!
def update
notification_setting = current_user.notification_settings_for(project)
saved = notification_setting.update_attributes(notification_setting_params)
render json: { saved: saved }
end
private
def notification_setting_params
params.require(:notification_setting).permit(:level)
end
end
...@@ -11,7 +11,6 @@ class Projects::RepositoriesController < Projects::ApplicationController ...@@ -11,7 +11,6 @@ class Projects::RepositoriesController < Projects::ApplicationController
end end
def archive def archive
RepositoryArchiveCacheWorker.perform_async
headers.store(*Gitlab::Workhorse.send_git_archive(@project, params[:ref], params[:format])) headers.store(*Gitlab::Workhorse.send_git_archive(@project, params[:ref], params[:format]))
head :ok head :ok
rescue => ex rescue => ex
......
...@@ -101,14 +101,18 @@ class ProjectsController < Projects::ApplicationController ...@@ -101,14 +101,18 @@ class ProjectsController < Projects::ApplicationController
respond_to do |format| respond_to do |format|
format.html do format.html do
if current_user
@membership = @project.team.find_member(current_user.id)
if @membership
@notification_setting = current_user.notification_settings_for(@project)
end
end
if @project.repository_exists? if @project.repository_exists?
if @project.empty_repo? if @project.empty_repo?
render 'projects/empty' render 'projects/empty'
else else
if current_user
@membership = @project.team.find_member(current_user.id)
end
render :show render :show
end end
else else
......
...@@ -184,7 +184,7 @@ module ApplicationHelper ...@@ -184,7 +184,7 @@ module ApplicationHelper
element = content_tag :time, time.to_s, element = content_tag :time, time.to_s,
class: "#{html_class} js-timeago #{"js-timeago-pending" unless skip_js}", class: "#{html_class} js-timeago #{"js-timeago-pending" unless skip_js}",
datetime: time.to_time.getutc.iso8601, datetime: time.to_time.getutc.iso8601,
title: time.in_time_zone.to_s(:medium), title: time.to_time.in_time_zone.to_s(:medium),
data: { toggle: 'tooltip', placement: placement, container: 'body' } data: { toggle: 'tooltip', placement: placement, container: 'body' }
unless skip_js unless skip_js
......
module CiStatusHelper module CiStatusHelper
def ci_status_path(ci_commit)
project = ci_commit.project
builds_namespace_project_commit_path(project.namespace, project, ci_commit.sha)
end
def ci_status_with_icon(status, target = nil) def ci_status_with_icon(status, target = nil)
content = ci_icon_for_status(status) + '&nbsp;'.html_safe + ci_label_for_status(status) content = ci_icon_for_status(status) + '&nbsp;'.html_safe + ci_label_for_status(status)
klass = "ci-status ci-#{status}" klass = "ci-status ci-#{status}"
...@@ -34,10 +39,11 @@ module CiStatusHelper ...@@ -34,10 +39,11 @@ module CiStatusHelper
end end
def render_ci_status(ci_commit, tooltip_placement: 'auto left') def render_ci_status(ci_commit, tooltip_placement: 'auto left')
return unless ci_commit.is_a?(Commit) || ci_commit.is_a?(Ci::Commit) # TODO: split this method into
# - render_commit_status
# - render_pipeline_status
link_to ci_icon_for_status(ci_commit.status), link_to ci_icon_for_status(ci_commit.status),
project_pipeline_path(ci_commit.project, ci_commit), ci_status_path(ci_commit),
class: "ci-status-link ci-status-icon-#{ci_commit.status.dasherize}", class: "ci-status-link ci-status-icon-#{ci_commit.status.dasherize}",
title: "Build #{ci_label_for_status(ci_commit.status)}", title: "Build #{ci_label_for_status(ci_commit.status)}",
data: { toggle: 'tooltip', placement: tooltip_placement } data: { toggle: 'tooltip', placement: tooltip_placement }
......
...@@ -33,14 +33,6 @@ module GitlabRoutingHelper ...@@ -33,14 +33,6 @@ module GitlabRoutingHelper
namespace_project_builds_path(project.namespace, project, *args) namespace_project_builds_path(project.namespace, project, *args)
end end
def project_commit_path(project, commit)
builds_namespace_project_commit_path(project.namespace, project, commit.id)
end
def project_pipeline_path(project, ci_commit)
builds_namespace_project_commit_path(project.namespace, project, ci_commit.sha)
end
def activity_project_path(project, *args) def activity_project_path(project, *args)
activity_namespace_project_path(project.namespace, project, *args) activity_namespace_project_path(project.namespace, project, *args)
end end
......
...@@ -52,6 +52,7 @@ module IssuesHelper ...@@ -52,6 +52,7 @@ module IssuesHelper
def milestone_options(object) def milestone_options(object)
milestones = object.project.milestones.active.reorder(due_date: :asc, title: :asc).to_a milestones = object.project.milestones.active.reorder(due_date: :asc, title: :asc).to_a
milestones.unshift(object.milestone) if object.milestone.present? && object.milestone.closed?
milestones.unshift(Milestone::None) milestones.unshift(Milestone::None)
options_from_collection_for_select(milestones, 'id', 'title', object.milestone_id) options_from_collection_for_select(milestones, 'id', 'title', object.milestone_id)
......
...@@ -3,8 +3,16 @@ module NamespacesHelper ...@@ -3,8 +3,16 @@ module NamespacesHelper
groups = current_user.owned_groups + current_user.masters_groups groups = current_user.owned_groups + current_user.masters_groups
users = [current_user.namespace] users = [current_user.namespace]
group_opts = ["Groups", groups.sort_by(&:human_name).map {|g| [display_path ? g.path : g.human_name, g.id]} ] data_attr_group = { 'data-options-parent' => 'groups' }
users_opts = [ "Users", users.sort_by(&:human_name).map {|u| [display_path ? u.path : u.human_name, u.id]} ] data_attr_users = { 'data-options-parent' => 'users' }
group_opts = [
"Groups", groups.sort_by(&:human_name).map { |g| [display_path ? g.path : g.human_name, g.id, data_attr_group] }
]
users_opts = [
"Users", users.sort_by(&:human_name).map { |u| [display_path ? u.path : u.human_name, u.id, data_attr_users] }
]
options = [] options = []
options << group_opts options << group_opts
......
module NotificationsHelper module NotificationsHelper
include IconsHelper include IconsHelper
def notification_icon(notification) def notification_icon_class(level)
if notification.disabled? case level.to_sym
icon('volume-off', class: 'ns-mute') when :disabled
elsif notification.participating? 'microphone-slash'
icon('volume-down', class: 'ns-part') when :participating
elsif notification.watch? 'volume-up'
icon('volume-up', class: 'ns-watch') when :watch
else 'eye'
icon('circle-o', class: 'ns-default') when :mention
'at'
when :global
'globe'
end end
end end
def notification_list_item(notification_level, user_membership) def notification_icon(level, text = nil)
case notification_level icon("#{notification_icon_class(level)} fw", text: text)
when Notification::N_DISABLED
update_notification_link(Notification::N_DISABLED, user_membership, 'Disabled', 'microphone-slash')
when Notification::N_PARTICIPATING
update_notification_link(Notification::N_PARTICIPATING, user_membership, 'Participate', 'volume-up')
when Notification::N_WATCH
update_notification_link(Notification::N_WATCH, user_membership, 'Watch', 'eye')
when Notification::N_MENTION
update_notification_link(Notification::N_MENTION, user_membership, 'On mention', 'at')
when Notification::N_GLOBAL
update_notification_link(Notification::N_GLOBAL, user_membership, 'Global', 'globe')
else
# do nothing
end
end end
def update_notification_link(notification_level, user_membership, title, icon) def notification_title(level)
content_tag(:li, class: active_level_for(user_membership, notification_level)) do case level.to_sym
link_to '#', class: 'update-notification', data: { notification_level: notification_level } do when :participating
icon("#{icon} fw", text: title) 'Participate'
end when :mention
'On mention'
else
level.to_s.titlecase
end end
end end
def notification_label(user_membership) def notification_list_item(level, setting)
Notification.new(user_membership).to_s title = notification_title(level)
end
data = {
notification_level: level,
notification_title: title
}
def active_level_for(user_membership, level) content_tag(:li, class: ('active' if setting.level == level)) do
'active' if user_membership.notification_level == level link_to '#', class: 'update-notification', data: data do
notification_icon(level, title)
end
end
end end
end end
...@@ -65,21 +65,14 @@ module ProjectsHelper ...@@ -65,21 +65,14 @@ module ProjectsHelper
link_to(simple_sanitize(owner.name), user_path(owner)) link_to(simple_sanitize(owner.name), user_path(owner))
end end
project_link = link_to project_path(project), { class: "project-item-select-holder" } do project_link = link_to simple_sanitize(project.name), project_path(project), { class: "project-item-select-holder" }
link_output = simple_sanitize(project.name)
if current_user if current_user
link_output += project_select_tag :project_path, project_link << icon("chevron-down", class: "dropdown-toggle-caret js-projects-dropdown-toggle", data: { target: ".js-dropdown-menu-projects", toggle: "dropdown" })
class: "project-item-select js-projects-dropdown",
data: { include_groups: false, order_by: 'last_activity_at' }
end
link_output
end end
project_link += icon "chevron-down", class: "dropdown-toggle-caret js-projects-dropdown-toggle" if current_user
full_title = namespace_link + ' / ' + project_link full_title = "#{namespace_link} / #{project_link}".html_safe
full_title += ' &middot; '.html_safe + link_to(simple_sanitize(name), url) if name full_title << ' &middot; '.html_safe << link_to(simple_sanitize(name), url) if name
full_title full_title
end end
......
...@@ -20,6 +20,8 @@ module TodosHelper ...@@ -20,6 +20,8 @@ module TodosHelper
end end
def todo_target_path(todo) def todo_target_path(todo)
return unless todo.target.present?
anchor = dom_id(todo.note) if todo.note.present? anchor = dom_id(todo.note) if todo.note.present?
if todo.for_commit? if todo.for_commit?
......
...@@ -150,13 +150,11 @@ class Commit ...@@ -150,13 +150,11 @@ class Commit
end end
def hook_attrs(with_changed_files: false) def hook_attrs(with_changed_files: false)
path_with_namespace = project.path_with_namespace
data = { data = {
id: id, id: id,
message: safe_message, message: safe_message,
timestamp: committed_date.xmlschema, timestamp: committed_date.xmlschema,
url: "#{Gitlab.config.gitlab.url}/#{path_with_namespace}/commit/#{id}", url: commit_url,
author: { author: {
name: author_name, name: author_name,
email: author_email email: author_email
...@@ -170,6 +168,10 @@ class Commit ...@@ -170,6 +168,10 @@ class Commit
data data
end end
def commit_url
project.present? ? "#{Gitlab.config.gitlab.url}/#{project.path_with_namespace}/commit/#{id}" : ""
end
# Discover issues should be closed when this commit is pushed to a project's # Discover issues should be closed when this commit is pushed to a project's
# default branch. # default branch.
def closes_issues(current_user = self.committer) def closes_issues(current_user = self.committer)
......
...@@ -51,8 +51,6 @@ class CommitStatus < ActiveRecord::Base ...@@ -51,8 +51,6 @@ class CommitStatus < ActiveRecord::Base
scope :ordered, -> { order(:ref, :stage_idx, :name) } scope :ordered, -> { order(:ref, :stage_idx, :name) }
scope :ignored, -> { where(allow_failure: true, status: [:failed, :canceled]) } scope :ignored, -> { where(allow_failure: true, status: [:failed, :canceled]) }
AVAILABLE_STATUSES = ['pending', 'running', 'success', 'failed', 'canceled']
state_machine :status, initial: :pending do state_machine :status, initial: :pending do
event :run do event :run do
transition pending: :running transition pending: :running
......
module CiStatus module CiStatus
extend ActiveSupport::Concern extend ActiveSupport::Concern
module ClassMethods AVAILABLE_STATUSES = %w(pending running success failed canceled skipped)
class_methods do
def status_sql def status_sql
builds = all.select('count(id)').to_sql builds = all.select('count(*)').to_sql
success = all.success.select('count(id)').to_sql success = all.success.select('count(*)').to_sql
ignored = all.failed.where(allow_failure: true).select('count(id)').to_sql if all.try(:ignored) ignored = all.ignored.select('count(*)').to_sql if all.try(:ignored)
ignored ||= '0' ignored ||= '0'
pending = all.pending.select('count(id)').to_sql pending = all.pending.select('count(*)').to_sql
running = all.running.select('count(id)').to_sql running = all.running.select('count(*)').to_sql
canceled = all.canceled.select('count(id)').to_sql canceled = all.canceled.select('count(*)').to_sql
deduce_status = "(CASE deduce_status = "(CASE
WHEN (#{builds})=0 THEN 'skipped' WHEN (#{builds})=0 THEN 'skipped'
...@@ -24,7 +26,7 @@ module CiStatus ...@@ -24,7 +26,7 @@ module CiStatus
end end
def status def status
pluck(self.status_sql).first all.pluck(self.status_sql).first
end end
def duration def duration
...@@ -34,7 +36,7 @@ module CiStatus ...@@ -34,7 +36,7 @@ module CiStatus
end end
included do included do
validates :status, inclusion: { in: %w(pending running failed success canceled skipped) } validates :status, inclusion: { in: AVAILABLE_STATUSES }
state_machine :status, initial: :pending do state_machine :status, initial: :pending do
state :pending, value: 'pending' state :pending, value: 'pending'
......
# == Notifiable concern
#
# Contains notification functionality
#
module Notifiable
extend ActiveSupport::Concern
included do
validates :notification_level, inclusion: { in: Notification.project_notification_levels }, presence: true
end
def notification
@notification ||= Notification.new(self)
end
end
...@@ -27,6 +27,7 @@ class Group < Namespace ...@@ -27,6 +27,7 @@ class Group < Namespace
has_many :users, through: :group_members has_many :users, through: :group_members
has_many :project_group_links, dependent: :destroy has_many :project_group_links, dependent: :destroy
has_many :shared_projects, through: :project_group_links, source: :project has_many :shared_projects, through: :project_group_links, source: :project
has_many :notification_settings, dependent: :destroy, as: :source
validate :avatar_type, if: ->(user) { user.avatar.present? && user.avatar_changed? } validate :avatar_type, if: ->(user) { user.avatar.present? && user.avatar_changed? }
validate :visibility_level_allowed_by_projects validate :visibility_level_allowed_by_projects
......
...@@ -19,7 +19,6 @@ ...@@ -19,7 +19,6 @@
class Member < ActiveRecord::Base class Member < ActiveRecord::Base
include Sortable include Sortable
include Notifiable
include Gitlab::Access include Gitlab::Access
attr_accessor :raw_invite_token attr_accessor :raw_invite_token
...@@ -56,12 +55,15 @@ class Member < ActiveRecord::Base ...@@ -56,12 +55,15 @@ class Member < ActiveRecord::Base
before_validation :generate_invite_token, on: :create, if: -> (member) { member.invite_email.present? } before_validation :generate_invite_token, on: :create, if: -> (member) { member.invite_email.present? }
after_create :send_invite, if: :invite? after_create :send_invite, if: :invite?
after_create :create_notification_setting, unless: :invite?
after_create :post_create_hook, unless: :invite? after_create :post_create_hook, unless: :invite?
after_update :post_update_hook, unless: :invite? after_update :post_update_hook, unless: :invite?
after_destroy :post_destroy_hook, unless: :invite? after_destroy :post_destroy_hook, unless: :invite?
delegate :name, :username, :email, to: :user, prefix: true delegate :name, :username, :email, to: :user, prefix: true
default_value_for :notification_level, NotificationSetting.levels[:global]
class << self class << self
def find_by_invite_token(invite_token) def find_by_invite_token(invite_token)
invite_token = Devise.token_generator.digest(self, :invite_token, invite_token) invite_token = Devise.token_generator.digest(self, :invite_token, invite_token)
...@@ -160,6 +162,14 @@ class Member < ActiveRecord::Base ...@@ -160,6 +162,14 @@ class Member < ActiveRecord::Base
send_invite send_invite
end end
def create_notification_setting
user.notification_settings.find_or_create_for(source)
end
def notification_setting
@notification_setting ||= user.notification_settings_for(source)
end
private private
def send_invite def send_invite
......
...@@ -24,7 +24,6 @@ class GroupMember < Member ...@@ -24,7 +24,6 @@ class GroupMember < Member
# Make sure group member points only to group as it source # Make sure group member points only to group as it source
default_value_for :source_type, SOURCE_TYPE default_value_for :source_type, SOURCE_TYPE
default_value_for :notification_level, Notification::N_GLOBAL
validates_format_of :source_type, with: /\ANamespace\z/ validates_format_of :source_type, with: /\ANamespace\z/
default_scope { where(source_type: SOURCE_TYPE) } default_scope { where(source_type: SOURCE_TYPE) }
......
...@@ -27,7 +27,6 @@ class ProjectMember < Member ...@@ -27,7 +27,6 @@ class ProjectMember < Member
# Make sure project member points only to project as it source # Make sure project member points only to project as it source
default_value_for :source_type, SOURCE_TYPE default_value_for :source_type, SOURCE_TYPE
default_value_for :notification_level, Notification::N_GLOBAL
validates_format_of :source_type, with: /\AProject\z/ validates_format_of :source_type, with: /\AProject\z/
default_scope { where(source_type: SOURCE_TYPE) } default_scope { where(source_type: SOURCE_TYPE) }
......
...@@ -128,7 +128,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -128,7 +128,7 @@ class MergeRequest < ActiveRecord::Base
validates :target_project, presence: true validates :target_project, presence: true
validates :target_branch, presence: true validates :target_branch, presence: true
validates :merge_user, presence: true, if: :merge_when_build_succeeds? validates :merge_user, presence: true, if: :merge_when_build_succeeds?
validate :validate_branches validate :validate_branches, unless: :allow_broken
validate :validate_fork validate :validate_fork
scope :by_branch, ->(branch_name) { where("(source_branch LIKE :branch) OR (target_branch LIKE :branch)", branch: branch_name) } scope :by_branch, ->(branch_name) { where("(source_branch LIKE :branch) OR (target_branch LIKE :branch)", branch: branch_name) }
...@@ -218,7 +218,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -218,7 +218,7 @@ class MergeRequest < ActiveRecord::Base
end end
if opened? || reopened? if opened? || reopened?
similar_mrs = self.target_project.merge_requests.where(source_branch: source_branch, target_branch: target_branch, source_project_id: source_project.id).opened similar_mrs = self.target_project.merge_requests.where(source_branch: source_branch, target_branch: target_branch, source_project_id: source_project.try(:id)).opened
similar_mrs = similar_mrs.where('id not in (?)', self.id) if self.id similar_mrs = similar_mrs.where('id not in (?)', self.id) if self.id
if similar_mrs.any? if similar_mrs.any?
errors.add :validate_branches, errors.add :validate_branches,
...@@ -345,7 +345,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -345,7 +345,7 @@ class MergeRequest < ActiveRecord::Base
def hook_attrs def hook_attrs
attrs = { attrs = {
source: source_project.hook_attrs, source: source_project.try(:hook_attrs),
target: target_project.hook_attrs, target: target_project.hook_attrs,
last_commit: nil, last_commit: nil,
work_in_progress: work_in_progress? work_in_progress: work_in_progress?
......
class Notification
#
# Notification levels
#
N_DISABLED = 0
N_PARTICIPATING = 1
N_WATCH = 2
N_GLOBAL = 3
N_MENTION = 4
attr_accessor :target
class << self
def notification_levels
[N_DISABLED, N_MENTION, N_PARTICIPATING, N_WATCH]
end
def options_with_labels
{
disabled: N_DISABLED,
participating: N_PARTICIPATING,
watch: N_WATCH,
mention: N_MENTION,
global: N_GLOBAL
}
end
def project_notification_levels
[N_DISABLED, N_MENTION, N_PARTICIPATING, N_WATCH, N_GLOBAL]
end
end
def initialize(target)
@target = target
end
def disabled?
target.notification_level == N_DISABLED
end
def participating?
target.notification_level == N_PARTICIPATING
end
def watch?
target.notification_level == N_WATCH
end
def global?
target.notification_level == N_GLOBAL
end
def mention?
target.notification_level == N_MENTION
end
def level
target.notification_level
end
def to_s
case level
when N_DISABLED
'Disabled'
when N_PARTICIPATING
'Participating'
when N_WATCH
'Watching'
when N_MENTION
'On mention'
when N_GLOBAL
'Global'
else
# do nothing
end
end
end
class NotificationSetting < ActiveRecord::Base
enum level: { disabled: 0, participating: 1, watch: 2, global: 3, mention: 4 }
default_value_for :level, NotificationSetting.levels[:global]
belongs_to :user
belongs_to :source, polymorphic: true
validates :user, presence: true
validates :source, presence: true
validates :level, presence: true
validates :user_id, uniqueness: { scope: [:source_type, :source_id],
message: "already exists in source",
allow_nil: true }
scope :for_groups, -> { where(source_type: 'Namespace') }
scope :for_projects, -> { where(source_type: 'Project') }
def self.find_or_create_for(source)
setting = find_or_initialize_by(source: source)
unless setting.persisted?
setting.save
end
setting
end
end
...@@ -154,6 +154,7 @@ class Project < ActiveRecord::Base ...@@ -154,6 +154,7 @@ class Project < ActiveRecord::Base
has_many :project_group_links, dependent: :destroy has_many :project_group_links, dependent: :destroy
has_many :invited_groups, through: :project_group_links, source: :group has_many :invited_groups, through: :project_group_links, source: :group
has_many :todos, dependent: :destroy has_many :todos, dependent: :destroy
has_many :notification_settings, dependent: :destroy, as: :source
has_one :import_data, dependent: :destroy, class_name: "ProjectImportData" has_one :import_data, dependent: :destroy, class_name: "ProjectImportData"
...@@ -388,9 +389,15 @@ class Project < ActiveRecord::Base ...@@ -388,9 +389,15 @@ class Project < ActiveRecord::Base
def add_import_job def add_import_job
if forked? if forked?
RepositoryForkWorker.perform_async(self.id, forked_from_project.path_with_namespace, self.namespace.path) job_id = RepositoryForkWorker.perform_async(self.id, forked_from_project.path_with_namespace, self.namespace.path)
else else
RepositoryImportWorker.perform_async(self.id) job_id = RepositoryImportWorker.perform_async(self.id)
end
if job_id
Rails.logger.info "Import job started for #{path_with_namespace} with job ID #{job_id}"
else
Rails.logger.error "Import job failed to start for #{path_with_namespace}"
end end
end end
......
...@@ -253,6 +253,8 @@ class Repository ...@@ -253,6 +253,8 @@ class Repository
# This ensures this particular cache is flushed after the first commit to a # This ensures this particular cache is flushed after the first commit to a
# new repository. # new repository.
expire_emptiness_caches if empty? expire_emptiness_caches if empty?
expire_branch_count_cache
expire_tag_count_cache
end end
def expire_branch_cache(branch_name = nil) def expire_branch_cache(branch_name = nil)
...@@ -896,9 +898,9 @@ class Repository ...@@ -896,9 +898,9 @@ class Repository
end end
def main_language def main_language
unless empty? return if empty? || rugged.head_unborn?
Linguist::Repository.new(rugged, rugged.head.target_id).language
end Linguist::Repository.new(rugged, rugged.head.target_id).language
end end
def avatar def avatar
......
...@@ -143,6 +143,7 @@ class User < ActiveRecord::Base ...@@ -143,6 +143,7 @@ class User < ActiveRecord::Base
has_many :spam_logs, dependent: :destroy has_many :spam_logs, dependent: :destroy
has_many :builds, dependent: :nullify, class_name: 'Ci::Build' has_many :builds, dependent: :nullify, class_name: 'Ci::Build'
has_many :todos, dependent: :destroy has_many :todos, dependent: :destroy
has_many :notification_settings, dependent: :destroy
# #
# Validations # Validations
...@@ -157,7 +158,7 @@ class User < ActiveRecord::Base ...@@ -157,7 +158,7 @@ class User < ActiveRecord::Base
presence: true, presence: true,
uniqueness: { case_sensitive: false } uniqueness: { case_sensitive: false }
validates :notification_level, inclusion: { in: Notification.notification_levels }, presence: true validates :notification_level, presence: true
validate :namespace_uniq, if: ->(user) { user.username_changed? } validate :namespace_uniq, if: ->(user) { user.username_changed? }
validate :avatar_type, if: ->(user) { user.avatar.present? && user.avatar_changed? } validate :avatar_type, if: ->(user) { user.avatar.present? && user.avatar_changed? }
validate :unique_email, if: ->(user) { user.email_changed? } validate :unique_email, if: ->(user) { user.email_changed? }
...@@ -190,6 +191,13 @@ class User < ActiveRecord::Base ...@@ -190,6 +191,13 @@ class User < ActiveRecord::Base
# Note: When adding an option, it MUST go on the end of the array. # Note: When adding an option, it MUST go on the end of the array.
enum project_view: [:readme, :activity, :files] enum project_view: [:readme, :activity, :files]
# Notification level
# Note: When adding an option, it MUST go on the end of the array.
#
# TODO: Add '_prefix: :notification' to enum when update to Rails 5. https://github.com/rails/rails/pull/19813
# Because user.notification_disabled? is much better than user.disabled?
enum notification_level: [:disabled, :participating, :watch, :global, :mention]
alias_attribute :private_token, :authentication_token alias_attribute :private_token, :authentication_token
delegate :path, to: :namespace, allow_nil: true, prefix: true delegate :path, to: :namespace, allow_nil: true, prefix: true
...@@ -349,10 +357,6 @@ class User < ActiveRecord::Base ...@@ -349,10 +357,6 @@ class User < ActiveRecord::Base
"#{self.class.reference_prefix}#{username}" "#{self.class.reference_prefix}#{username}"
end end
def notification
@notification ||= Notification.new(self)
end
def generate_password def generate_password
if self.force_random_password if self.force_random_password
self.password = self.password_confirmation = Devise.friendly_token.first(8) self.password = self.password_confirmation = Devise.friendly_token.first(8)
...@@ -827,6 +831,10 @@ class User < ActiveRecord::Base ...@@ -827,6 +831,10 @@ class User < ActiveRecord::Base
end end
end end
def notification_settings_for(source)
notification_settings.find_or_initialize_by(source: source)
end
private private
def projects_union def projects_union
......
module Notes
class DeleteService < BaseService
def execute(note)
note.destroy
note.reset_events_cache
end
end
end
...@@ -253,8 +253,8 @@ class NotificationService ...@@ -253,8 +253,8 @@ class NotificationService
def project_watchers(project) def project_watchers(project)
project_members = project_member_notification(project) project_members = project_member_notification(project)
users_with_project_level_global = project_member_notification(project, Notification::N_GLOBAL) users_with_project_level_global = project_member_notification(project, :global)
users_with_group_level_global = group_member_notification(project, Notification::N_GLOBAL) users_with_group_level_global = group_member_notification(project, :global)
users = users_with_global_level_watch([users_with_project_level_global, users_with_group_level_global].flatten.uniq) users = users_with_global_level_watch([users_with_project_level_global, users_with_group_level_global].flatten.uniq)
users_with_project_setting = select_project_member_setting(project, users_with_project_level_global, users) users_with_project_setting = select_project_member_setting(project, users_with_project_level_global, users)
...@@ -264,18 +264,16 @@ class NotificationService ...@@ -264,18 +264,16 @@ class NotificationService
end end
def project_member_notification(project, notification_level=nil) def project_member_notification(project, notification_level=nil)
project_members = project.project_members
if notification_level if notification_level
project_members.where(notification_level: notification_level).pluck(:user_id) project.notification_settings.where(level: NotificationSetting.levels[notification_level]).pluck(:user_id)
else else
project_members.pluck(:user_id) project.notification_settings.pluck(:user_id)
end end
end end
def group_member_notification(project, notification_level) def group_member_notification(project, notification_level)
if project.group if project.group
project.group.group_members.where(notification_level: notification_level).pluck(:user_id) project.group.notification_settings.where(level: NotificationSetting.levels[notification_level]).pluck(:user_id)
else else
[] []
end end
...@@ -284,13 +282,13 @@ class NotificationService ...@@ -284,13 +282,13 @@ class NotificationService
def users_with_global_level_watch(ids) def users_with_global_level_watch(ids)
User.where( User.where(
id: ids, id: ids,
notification_level: Notification::N_WATCH notification_level: NotificationSetting.levels[:watch]
).pluck(:id) ).pluck(:id)
end end
# Build a list of users based on project notifcation settings # Build a list of users based on project notifcation settings
def select_project_member_setting(project, global_setting, users_global_level_watch) def select_project_member_setting(project, global_setting, users_global_level_watch)
users = project_member_notification(project, Notification::N_WATCH) users = project_member_notification(project, :watch)
# If project setting is global, add to watch list if global setting is watch # If project setting is global, add to watch list if global setting is watch
global_setting.each do |user_id| global_setting.each do |user_id|
...@@ -304,7 +302,7 @@ class NotificationService ...@@ -304,7 +302,7 @@ class NotificationService
# Build a list of users based on group notification settings # Build a list of users based on group notification settings
def select_group_member_setting(project, project_members, global_setting, users_global_level_watch) def select_group_member_setting(project, project_members, global_setting, users_global_level_watch)
uids = group_member_notification(project, Notification::N_WATCH) uids = group_member_notification(project, :watch)
# Group setting is watch, add to users list if user is not project member # Group setting is watch, add to users list if user is not project member
users = [] users = []
...@@ -331,40 +329,46 @@ class NotificationService ...@@ -331,40 +329,46 @@ class NotificationService
# Remove users with disabled notifications from array # Remove users with disabled notifications from array
# Also remove duplications and nil recipients # Also remove duplications and nil recipients
def reject_muted_users(users, project = nil) def reject_muted_users(users, project = nil)
reject_users(users, :disabled?, project) reject_users(users, :disabled, project)
end end
# Remove users with notification level 'Mentioned' # Remove users with notification level 'Mentioned'
def reject_mention_users(users, project = nil) def reject_mention_users(users, project = nil)
reject_users(users, :mention?, project) reject_users(users, :mention, project)
end end
# Reject users which method_name from notification object returns true. # Reject users which has certain notification level
# #
# Example: # Example:
# reject_users(users, :watch?, project) # reject_users(users, :watch, project)
# #
def reject_users(users, method_name, project = nil) def reject_users(users, level, project = nil)
level = level.to_s
unless NotificationSetting.levels.keys.include?(level)
raise 'Invalid notification level'
end
users = users.to_a.compact.uniq users = users.to_a.compact.uniq
users = users.reject(&:blocked?) users = users.reject(&:blocked?)
users.reject do |user| users.reject do |user|
next user.notification.send(method_name) unless project next user.notification_level == level unless project
member = project.project_members.find_by(user_id: user.id) setting = user.notification_settings_for(project)
if !member && project.group if !setting && project.group
member = project.group.group_members.find_by(user_id: user.id) setting = user.notification_settings_for(project.group)
end end
# reject users who globally set mention notification and has no membership # reject users who globally set mention notification and has no setting per project/group
next user.notification.send(method_name) unless member next user.notification_level == level unless setting
# reject users who set mention notification in project # reject users who set mention notification in project
next true if member.notification.send(method_name) next true if setting.level == level
# reject users who have N_MENTION in project and disabled in global settings # reject users who have mention level in project and disabled in global settings
member.notification.global? && user.notification.send(method_name) setting.global? && user.notification_level == level
end end
end end
......
...@@ -117,7 +117,7 @@ ...@@ -117,7 +117,7 @@
%td.build-link %td.build-link
- if project - if project
= link_to builds_namespace_project_commit_path(project.namespace, project, build.sha) do = link_to ci_status_path(build.commit) do
%strong #{build.commit.short_sha} %strong #{build.commit.short_sha}
%td.timestamp %td.timestamp
......
...@@ -45,6 +45,8 @@ ...@@ -45,6 +45,8 @@
%h1.title= title %h1.title= title
= yield :header_content
= render 'shared/outdated_browser' = render 'shared/outdated_browser'
- if @project && !@project.empty_repo? - if @project && !@project.empty_repo?
......
...@@ -17,4 +17,12 @@ ...@@ -17,4 +17,12 @@
- content_for :scripts_body do - content_for :scripts_body do
= render "layouts/init_auto_complete" if current_user = render "layouts/init_auto_complete" if current_user
- content_for :header_content do
.js-dropdown-menu-projects
.dropdown-menu.dropdown-select.dropdown-menu-projects
= dropdown_title("Go to a project")
= dropdown_filter("Search your projects")
= dropdown_content
= dropdown_loading
= render template: "layouts/application" = render template: "layouts/application"
%li.notification-list-item
%span.notification.fa.fa-holder.append-right-5
- if setting.global?
= notification_icon(current_user.notification_level)
- else
= notification_icon(setting.level)
%span.str-truncated
= link_to group.name, group_path(group)
.pull-right
= form_for [group, setting], remote: true, html: { class: 'update-notifications' } do |f|
= f.select :level, NotificationSetting.levels.keys, {}, class: 'form-control trigger-submit'
%li.notification-list-item
%span.notification.fa.fa-holder.append-right-5
- if setting.global?
= notification_icon(current_user.notification_level)
- else
= notification_icon(setting.level)
%span.str-truncated
= link_to_project(project)
.pull-right
= form_for [project.namespace.becomes(Namespace), project, setting], remote: true, html: { class: 'update-notifications' } do |f|
= f.select :level, NotificationSetting.levels.keys, {}, class: 'form-control trigger-submit'
%li.notification-list-item
%span.notification.fa.fa-holder.append-right-5
- if notification.global?
= notification_icon(@notification)
- else
= notification_icon(notification)
%span.str-truncated
- if membership.kind_of? GroupMember
= link_to membership.group.name, membership.group
- else
= link_to_project(membership.project)
.pull-right
= form_tag profile_notifications_path, method: :put, remote: true, class: 'update-notifications' do
= hidden_field_tag :notification_type, type, id: dom_id(membership, 'notification_type')
= hidden_field_tag :notification_id, membership.id, id: dom_id(membership, 'notification_id')
= select_tag :notification_level, options_for_select(Notification.options_with_labels, notification.level), class: 'form-control trigger-submit'
- page_title "Notifications" - page_title "Notifications"
- header_title page_title, profile_notifications_path - header_title page_title, profile_notifications_path
= form_for @user, url: profile_notifications_path, method: :put, html: { class: 'update-notifications prepend-top-default' } do |f| %div
= form_errors(@user) - if @user.errors.any?
%div.alert.alert-danger
%ul
- @user.errors.full_messages.each do |msg|
%li= msg
= hidden_field_tag :notification_type, 'global' = hidden_field_tag :notification_type, 'global'
.row .row
...@@ -16,56 +20,55 @@ ...@@ -16,56 +20,55 @@
.col-lg-9 .col-lg-9
%h5 %h5
Global notification settings Global notification settings
.form-group
= f.label :notification_email, class: "label-light"
= f.select :notification_email, @user.all_emails, { include_blank: false }, class: "select2"
.form-group
= f.label :notification_level, class: 'label-light'
.radio
= f.label :notification_level, value: Notification::N_DISABLED do
= f.radio_button :notification_level, Notification::N_DISABLED
.level-title
Disabled
%p You will not get any notifications via email
.radio = form_for @user, url: profile_notifications_path, method: :put, html: { class: 'update-notifications prepend-top-default' } do |f|
= f.label :notification_level, value: Notification::N_MENTION do .form-group
= f.radio_button :notification_level, Notification::N_MENTION = f.label :notification_email, class: "label-light"
.level-title = f.select :notification_email, @user.all_emails, { include_blank: false }, class: "select2"
On Mention .form-group
%p You will receive notifications only for comments in which you were @mentioned = f.label :notification_level, class: 'label-light'
.radio
= f.label :notification_level, value: :disabled do
= f.radio_button :notification_level, :disabled
.level-title
Disabled
%p You will not get any notifications via email
.radio .radio
= f.label :notification_level, value: Notification::N_PARTICIPATING do = f.label :notification_level, value: :mention do
= f.radio_button :notification_level, Notification::N_PARTICIPATING = f.radio_button :notification_level, :mention
.level-title .level-title
Participating On Mention
%p You will only receive notifications from related resources (e.g. from your commits or assigned issues) %p You will receive notifications only for comments in which you were @mentioned
.radio .radio
= f.label :notification_level, value: Notification::N_WATCH do = f.label :notification_level, value: :participating do
= f.radio_button :notification_level, Notification::N_WATCH = f.radio_button :notification_level, :participating
.level-title .level-title
Watch Participating
%p You will receive notifications for any activity %p You will only receive notifications from related resources (e.g. from your commits or assigned issues)
.prepend-top-default .radio
= f.submit 'Update settings', class: "btn btn-create" = f.label :notification_level, value: :watch do
= f.radio_button :notification_level, :watch
.level-title
Watch
%p You will receive notifications for any activity
.prepend-top-default
= f.submit 'Update settings', class: "btn btn-create"
%hr %hr
.col-lg-9.col-lg-push-3 %h5
%h5 Groups (#{@group_notifications.count})
Groups (#{@group_members.count}) %div
%div %ul.bordered-list
%ul.bordered-list - @group_notifications.each do |setting|
- @group_members.each do |group_member| = render 'group_settings', setting: setting, group: setting.source
- notification = Notification.new(group_member) %h5
= render 'settings', type: 'group', membership: group_member, notification: notification Projects (#{@project_notifications.count})
%h5 %p.account-well
Projects (#{@project_members.count}) To specify the notification level per project of a group you belong to, you need to visit project page and change notification level there.
%p.account-well .append-bottom-default
To specify the notification level per project of a group you belong to, you need to be a member of the project itself, not only its group. %ul.bordered-list
.append-bottom-default - @project_notifications.each do |setting|
%ul.bordered-list = render 'project_settings', setting: setting, project: setting.source
- @project_members.each do |project_member|
- notification = Notification.new(project_member)
= render 'settings', type: 'project', membership: project_member, notification: notification
- if @saved
:plain
new Flash("Notification settings saved", "notice")
- else
:plain
new Flash("Failed to save new settings", "alert")
.project-last-commit .project-last-commit
- if commit.status - if commit.status
= link_to project_commit_path(commit.project, commit), class: "ci-status ci-#{commit.status}" do = link_to builds_namespace_project_commit_path(commit.project.namespace, commit.project, commit), class: "ci-status ci-#{commit.status}" do
= ci_icon_for_status(commit.status) = ci_icon_for_status(commit.status)
= ci_label_for_status(commit.status) = ci_label_for_status(commit.status)
......
...@@ -4,7 +4,7 @@ ...@@ -4,7 +4,7 @@
.build-page .build-page
.gray-content-block.top-block .gray-content-block.top-block
Build ##{@build.id} for commit Build ##{@build.id} for commit
%strong.monospace= link_to @build.commit.short_sha, builds_namespace_project_commit_path(@project.namespace, @project, @build.sha) %strong.monospace= link_to @build.commit.short_sha, ci_status_path(@build.commit)
from from
= link_to @build.ref, namespace_project_commits_path(@project.namespace, @project, @build.ref) = link_to @build.ref, namespace_project_commits_path(@project.namespace, @project, @build.ref)
- merge_request = @build.merge_request - merge_request = @build.merge_request
...@@ -173,7 +173,7 @@ ...@@ -173,7 +173,7 @@
Commit Commit
.pull-right .pull-right
%small %small
= link_to @build.commit.short_sha, builds_namespace_project_commit_path(@project.namespace, @project, @build.sha), class: "monospace" = link_to @build.commit.short_sha, ci_status_path(@build.commit), class: "monospace"
%p %p
%span.attr-name Branch: %span.attr-name Branch:
= link_to @build.ref, namespace_project_commits_path(@project.namespace, @project, @build.ref) = link_to @build.ref, namespace_project_commits_path(@project.namespace, @project, @build.ref)
...@@ -196,7 +196,7 @@ ...@@ -196,7 +196,7 @@
.build-widget .build-widget
%h4.title #{pluralize(@builds.count(:id), "other build")} for %h4.title #{pluralize(@builds.count(:id), "other build")} for
= succeed ":" do = succeed ":" do
= link_to @build.commit.short_sha, builds_namespace_project_commit_path(@project.namespace, @project, @build.sha), class: "monospace" = link_to @build.commit.short_sha, ci_status_path(@build.commit), class: "monospace"
%table.table.builds %table.table.builds
- @builds.each_with_index do |build, i| - @builds.each_with_index do |build, i|
%tr.build %tr.build
......
- case @membership - if @notification_setting
- when ProjectMember = form_for @notification_setting, url: namespace_project_notification_setting_path(@project.namespace.becomes(Namespace), @project), method: :patch, remote: true, html: { class: 'inline', id: 'notification-form' } do |f|
= form_tag profile_notifications_path, method: :put, remote: true, class: 'inline', id: 'notification-form' do = f.hidden_field :level
= hidden_field_tag :notification_type, 'project'
= hidden_field_tag :notification_id, @membership.id
= hidden_field_tag :notification_level
%span.dropdown %span.dropdown
%a.dropdown-new.btn.notifications-btn#notifications-button{href: '#', "data-toggle" => "dropdown"} %a.dropdown-new.btn.notifications-btn#notifications-button{href: '#', "data-toggle" => "dropdown"}
= icon('bell') = icon('bell')
= notification_label(@membership) = notification_title(@notification_setting.level)
= icon('angle-down') = icon('angle-down')
%ul.dropdown-menu.dropdown-menu-right.project-home-dropdown %ul.dropdown-menu.dropdown-menu-right.project-home-dropdown
- Notification.project_notification_levels.each do |level| - NotificationSetting.levels.each do |level|
= notification_list_item(level, @membership) = notification_list_item(level.first, @notification_setting)
- when GroupMember
.btn.disabled.notifications-btn.has-tooltip{title: "To change the notification level, you need to be a member of the project itself, not only its group."}
= icon('bell')
= notification_label(@membership)
= icon('angle-down')
...@@ -18,7 +18,7 @@ ...@@ -18,7 +18,7 @@
= ci_commit.ref = ci_commit.ref
- if defined?(link_to_commit) && link_to_commit - if defined?(link_to_commit) && link_to_commit
for commit for commit
= link_to @commit.short_id, namespace_project_commit_path(@project.namespace, @project, @commit.id), class: "monospace" = link_to ci_commit.short_sha, namespace_project_commit_path(@project.namespace, @project, ci_commit.sha), class: "monospace"
- if ci_commit.duration > 0 - if ci_commit.duration > 0
took took
= time_interval_in_words ci_commit.duration = time_interval_in_words ci_commit.duration
......
= form_for [@project.namespace.becomes(Namespace), @project, @merge_request], html: { class: 'merge-request-form form-horizontal gfm-form js-requires-input' } do |f| = form_for [@project.namespace.becomes(Namespace), @project, @merge_request], html: { class: 'merge-request-form form-horizontal gfm-form js-requires-input js-quick-submit' } do |f|
= render 'shared/issuable/form', f: f, issuable: @merge_request = render 'shared/issuable/form', f: f, issuable: @merge_request
:javascript :javascript
......
= render "projects/commit/builds", link_to_commit: true = render "projects/commit/ci_commit", ci_commit: @ci_commit, link_to_commit: true
...@@ -8,20 +8,22 @@ ...@@ -8,20 +8,22 @@
= render 'projects/merge_requests/widget/locked' = render 'projects/merge_requests/widget/locked'
:javascript :javascript
var merge_request_widget;
var opts = { var opts = {
merge_check_url: "#{merge_check_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)}", merge_check_url: "#{merge_check_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)}",
check_enable: #{@merge_request.unchecked? ? "true" : "false"}, check_enable: #{@merge_request.unchecked? ? "true" : "false"},
ci_status_url: "#{ci_status_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)}", ci_status_url: "#{ci_status_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)}",
gitlab_icon: "#{asset_path 'gitlab_logo.png'}", gitlab_icon: "#{asset_path 'gitlab_logo.png'}",
ci_status: "", ci_status: "",
ci_message: "Build {{status}} for \"{{title}}\"", ci_message: {
normal: "Build {{status}} for \"{{title}}\"",
preparing: "{{status}} build for \"{{title}}\""
},
ci_enable: #{@project.ci_service ? "true" : "false"}, ci_enable: #{@project.ci_service ? "true" : "false"},
ci_title: {
preparing: "{{status}} build",
normal: "Build {{status}}"
},
builds_path: "#{builds_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)}" builds_path: "#{builds_namespace_project_merge_request_path(@project.namespace, @project, @merge_request)}"
}; };
if(typeof merge_request_widget === 'undefined') { merge_request_widget = new MergeRequestWidget(opts);
merge_request_widget = new MergeRequestWidget(opts);
} else {
merge_request_widget.setOpts(opts);
}
...@@ -19,7 +19,7 @@ ...@@ -19,7 +19,7 @@
- if current_user.can_select_namespace? - if current_user.can_select_namespace?
.input-group-addon .input-group-addon
= root_url = root_url
= f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user, display_path: true), {}, {class: 'select2', tabindex: 1} = f.select :namespace_id, namespaces_options(params[:namespace_id] || :current_user, display_path: true), {}, {class: 'select2 js-select-namespace', tabindex: 1}
.input-group-addon .input-group-addon
\/ \/
- else - else
......
...@@ -10,12 +10,12 @@ ...@@ -10,12 +10,12 @@
= "#{note.author.to_reference} commented" = "#{note.author.to_reference} commented"
%a{ href: "##{dom_id(note)}" } %a{ href: "##{dom_id(note)}" }
= time_ago_with_tooltip(note.created_at, placement: 'bottom', html_class: 'note-created-ago') = time_ago_with_tooltip(note.created_at, placement: 'bottom', html_class: 'note-created-ago')
- if note_editable?(note) .note-actions
.note-actions - access = note.project.team.human_max_access(note.author.id)
- access = note.project.team.human_max_access(note.author.id) - if access
- if access %span.note-role
%span.note-role = access
= access - if note_editable?(note)
= link_to '#', title: 'Edit comment', class: 'note-action-button js-note-edit' do = link_to '#', title: 'Edit comment', class: 'note-action-button js-note-edit' do
= icon('pencil') = icon('pencil')
= link_to namespace_project_note_path(note.project.namespace, note.project, note), title: 'Remove comment', method: :delete, data: { confirm: 'Are you sure you want to remove this comment?' }, remote: true, class: 'note-action-button js-note-delete danger' do = link_to namespace_project_note_path(note.project.namespace, note.project, note), title: 'Remove comment', method: :delete, data: { confirm: 'Are you sure you want to remove this comment?' }, remote: true, class: 'note-action-button js-note-delete danger' do
......
...@@ -6,7 +6,7 @@ ...@@ -6,7 +6,7 @@
.commit-message-container .commit-message-container
.max-width-marker .max-width-marker
= text_area_tag 'commit_message', = text_area_tag 'commit_message',
(params[:commit_message] || local_assigns[:text]), (params[:commit_message] || local_assigns[:text] || local_assigns[:placeholder]),
class: 'form-control js-commit-message', placeholder: local_assigns[:placeholder], class: 'form-control js-commit-message', placeholder: local_assigns[:placeholder],
required: true, rows: (local_assigns[:rows] || 3), required: true, rows: (local_assigns[:rows] || 3),
id: "commit_message-#{nonce}" id: "commit_message-#{nonce}"
......
- if params[:label_name].present? - if params[:label_name].present?
= hidden_field_tag(:label_name, params[:label_name]) = hidden_field_tag(:label_name, params[:label_name])
.dropdown .dropdown
%button.dropdown-menu-toggle.js-label-select.js-filter-submit{type: "button", data: {toggle: "dropdown", field_name: "label_name", show_no: "true", show_any: "true", selected: params[:label_name], project_id: @project.try(:id), labels: labels_filter_path, default_label: "Label"}} %button.dropdown-menu-toggle.js-label-select.js-filter-submit.js-extra-options{type: "button", data: {toggle: "dropdown", field_name: "label_name", show_no: "true", show_any: "true", selected: params[:label_name], project_id: @project.try(:id), labels: labels_filter_path, default_label: "Label"}}
%span.dropdown-toggle-text %span.dropdown-toggle-text
= h(params[:label_name].presence || "Label") = h(params[:label_name].presence || "Label")
= icon('chevron-down') = icon('chevron-down')
......
...@@ -46,6 +46,15 @@ production: &base ...@@ -46,6 +46,15 @@ production: &base
# #
# relative_url_root: /gitlab # relative_url_root: /gitlab
# Trusted Proxies
# Customize if you have GitLab behind a reverse proxy which is running on a different machine.
# Add the IP address for your reverse proxy to the list, otherwise users will appear signed in from that address.
trusted_proxies:
# Examples:
#- 192.168.1.0/24
#- 192.168.2.1
#- 2001:0db8::/32
# Uncomment and customize if you can't use the default user to run GitLab (default: 'git') # Uncomment and customize if you can't use the default user to run GitLab (default: 'git')
# user: git # user: git
...@@ -156,6 +165,9 @@ production: &base ...@@ -156,6 +165,9 @@ production: &base
stuck_ci_builds_worker: stuck_ci_builds_worker:
cron: "0 0 * * *" cron: "0 0 * * *"
# Remove outdated repository archives
repository_archive_cache_worker:
cron: "0 * * * *"
# #
# 2. GitLab CI settings # 2. GitLab CI settings
...@@ -304,6 +316,13 @@ production: &base ...@@ -304,6 +316,13 @@ production: &base
# (default: false) # (default: false)
auto_link_saml_user: false auto_link_saml_user: false
# Set different Omniauth providers as external so that all users creating accounts
# via these providers will not be able to have access to internal projects. You
# will need to use the full name of the provider, like `google_oauth2` for Google.
# Refer to the examples below for the full names of the supported providers.
# (default: [])
external_providers: []
## Auth providers ## Auth providers
# Uncomment the following lines and fill in the data of the auth provider you want to use # Uncomment the following lines and fill in the data of the auth provider you want to use
# If your favorite auth provider is not listed you can use others: # If your favorite auth provider is not listed you can use others:
......
...@@ -129,6 +129,7 @@ Settings['omniauth'] ||= Settingslogic.new({}) ...@@ -129,6 +129,7 @@ Settings['omniauth'] ||= Settingslogic.new({})
Settings.omniauth['enabled'] = false if Settings.omniauth['enabled'].nil? Settings.omniauth['enabled'] = false if Settings.omniauth['enabled'].nil?
Settings.omniauth['auto_sign_in_with_provider'] = false if Settings.omniauth['auto_sign_in_with_provider'].nil? Settings.omniauth['auto_sign_in_with_provider'] = false if Settings.omniauth['auto_sign_in_with_provider'].nil?
Settings.omniauth['allow_single_sign_on'] = false if Settings.omniauth['allow_single_sign_on'].nil? Settings.omniauth['allow_single_sign_on'] = false if Settings.omniauth['allow_single_sign_on'].nil?
Settings.omniauth['external_providers'] = [] if Settings.omniauth['external_providers'].nil?
Settings.omniauth['block_auto_created_users'] = true if Settings.omniauth['block_auto_created_users'].nil? Settings.omniauth['block_auto_created_users'] = true if Settings.omniauth['block_auto_created_users'].nil?
Settings.omniauth['auto_link_ldap_user'] = false if Settings.omniauth['auto_link_ldap_user'].nil? Settings.omniauth['auto_link_ldap_user'] = false if Settings.omniauth['auto_link_ldap_user'].nil?
Settings.omniauth['auto_link_saml_user'] = false if Settings.omniauth['auto_link_saml_user'].nil? Settings.omniauth['auto_link_saml_user'] = false if Settings.omniauth['auto_link_saml_user'].nil?
...@@ -190,6 +191,7 @@ Settings.gitlab.default_projects_features['visibility_level'] = Settings.send ...@@ -190,6 +191,7 @@ Settings.gitlab.default_projects_features['visibility_level'] = Settings.send
Settings.gitlab['repository_downloads_path'] = File.join(Settings.shared['path'], 'cache/archive') if Settings.gitlab['repository_downloads_path'].nil? Settings.gitlab['repository_downloads_path'] = File.join(Settings.shared['path'], 'cache/archive') if Settings.gitlab['repository_downloads_path'].nil?
Settings.gitlab['restricted_signup_domains'] ||= [] Settings.gitlab['restricted_signup_domains'] ||= []
Settings.gitlab['import_sources'] ||= ['github','bitbucket','gitlab','gitorious','google_code','fogbugz','git'] Settings.gitlab['import_sources'] ||= ['github','bitbucket','gitlab','gitorious','google_code','fogbugz','git']
Settings.gitlab['trusted_proxies'] ||= []
# #
...@@ -239,6 +241,9 @@ Settings['cron_jobs'] ||= Settingslogic.new({}) ...@@ -239,6 +241,9 @@ Settings['cron_jobs'] ||= Settingslogic.new({})
Settings.cron_jobs['stuck_ci_builds_worker'] ||= Settingslogic.new({}) Settings.cron_jobs['stuck_ci_builds_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['stuck_ci_builds_worker']['cron'] ||= '0 0 * * *' Settings.cron_jobs['stuck_ci_builds_worker']['cron'] ||= '0 0 * * *'
Settings.cron_jobs['stuck_ci_builds_worker']['job_class'] = 'StuckCiBuildsWorker' Settings.cron_jobs['stuck_ci_builds_worker']['job_class'] = 'StuckCiBuildsWorker'
Settings.cron_jobs['repository_archive_cache_worker'] ||= Settingslogic.new({})
Settings.cron_jobs['repository_archive_cache_worker']['cron'] ||= '0 * * * *'
Settings.cron_jobs['repository_archive_cache_worker']['job_class'] = 'RepositoryArchiveCacheWorker'
# #
......
if Gitlab::Metrics.enabled? if Gitlab::Metrics.enabled?
require 'pathname'
require 'influxdb' require 'influxdb'
require 'connection_pool' require 'connection_pool'
require 'method_source' require 'method_source'
...@@ -85,9 +86,6 @@ if Gitlab::Metrics.enabled? ...@@ -85,9 +86,6 @@ if Gitlab::Metrics.enabled?
config.instrument_instance_methods(const) config.instrument_instance_methods(const)
end end
config.instrument_methods(Banzai::ReferenceExtractor)
config.instrument_instance_methods(Banzai::ReferenceExtractor)
config.instrument_methods(Banzai::Renderer) config.instrument_methods(Banzai::Renderer)
config.instrument_methods(Banzai::Querying) config.instrument_methods(Banzai::Querying)
...@@ -98,6 +96,17 @@ if Gitlab::Metrics.enabled? ...@@ -98,6 +96,17 @@ if Gitlab::Metrics.enabled?
config.instrument_methods(Gitlab::ReferenceExtractor) config.instrument_methods(Gitlab::ReferenceExtractor)
config.instrument_instance_methods(Gitlab::ReferenceExtractor) config.instrument_instance_methods(Gitlab::ReferenceExtractor)
# Instrument all service classes
services = Rails.root.join('app', 'services')
Dir[services.join('**', '*.rb')].each do |file_path|
path = Pathname.new(file_path).relative_path_from(services)
const = path.to_s.sub('.rb', '').camelize.constantize
config.instrument_methods(const)
config.instrument_instance_methods(const)
end
end end
GC::Profiler.enable GC::Profiler.enable
......
Rails.application.config.action_dispatch.trusted_proxies =
[ '127.0.0.1', '::1' ] + Array(Gitlab.config.gitlab.trusted_proxies)
...@@ -406,6 +406,7 @@ Rails.application.routes.draw do ...@@ -406,6 +406,7 @@ Rails.application.routes.draw do
resource :avatar, only: [:destroy] resource :avatar, only: [:destroy]
resources :milestones, constraints: { id: /[^\/]+/ }, only: [:index, :show, :update, :new, :create] resources :milestones, constraints: { id: /[^\/]+/ }, only: [:index, :show, :update, :new, :create]
resource :notification_setting, only: [:update]
end end
end end
...@@ -607,6 +608,7 @@ Rails.application.routes.draw do ...@@ -607,6 +608,7 @@ Rails.application.routes.draw do
resources :forks, only: [:index, :new, :create] resources :forks, only: [:index, :new, :create]
resource :import, only: [:new, :create, :show] resource :import, only: [:new, :create, :show]
resource :notification_setting, only: [:update]
resources :refs, only: [] do resources :refs, only: [] do
collection do collection do
......
class CreateNotificationSettings < ActiveRecord::Migration
def change
create_table :notification_settings do |t|
t.references :user, null: false
t.references :source, polymorphic: true, null: false
t.integer :level, default: 0, null: false
t.timestamps null: false
end
end
end
# This migration will create one row of NotificationSetting for each Member row
# It can take long time on big instances.
#
# This migration can be done online but with following effects:
# - during migration some users will receive notifications based on their global settings (project/group settings will be ignored)
# - its possible to get duplicate records for notification settings since we don't create uniq index yet
#
class MigrateNewNotificationSetting < ActiveRecord::Migration
def up
timestamp = Time.now
execute "INSERT INTO notification_settings ( user_id, source_id, source_type, level, created_at, updated_at ) SELECT user_id, source_id, source_type, notification_level, '#{timestamp}', '#{timestamp}' FROM members WHERE user_id IS NOT NULL"
end
def down
execute "DELETE FROM notification_settings"
end
end
class AddNotificationSettingIndex < ActiveRecord::Migration
def change
add_index :notification_settings, :user_id
add_index :notification_settings, [:source_id, :source_type]
end
end
class AddActionToCiCommit < ActiveRecord::Migration
def change
add_column :ci_commits, :action, :string
end
end
class AddDurationToCiCommit < ActiveRecord::Migration
def change
add_column :ci_commits, :duration, :integer
end
end
...@@ -3,5 +3,6 @@ class AddFieldsToCiCommit < ActiveRecord::Migration ...@@ -3,5 +3,6 @@ class AddFieldsToCiCommit < ActiveRecord::Migration
add_column :ci_commits, :status, :string add_column :ci_commits, :status, :string
add_column :ci_commits, :started_at, :timestamp add_column :ci_commits, :started_at, :timestamp
add_column :ci_commits, :finished_at, :timestamp add_column :ci_commits, :finished_at, :timestamp
add_column :ci_commits, :duration, :integer
end end
end end
class UpdateCiCommit < ActiveRecord::Migration class UpdateCiCommit < ActiveRecord::Migration
# This migration can be run online, but needs to be executed for the second time after restarting Unicorn workers
# Otherwise Offline migration should be used.
def change def change
execute("UPDATE ci_commits SET status=#{status}, ref=#{ref}, tag=#{tag} WHERE status IS NULL") execute("UPDATE ci_commits SET status=#{status}, ref=#{ref}, tag=#{tag} WHERE status IS NULL")
end end
private
def status def status
builds = '(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id)' builds = '(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id)'
success = "(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND status='success')" success = "(SELECT COUNT(*) FROM ci_builds WHERE ci_builds.commit_id=ci_commits.id AND status='success')"
......
class AddCiCommitIndexes < ActiveRecord::Migration
disable_ddl_transaction!
def change
add_index :ci_commits, [:gl_project_id, :sha], index_options
add_index :ci_commits, [:gl_project_id, :status], index_options
add_index :ci_commits, [:status], index_options
end
private
def index_options
if Gitlab::Database.postgresql?
{ algorithm: :concurrently }
else
{ }
end
end
end
class AddCiCommitIndexes < ActiveRecord::Migration
def change
add_index :ci_commits, [:gl_project_id, :sha]
add_index :ci_commits, [:gl_project_id, :status]
add_index :ci_commits, [:status]
end
end
...@@ -42,48 +42,48 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -42,48 +42,48 @@ ActiveRecord::Schema.define(version: 20160412175417) do
t.text "sign_in_text" t.text "sign_in_text"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "home_page_url", limit: 255 t.string "home_page_url"
t.integer "default_branch_protection", default: 2 t.integer "default_branch_protection", default: 2
t.text "restricted_visibility_levels" t.text "restricted_visibility_levels"
t.integer "max_attachment_size", default: 10, null: false t.boolean "version_check_enabled", default: true
t.integer "max_attachment_size", default: 10, null: false
t.integer "default_project_visibility" t.integer "default_project_visibility"
t.integer "default_snippet_visibility" t.integer "default_snippet_visibility"
t.text "restricted_signup_domains" t.text "restricted_signup_domains"
t.boolean "version_check_enabled", default: true t.boolean "user_oauth_applications", default: true
t.boolean "user_oauth_applications", default: true t.string "after_sign_out_path"
t.string "after_sign_out_path", limit: 255 t.integer "session_expire_delay", default: 10080, null: false
t.integer "session_expire_delay", default: 10080, null: false
t.text "import_sources" t.text "import_sources"
t.text "help_page_text" t.text "help_page_text"
t.string "admin_notification_email", limit: 255 t.string "admin_notification_email"
t.boolean "shared_runners_enabled", default: true, null: false t.boolean "shared_runners_enabled", default: true, null: false
t.integer "max_artifacts_size", default: 100, null: false t.integer "max_artifacts_size", default: 100, null: false
t.string "runners_registration_token" t.string "runners_registration_token"
t.boolean "require_two_factor_authentication", default: false t.boolean "require_two_factor_authentication", default: false
t.integer "two_factor_grace_period", default: 48 t.integer "two_factor_grace_period", default: 48
t.boolean "metrics_enabled", default: false t.boolean "metrics_enabled", default: false
t.string "metrics_host", default: "localhost" t.string "metrics_host", default: "localhost"
t.integer "metrics_pool_size", default: 16 t.integer "metrics_pool_size", default: 16
t.integer "metrics_timeout", default: 10 t.integer "metrics_timeout", default: 10
t.integer "metrics_method_call_threshold", default: 10 t.integer "metrics_method_call_threshold", default: 10
t.boolean "recaptcha_enabled", default: false t.boolean "recaptcha_enabled", default: false
t.string "recaptcha_site_key" t.string "recaptcha_site_key"
t.string "recaptcha_private_key" t.string "recaptcha_private_key"
t.integer "metrics_port", default: 8089 t.integer "metrics_port", default: 8089
t.integer "metrics_sample_interval", default: 15 t.integer "metrics_sample_interval", default: 15
t.boolean "sentry_enabled", default: false t.boolean "sentry_enabled", default: false
t.string "sentry_dsn" t.string "sentry_dsn"
t.boolean "akismet_enabled", default: false t.boolean "akismet_enabled", default: false
t.string "akismet_api_key" t.string "akismet_api_key"
t.boolean "email_author_in_body", default: false t.boolean "email_author_in_body", default: false
t.integer "default_group_visibility" t.integer "default_group_visibility"
end end
create_table "audit_events", force: :cascade do |t| create_table "audit_events", force: :cascade do |t|
t.integer "author_id", null: false t.integer "author_id", null: false
t.string "type", limit: 255, null: false t.string "type", null: false
t.integer "entity_id", null: false t.integer "entity_id", null: false
t.string "entity_type", limit: 255, null: false t.string "entity_type", null: false
t.text "details" t.text "details"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
...@@ -94,13 +94,13 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -94,13 +94,13 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "audit_events", ["type"], name: "index_audit_events_on_type", using: :btree add_index "audit_events", ["type"], name: "index_audit_events_on_type", using: :btree
create_table "broadcast_messages", force: :cascade do |t| create_table "broadcast_messages", force: :cascade do |t|
t.text "message", null: false t.text "message", null: false
t.datetime "starts_at" t.datetime "starts_at"
t.datetime "ends_at" t.datetime "ends_at"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.string "color", limit: 510 t.string "color"
t.string "font", limit: 510 t.string "font"
end end
create_table "ci_application_settings", force: :cascade do |t| create_table "ci_application_settings", force: :cascade do |t|
...@@ -112,7 +112,7 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -112,7 +112,7 @@ ActiveRecord::Schema.define(version: 20160412175417) do
create_table "ci_builds", force: :cascade do |t| create_table "ci_builds", force: :cascade do |t|
t.integer "project_id" t.integer "project_id"
t.string "status", limit: 255 t.string "status"
t.datetime "finished_at" t.datetime "finished_at"
t.text "trace" t.text "trace"
t.datetime "created_at" t.datetime "created_at"
...@@ -123,19 +123,19 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -123,19 +123,19 @@ ActiveRecord::Schema.define(version: 20160412175417) do
t.integer "commit_id" t.integer "commit_id"
t.text "commands" t.text "commands"
t.integer "job_id" t.integer "job_id"
t.string "name", limit: 255 t.string "name"
t.boolean "deploy", default: false t.boolean "deploy", default: false
t.text "options" t.text "options"
t.boolean "allow_failure", default: false, null: false t.boolean "allow_failure", default: false, null: false
t.string "stage", limit: 255 t.string "stage"
t.integer "trigger_request_id" t.integer "trigger_request_id"
t.integer "stage_idx" t.integer "stage_idx"
t.boolean "tag" t.boolean "tag"
t.string "ref", limit: 255 t.string "ref"
t.integer "user_id" t.integer "user_id"
t.string "type", limit: 255 t.string "type"
t.string "target_url", limit: 255 t.string "target_url"
t.string "description", limit: 255 t.string "description"
t.text "artifacts_file" t.text "artifacts_file"
t.integer "gl_project_id" t.integer "gl_project_id"
t.text "artifacts_metadata" t.text "artifacts_metadata"
...@@ -145,7 +145,6 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -145,7 +145,6 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "ci_builds", ["commit_id", "stage_idx", "created_at"], name: "index_ci_builds_on_commit_id_and_stage_idx_and_created_at", using: :btree add_index "ci_builds", ["commit_id", "stage_idx", "created_at"], name: "index_ci_builds_on_commit_id_and_stage_idx_and_created_at", using: :btree
add_index "ci_builds", ["commit_id", "status", "type"], name: "index_ci_builds_on_commit_id_and_status_and_type", using: :btree add_index "ci_builds", ["commit_id", "status", "type"], name: "index_ci_builds_on_commit_id_and_status_and_type", using: :btree
add_index "ci_builds", ["commit_id", "status"], name: "index_ci_builds_on_commit_id_and_status", using: :btree
add_index "ci_builds", ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref", using: :btree add_index "ci_builds", ["commit_id", "type", "name", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_name_and_ref", using: :btree
add_index "ci_builds", ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref", using: :btree add_index "ci_builds", ["commit_id", "type", "ref"], name: "index_ci_builds_on_commit_id_and_type_and_ref", using: :btree
add_index "ci_builds", ["commit_id"], name: "index_ci_builds_on_commit_id", using: :btree add_index "ci_builds", ["commit_id"], name: "index_ci_builds_on_commit_id", using: :btree
...@@ -155,25 +154,23 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -155,25 +154,23 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "ci_builds", ["project_id"], name: "index_ci_builds_on_project_id", using: :btree add_index "ci_builds", ["project_id"], name: "index_ci_builds_on_project_id", using: :btree
add_index "ci_builds", ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree add_index "ci_builds", ["runner_id"], name: "index_ci_builds_on_runner_id", using: :btree
add_index "ci_builds", ["status"], name: "index_ci_builds_on_status", using: :btree add_index "ci_builds", ["status"], name: "index_ci_builds_on_status", using: :btree
add_index "ci_builds", ["type", "status", "runner_id"], name: "index_ci_builds_on_test2", using: :btree
add_index "ci_builds", ["type"], name: "index_ci_builds_on_type", using: :btree add_index "ci_builds", ["type"], name: "index_ci_builds_on_type", using: :btree
create_table "ci_commits", force: :cascade do |t| create_table "ci_commits", force: :cascade do |t|
t.integer "project_id" t.integer "project_id"
t.string "ref", limit: 255 t.string "ref"
t.string "sha", limit: 255 t.string "sha"
t.string "before_sha", limit: 255 t.string "before_sha"
t.text "push_data" t.text "push_data"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.boolean "tag", default: false t.boolean "tag", default: false
t.text "yaml_errors" t.text "yaml_errors"
t.datetime "committed_at" t.datetime "committed_at"
t.integer "gl_project_id" t.integer "gl_project_id"
t.string "status" t.string "status"
t.datetime "started_at" t.datetime "started_at"
t.datetime "finished_at" t.datetime "finished_at"
t.string "action"
t.integer "duration" t.integer "duration"
end end
...@@ -201,16 +198,16 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -201,16 +198,16 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "ci_events", ["project_id"], name: "index_ci_events_on_project_id", using: :btree add_index "ci_events", ["project_id"], name: "index_ci_events_on_project_id", using: :btree
create_table "ci_jobs", force: :cascade do |t| create_table "ci_jobs", force: :cascade do |t|
t.integer "project_id", null: false t.integer "project_id", null: false
t.text "commands" t.text "commands"
t.boolean "active", default: true, null: false t.boolean "active", default: true, null: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "name", limit: 255 t.string "name"
t.boolean "build_branches", default: true, null: false t.boolean "build_branches", default: true, null: false
t.boolean "build_tags", default: false, null: false t.boolean "build_tags", default: false, null: false
t.string "job_type", limit: 255, default: "parallel" t.string "job_type", default: "parallel"
t.string "refs", limit: 255 t.string "refs"
t.datetime "deleted_at" t.datetime "deleted_at"
end end
...@@ -218,25 +215,25 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -218,25 +215,25 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "ci_jobs", ["project_id"], name: "index_ci_jobs_on_project_id", using: :btree add_index "ci_jobs", ["project_id"], name: "index_ci_jobs_on_project_id", using: :btree
create_table "ci_projects", force: :cascade do |t| create_table "ci_projects", force: :cascade do |t|
t.string "name", limit: 255 t.string "name"
t.integer "timeout", default: 3600, null: false t.integer "timeout", default: 3600, null: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "token", limit: 255 t.string "token"
t.string "default_ref", limit: 255 t.string "default_ref"
t.string "path", limit: 255 t.string "path"
t.boolean "always_build", default: false, null: false t.boolean "always_build", default: false, null: false
t.integer "polling_interval" t.integer "polling_interval"
t.boolean "public", default: false, null: false t.boolean "public", default: false, null: false
t.string "ssh_url_to_repo", limit: 255 t.string "ssh_url_to_repo"
t.integer "gitlab_id" t.integer "gitlab_id"
t.boolean "allow_git_fetch", default: true, null: false t.boolean "allow_git_fetch", default: true, null: false
t.string "email_recipients", limit: 255, default: "", null: false t.string "email_recipients", default: "", null: false
t.boolean "email_add_pusher", default: true, null: false t.boolean "email_add_pusher", default: true, null: false
t.boolean "email_only_broken_builds", default: true, null: false t.boolean "email_only_broken_builds", default: true, null: false
t.string "skip_refs", limit: 255 t.string "skip_refs"
t.string "coverage_regex", limit: 255 t.string "coverage_regex"
t.boolean "shared_runners_enabled", default: false t.boolean "shared_runners_enabled", default: false
t.text "generated_yaml_config" t.text "generated_yaml_config"
end end
...@@ -255,18 +252,18 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -255,18 +252,18 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "ci_runner_projects", ["runner_id"], name: "index_ci_runner_projects_on_runner_id", using: :btree add_index "ci_runner_projects", ["runner_id"], name: "index_ci_runner_projects_on_runner_id", using: :btree
create_table "ci_runners", force: :cascade do |t| create_table "ci_runners", force: :cascade do |t|
t.string "token", limit: 255 t.string "token"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "description", limit: 255 t.string "description"
t.datetime "contacted_at" t.datetime "contacted_at"
t.boolean "active", default: true, null: false t.boolean "active", default: true, null: false
t.boolean "is_shared", default: false t.boolean "is_shared", default: false
t.string "name", limit: 255 t.string "name"
t.string "version", limit: 255 t.string "version"
t.string "revision", limit: 255 t.string "revision"
t.string "platform", limit: 255 t.string "platform"
t.string "architecture", limit: 255 t.string "architecture"
end end
add_index "ci_runners", ["description"], name: "index_ci_runners_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"} add_index "ci_runners", ["description"], name: "index_ci_runners_on_description_trigram", using: :gin, opclasses: {"description"=>"gin_trgm_ops"}
...@@ -274,19 +271,19 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -274,19 +271,19 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "ci_runners", ["token"], name: "index_ci_runners_on_token_trigram", using: :gin, opclasses: {"token"=>"gin_trgm_ops"} add_index "ci_runners", ["token"], name: "index_ci_runners_on_token_trigram", using: :gin, opclasses: {"token"=>"gin_trgm_ops"}
create_table "ci_services", force: :cascade do |t| create_table "ci_services", force: :cascade do |t|
t.string "type", limit: 255 t.string "type"
t.string "title", limit: 255 t.string "title"
t.integer "project_id", null: false t.integer "project_id", null: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.boolean "active", default: false, null: false t.boolean "active", default: false, null: false
t.text "properties" t.text "properties"
end end
add_index "ci_services", ["project_id"], name: "index_ci_services_on_project_id", using: :btree add_index "ci_services", ["project_id"], name: "index_ci_services_on_project_id", using: :btree
create_table "ci_sessions", force: :cascade do |t| create_table "ci_sessions", force: :cascade do |t|
t.string "session_id", limit: 255, null: false t.string "session_id", null: false
t.text "data" t.text "data"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
...@@ -298,9 +295,9 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -298,9 +295,9 @@ ActiveRecord::Schema.define(version: 20160412175417) do
create_table "ci_taggings", force: :cascade do |t| create_table "ci_taggings", force: :cascade do |t|
t.integer "tag_id" t.integer "tag_id"
t.integer "taggable_id" t.integer "taggable_id"
t.string "taggable_type", limit: 255 t.string "taggable_type"
t.integer "tagger_id" t.integer "tagger_id"
t.string "tagger_type", limit: 255 t.string "tagger_type"
t.string "context", limit: 128 t.string "context", limit: 128
t.datetime "created_at" t.datetime "created_at"
end end
...@@ -309,8 +306,8 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -309,8 +306,8 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "ci_taggings", ["taggable_id", "taggable_type", "context"], name: "index_ci_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree add_index "ci_taggings", ["taggable_id", "taggable_type", "context"], name: "index_ci_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
create_table "ci_tags", force: :cascade do |t| create_table "ci_tags", force: :cascade do |t|
t.string "name", limit: 255 t.string "name"
t.integer "taggings_count", default: 0 t.integer "taggings_count", default: 0
end end
add_index "ci_tags", ["name"], name: "index_ci_tags_on_name", unique: true, using: :btree add_index "ci_tags", ["name"], name: "index_ci_tags_on_name", unique: true, using: :btree
...@@ -324,7 +321,7 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -324,7 +321,7 @@ ActiveRecord::Schema.define(version: 20160412175417) do
end end
create_table "ci_triggers", force: :cascade do |t| create_table "ci_triggers", force: :cascade do |t|
t.string "token", limit: 255 t.string "token"
t.integer "project_id" t.integer "project_id"
t.datetime "deleted_at" t.datetime "deleted_at"
t.datetime "created_at" t.datetime "created_at"
...@@ -337,19 +334,19 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -337,19 +334,19 @@ ActiveRecord::Schema.define(version: 20160412175417) do
create_table "ci_variables", force: :cascade do |t| create_table "ci_variables", force: :cascade do |t|
t.integer "project_id" t.integer "project_id"
t.string "key", limit: 255 t.string "key"
t.text "value" t.text "value"
t.text "encrypted_value" t.text "encrypted_value"
t.string "encrypted_value_salt", limit: 255 t.string "encrypted_value_salt"
t.string "encrypted_value_iv", limit: 255 t.string "encrypted_value_iv"
t.integer "gl_project_id" t.integer "gl_project_id"
end end
add_index "ci_variables", ["gl_project_id"], name: "index_ci_variables_on_gl_project_id", using: :btree add_index "ci_variables", ["gl_project_id"], name: "index_ci_variables_on_gl_project_id", using: :btree
create_table "ci_web_hooks", force: :cascade do |t| create_table "ci_web_hooks", force: :cascade do |t|
t.string "url", limit: 255, null: false t.string "url", null: false
t.integer "project_id", null: false t.integer "project_id", null: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
...@@ -357,30 +354,30 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -357,30 +354,30 @@ ActiveRecord::Schema.define(version: 20160412175417) do
create_table "deploy_keys_projects", force: :cascade do |t| create_table "deploy_keys_projects", force: :cascade do |t|
t.integer "deploy_key_id", null: false t.integer "deploy_key_id", null: false
t.integer "project_id", null: false t.integer "project_id", null: false
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
end end
add_index "deploy_keys_projects", ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree add_index "deploy_keys_projects", ["project_id"], name: "index_deploy_keys_projects_on_project_id", using: :btree
create_table "emails", force: :cascade do |t| create_table "emails", force: :cascade do |t|
t.integer "user_id", null: false t.integer "user_id", null: false
t.string "email", limit: 510, null: false t.string "email", null: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
add_index "emails", ["email"], name: "emails_email_key", unique: true, using: :btree add_index "emails", ["email"], name: "index_emails_on_email", unique: true, using: :btree
add_index "emails", ["user_id"], name: "index_emails_on_user_id", using: :btree add_index "emails", ["user_id"], name: "index_emails_on_user_id", using: :btree
create_table "events", force: :cascade do |t| create_table "events", force: :cascade do |t|
t.string "target_type", limit: 510 t.string "target_type"
t.integer "target_id" t.integer "target_id"
t.string "title", limit: 510 t.string "title"
t.text "data" t.text "data"
t.integer "project_id" t.integer "project_id"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.integer "action" t.integer "action"
t.integer "author_id" t.integer "author_id"
end end
...@@ -395,15 +392,15 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -395,15 +392,15 @@ ActiveRecord::Schema.define(version: 20160412175417) do
create_table "forked_project_links", force: :cascade do |t| create_table "forked_project_links", force: :cascade do |t|
t.integer "forked_to_project_id", null: false t.integer "forked_to_project_id", null: false
t.integer "forked_from_project_id", null: false t.integer "forked_from_project_id", null: false
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
end end
add_index "forked_project_links", ["forked_to_project_id"], name: "forked_project_links_forked_to_project_id_key", unique: true, using: :btree add_index "forked_project_links", ["forked_to_project_id"], name: "index_forked_project_links_on_forked_to_project_id", unique: true, using: :btree
create_table "identities", force: :cascade do |t| create_table "identities", force: :cascade do |t|
t.string "extern_uid", limit: 255 t.string "extern_uid"
t.string "provider", limit: 255 t.string "provider"
t.integer "user_id" t.integer "user_id"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
...@@ -413,21 +410,21 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -413,21 +410,21 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "identities", ["user_id"], name: "index_identities_on_user_id", using: :btree add_index "identities", ["user_id"], name: "index_identities_on_user_id", using: :btree
create_table "issues", force: :cascade do |t| create_table "issues", force: :cascade do |t|
t.string "title", limit: 510 t.string "title"
t.integer "assignee_id" t.integer "assignee_id"
t.integer "author_id" t.integer "author_id"
t.integer "project_id" t.integer "project_id"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "position", default: 0 t.integer "position", default: 0
t.string "branch_name", limit: 510 t.string "branch_name"
t.text "description" t.text "description"
t.integer "milestone_id" t.integer "milestone_id"
t.string "state", limit: 510 t.string "state"
t.integer "iid" t.integer "iid"
t.integer "updated_by_id" t.integer "updated_by_id"
t.boolean "confidential", default: false
t.integer "moved_to_id" t.integer "moved_to_id"
t.boolean "confidential", default: false
t.datetime "deleted_at" t.datetime "deleted_at"
end end
...@@ -450,10 +447,10 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -450,10 +447,10 @@ ActiveRecord::Schema.define(version: 20160412175417) do
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.text "key" t.text "key"
t.string "title", limit: 510 t.string "title"
t.string "type", limit: 510 t.string "type"
t.string "fingerprint", limit: 510 t.string "fingerprint"
t.boolean "public", default: false, null: false t.boolean "public", default: false, null: false
end end
add_index "keys", ["created_at", "id"], name: "index_keys_on_created_at_and_id", using: :btree add_index "keys", ["created_at", "id"], name: "index_keys_on_created_at_and_id", using: :btree
...@@ -462,7 +459,7 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -462,7 +459,7 @@ ActiveRecord::Schema.define(version: 20160412175417) do
create_table "label_links", force: :cascade do |t| create_table "label_links", force: :cascade do |t|
t.integer "label_id" t.integer "label_id"
t.integer "target_id" t.integer "target_id"
t.string "target_type", limit: 255 t.string "target_type"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
end end
...@@ -471,23 +468,23 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -471,23 +468,23 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "label_links", ["target_id", "target_type"], name: "index_label_links_on_target_id_and_target_type", using: :btree add_index "label_links", ["target_id", "target_type"], name: "index_label_links_on_target_id_and_target_type", using: :btree
create_table "labels", force: :cascade do |t| create_table "labels", force: :cascade do |t|
t.string "title", limit: 255 t.string "title"
t.string "color", limit: 255 t.string "color"
t.integer "project_id" t.integer "project_id"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.boolean "template", default: false t.boolean "template", default: false
t.string "description" t.string "description"
end end
add_index "labels", ["project_id"], name: "index_labels_on_project_id", using: :btree add_index "labels", ["project_id"], name: "index_labels_on_project_id", using: :btree
create_table "lfs_objects", force: :cascade do |t| create_table "lfs_objects", force: :cascade do |t|
t.string "oid", limit: 255, null: false t.string "oid", null: false
t.integer "size", limit: 8, null: false t.integer "size", limit: 8, null: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "file", limit: 255 t.string "file"
end end
add_index "lfs_objects", ["oid"], name: "index_lfs_objects_on_oid", unique: true, using: :btree add_index "lfs_objects", ["oid"], name: "index_lfs_objects_on_oid", unique: true, using: :btree
...@@ -502,17 +499,17 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -502,17 +499,17 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "lfs_objects_projects", ["project_id"], name: "index_lfs_objects_projects_on_project_id", using: :btree add_index "lfs_objects_projects", ["project_id"], name: "index_lfs_objects_projects_on_project_id", using: :btree
create_table "members", force: :cascade do |t| create_table "members", force: :cascade do |t|
t.integer "access_level", null: false t.integer "access_level", null: false
t.integer "source_id", null: false t.integer "source_id", null: false
t.string "source_type", limit: 255, null: false t.string "source_type", null: false
t.integer "user_id" t.integer "user_id"
t.integer "notification_level", null: false t.integer "notification_level", null: false
t.string "type", limit: 255 t.string "type"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "created_by_id" t.integer "created_by_id"
t.string "invite_email", limit: 255 t.string "invite_email"
t.string "invite_token", limit: 255 t.string "invite_token"
t.datetime "invite_accepted_at" t.datetime "invite_accepted_at"
end end
...@@ -524,10 +521,10 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -524,10 +521,10 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "members", ["user_id"], name: "index_members_on_user_id", using: :btree add_index "members", ["user_id"], name: "index_members_on_user_id", using: :btree
create_table "merge_request_diffs", force: :cascade do |t| create_table "merge_request_diffs", force: :cascade do |t|
t.string "state", limit: 255 t.string "state"
t.text "st_commits" t.text "st_commits"
t.text "st_diffs" t.text "st_diffs"
t.integer "merge_request_id", null: false t.integer "merge_request_id", null: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "base_commit_sha" t.string "base_commit_sha"
...@@ -537,26 +534,26 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -537,26 +534,26 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "merge_request_diffs", ["merge_request_id"], name: "index_merge_request_diffs_on_merge_request_id", unique: true, using: :btree add_index "merge_request_diffs", ["merge_request_id"], name: "index_merge_request_diffs_on_merge_request_id", unique: true, using: :btree
create_table "merge_requests", force: :cascade do |t| create_table "merge_requests", force: :cascade do |t|
t.string "target_branch", limit: 510, null: false t.string "target_branch", null: false
t.string "source_branch", limit: 510, null: false t.string "source_branch", null: false
t.integer "source_project_id", null: false t.integer "source_project_id", null: false
t.integer "author_id" t.integer "author_id"
t.integer "assignee_id" t.integer "assignee_id"
t.string "title", limit: 510 t.string "title"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "milestone_id" t.integer "milestone_id"
t.string "state", limit: 510 t.string "state"
t.string "merge_status", limit: 510 t.string "merge_status"
t.integer "target_project_id", null: false t.integer "target_project_id", null: false
t.integer "iid" t.integer "iid"
t.text "description" t.text "description"
t.integer "position", default: 0 t.integer "position", default: 0
t.datetime "locked_at" t.datetime "locked_at"
t.integer "updated_by_id" t.integer "updated_by_id"
t.string "merge_error", limit: 255 t.string "merge_error"
t.text "merge_params" t.text "merge_params"
t.boolean "merge_when_build_succeeds", default: false, null: false t.boolean "merge_when_build_succeeds", default: false, null: false
t.integer "merge_user_id" t.integer "merge_user_id"
t.string "merge_commit_sha" t.string "merge_commit_sha"
t.datetime "deleted_at" t.datetime "deleted_at"
...@@ -577,13 +574,13 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -577,13 +574,13 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "merge_requests", ["title"], name: "index_merge_requests_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"} add_index "merge_requests", ["title"], name: "index_merge_requests_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"}
create_table "milestones", force: :cascade do |t| create_table "milestones", force: :cascade do |t|
t.string "title", limit: 510, null: false t.string "title", null: false
t.integer "project_id", null: false t.integer "project_id", null: false
t.text "description" t.text "description"
t.date "due_date" t.date "due_date"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.string "state", limit: 510 t.string "state"
t.integer "iid" t.integer "iid"
end end
...@@ -596,16 +593,16 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -596,16 +593,16 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "milestones", ["title"], name: "index_milestones_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"} add_index "milestones", ["title"], name: "index_milestones_on_title_trigram", using: :gin, opclasses: {"title"=>"gin_trgm_ops"}
create_table "namespaces", force: :cascade do |t| create_table "namespaces", force: :cascade do |t|
t.string "name", limit: 510, null: false t.string "name", null: false
t.string "path", limit: 510, null: false t.string "path", null: false
t.integer "owner_id" t.integer "owner_id"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.string "type", limit: 510 t.string "type"
t.string "description", limit: 510, default: "", null: false t.string "description", default: "", null: false
t.string "avatar", limit: 510 t.string "avatar"
t.boolean "share_with_group_lock", default: false t.boolean "share_with_group_lock", default: false
t.integer "visibility_level", default: 20, null: false t.integer "visibility_level", default: 20, null: false
end end
add_index "namespaces", ["created_at", "id"], name: "index_namespaces_on_created_at_and_id", using: :btree add_index "namespaces", ["created_at", "id"], name: "index_namespaces_on_created_at_and_id", using: :btree
...@@ -619,19 +616,19 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -619,19 +616,19 @@ ActiveRecord::Schema.define(version: 20160412175417) do
create_table "notes", force: :cascade do |t| create_table "notes", force: :cascade do |t|
t.text "note" t.text "note"
t.string "noteable_type", limit: 510 t.string "noteable_type"
t.integer "author_id" t.integer "author_id"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "project_id" t.integer "project_id"
t.string "attachment", limit: 510 t.string "attachment"
t.string "line_code", limit: 510 t.string "line_code"
t.string "commit_id", limit: 510 t.string "commit_id"
t.integer "noteable_id" t.integer "noteable_id"
t.boolean "system", default: false, null: false
t.text "st_diff" t.text "st_diff"
t.boolean "system", null: false
t.integer "updated_by_id" t.integer "updated_by_id"
t.boolean "is_award", default: false, null: false t.boolean "is_award", default: false, null: false
end end
add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree add_index "notes", ["author_id"], name: "index_notes_on_author_id", using: :btree
...@@ -647,15 +644,27 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -647,15 +644,27 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "notes", ["project_id"], name: "index_notes_on_project_id", using: :btree add_index "notes", ["project_id"], name: "index_notes_on_project_id", using: :btree
add_index "notes", ["updated_at"], name: "index_notes_on_updated_at", using: :btree add_index "notes", ["updated_at"], name: "index_notes_on_updated_at", using: :btree
create_table "notification_settings", force: :cascade do |t|
t.integer "user_id", null: false
t.integer "source_id", null: false
t.string "source_type", null: false
t.integer "level", default: 0, null: false
t.datetime "created_at", null: false
t.datetime "updated_at", null: false
end
add_index "notification_settings", ["source_id", "source_type"], name: "index_notification_settings_on_source_id_and_source_type", using: :btree
add_index "notification_settings", ["user_id"], name: "index_notification_settings_on_user_id", using: :btree
create_table "oauth_access_grants", force: :cascade do |t| create_table "oauth_access_grants", force: :cascade do |t|
t.integer "resource_owner_id", null: false t.integer "resource_owner_id", null: false
t.integer "application_id", null: false t.integer "application_id", null: false
t.string "token", limit: 255, null: false t.string "token", null: false
t.integer "expires_in", null: false t.integer "expires_in", null: false
t.text "redirect_uri", null: false t.text "redirect_uri", null: false
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "revoked_at" t.datetime "revoked_at"
t.string "scopes", limit: 255 t.string "scopes"
end end
add_index "oauth_access_grants", ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree add_index "oauth_access_grants", ["token"], name: "index_oauth_access_grants_on_token", unique: true, using: :btree
...@@ -663,12 +672,12 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -663,12 +672,12 @@ ActiveRecord::Schema.define(version: 20160412175417) do
create_table "oauth_access_tokens", force: :cascade do |t| create_table "oauth_access_tokens", force: :cascade do |t|
t.integer "resource_owner_id" t.integer "resource_owner_id"
t.integer "application_id" t.integer "application_id"
t.string "token", limit: 255, null: false t.string "token", null: false
t.string "refresh_token", limit: 255 t.string "refresh_token"
t.integer "expires_in" t.integer "expires_in"
t.datetime "revoked_at" t.datetime "revoked_at"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.string "scopes", limit: 255 t.string "scopes"
end end
add_index "oauth_access_tokens", ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree add_index "oauth_access_tokens", ["refresh_token"], name: "index_oauth_access_tokens_on_refresh_token", unique: true, using: :btree
...@@ -676,15 +685,15 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -676,15 +685,15 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "oauth_access_tokens", ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree add_index "oauth_access_tokens", ["token"], name: "index_oauth_access_tokens_on_token", unique: true, using: :btree
create_table "oauth_applications", force: :cascade do |t| create_table "oauth_applications", force: :cascade do |t|
t.string "name", limit: 255, null: false t.string "name", null: false
t.string "uid", limit: 255, null: false t.string "uid", null: false
t.string "secret", limit: 255, null: false t.string "secret", null: false
t.text "redirect_uri", null: false t.text "redirect_uri", null: false
t.string "scopes", limit: 255, default: "", null: false t.string "scopes", default: "", null: false
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "owner_id" t.integer "owner_id"
t.string "owner_type", limit: 255 t.string "owner_type"
end end
add_index "oauth_applications", ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree add_index "oauth_applications", ["owner_id", "owner_type"], name: "index_oauth_applications_on_owner_id_and_owner_type", using: :btree
...@@ -704,43 +713,43 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -704,43 +713,43 @@ ActiveRecord::Schema.define(version: 20160412175417) do
end end
create_table "projects", force: :cascade do |t| create_table "projects", force: :cascade do |t|
t.string "name", limit: 510 t.string "name"
t.string "path", limit: 510 t.string "path"
t.text "description" t.text "description"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.integer "creator_id" t.integer "creator_id"
t.boolean "issues_enabled", null: false t.boolean "issues_enabled", default: true, null: false
t.boolean "wall_enabled", null: false t.boolean "wall_enabled", default: true, null: false
t.boolean "merge_requests_enabled", null: false t.boolean "merge_requests_enabled", default: true, null: false
t.boolean "wiki_enabled", null: false t.boolean "wiki_enabled", default: true, null: false
t.integer "namespace_id" t.integer "namespace_id"
t.string "issues_tracker", limit: 510, default: "gitlab", null: false t.string "issues_tracker", default: "gitlab", null: false
t.string "issues_tracker_id", limit: 510 t.string "issues_tracker_id"
t.boolean "snippets_enabled", null: false t.boolean "snippets_enabled", default: true, null: false
t.datetime "last_activity_at" t.datetime "last_activity_at"
t.string "import_url", limit: 510 t.string "import_url"
t.integer "visibility_level", default: 0, null: false t.integer "visibility_level", default: 0, null: false
t.boolean "archived", null: false t.boolean "archived", default: false, null: false
t.string "import_status", limit: 255 t.string "avatar"
t.float "repository_size", default: 0.0 t.string "import_status"
t.integer "star_count", default: 0, null: false t.float "repository_size", default: 0.0
t.string "import_type", limit: 255 t.integer "star_count", default: 0, null: false
t.string "import_source", limit: 255 t.string "import_type"
t.string "avatar", limit: 255 t.string "import_source"
t.integer "commit_count", default: 0 t.integer "commit_count", default: 0
t.text "import_error" t.text "import_error"
t.integer "ci_id" t.integer "ci_id"
t.boolean "builds_enabled", default: true, null: false t.boolean "builds_enabled", default: true, null: false
t.boolean "shared_runners_enabled", default: true, null: false t.boolean "shared_runners_enabled", default: true, null: false
t.string "runners_token" t.string "runners_token"
t.string "build_coverage_regex" t.string "build_coverage_regex"
t.boolean "build_allow_git_fetch", default: true, null: false t.boolean "build_allow_git_fetch", default: true, null: false
t.integer "build_timeout", default: 3600, null: false t.integer "build_timeout", default: 3600, null: false
t.boolean "pending_delete", default: false t.boolean "pending_delete", default: false
t.boolean "public_builds", default: true, null: false t.boolean "public_builds", default: true, null: false
t.string "main_language" t.string "main_language"
t.integer "pushes_since_gc", default: 0 t.integer "pushes_since_gc", default: 0
end end
add_index "projects", ["builds_enabled", "shared_runners_enabled"], name: "index_projects_on_builds_enabled_and_shared_runners_enabled", using: :btree add_index "projects", ["builds_enabled", "shared_runners_enabled"], name: "index_projects_on_builds_enabled_and_shared_runners_enabled", using: :btree
...@@ -760,17 +769,17 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -760,17 +769,17 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "projects", ["visibility_level"], name: "index_projects_on_visibility_level", using: :btree add_index "projects", ["visibility_level"], name: "index_projects_on_visibility_level", using: :btree
create_table "protected_branches", force: :cascade do |t| create_table "protected_branches", force: :cascade do |t|
t.integer "project_id", null: false t.integer "project_id", null: false
t.string "name", limit: 510, null: false t.string "name", null: false
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.boolean "developers_can_push", default: false, null: false t.boolean "developers_can_push", default: false, null: false
end end
add_index "protected_branches", ["project_id"], name: "index_protected_branches_on_project_id", using: :btree add_index "protected_branches", ["project_id"], name: "index_protected_branches_on_project_id", using: :btree
create_table "releases", force: :cascade do |t| create_table "releases", force: :cascade do |t|
t.string "tag", limit: 255 t.string "tag"
t.text "description" t.text "description"
t.integer "project_id" t.integer "project_id"
t.datetime "created_at" t.datetime "created_at"
...@@ -783,32 +792,32 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -783,32 +792,32 @@ ActiveRecord::Schema.define(version: 20160412175417) do
create_table "sent_notifications", force: :cascade do |t| create_table "sent_notifications", force: :cascade do |t|
t.integer "project_id" t.integer "project_id"
t.integer "noteable_id" t.integer "noteable_id"
t.string "noteable_type", limit: 255 t.string "noteable_type"
t.integer "recipient_id" t.integer "recipient_id"
t.string "commit_id", limit: 255 t.string "commit_id"
t.string "reply_key", limit: 255, null: false t.string "reply_key", null: false
t.string "line_code", limit: 255 t.string "line_code"
end end
add_index "sent_notifications", ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true, using: :btree add_index "sent_notifications", ["reply_key"], name: "index_sent_notifications_on_reply_key", unique: true, using: :btree
create_table "services", force: :cascade do |t| create_table "services", force: :cascade do |t|
t.string "type", limit: 510 t.string "type"
t.string "title", limit: 510 t.string "title"
t.integer "project_id" t.integer "project_id"
t.datetime "created_at", null: false t.datetime "created_at", null: false
t.datetime "updated_at", null: false t.datetime "updated_at", null: false
t.boolean "active", null: false t.boolean "active", null: false
t.text "properties" t.text "properties"
t.boolean "template", default: false t.boolean "template", default: false
t.boolean "push_events", default: true t.boolean "push_events", default: true
t.boolean "issues_events", default: true t.boolean "issues_events", default: true
t.boolean "merge_requests_events", default: true t.boolean "merge_requests_events", default: true
t.boolean "tag_push_events", default: true t.boolean "tag_push_events", default: true
t.boolean "note_events", default: true, null: false t.boolean "note_events", default: true, null: false
t.boolean "build_events", default: false, null: false t.boolean "build_events", default: false, null: false
t.string "category", default: "common", null: false t.string "category", default: "common", null: false
t.boolean "default", default: false t.boolean "default", default: false
end end
add_index "services", ["category"], name: "index_services_on_category", using: :btree add_index "services", ["category"], name: "index_services_on_category", using: :btree
...@@ -818,15 +827,15 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -818,15 +827,15 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "services", ["template"], name: "index_services_on_template", using: :btree add_index "services", ["template"], name: "index_services_on_template", using: :btree
create_table "snippets", force: :cascade do |t| create_table "snippets", force: :cascade do |t|
t.string "title", limit: 510 t.string "title"
t.text "content" t.text "content"
t.integer "author_id", null: false t.integer "author_id", null: false
t.integer "project_id" t.integer "project_id"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "file_name", limit: 510 t.string "file_name"
t.string "type", limit: 510 t.string "type"
t.integer "visibility_level", default: 0, null: false t.integer "visibility_level", default: 0, null: false
end end
add_index "snippets", ["author_id"], name: "index_snippets_on_author_id", using: :btree add_index "snippets", ["author_id"], name: "index_snippets_on_author_id", using: :btree
...@@ -854,7 +863,7 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -854,7 +863,7 @@ ActiveRecord::Schema.define(version: 20160412175417) do
create_table "subscriptions", force: :cascade do |t| create_table "subscriptions", force: :cascade do |t|
t.integer "user_id" t.integer "user_id"
t.integer "subscribable_id" t.integer "subscribable_id"
t.string "subscribable_type", limit: 255 t.string "subscribable_type"
t.boolean "subscribed" t.boolean "subscribed"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
...@@ -865,10 +874,10 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -865,10 +874,10 @@ ActiveRecord::Schema.define(version: 20160412175417) do
create_table "taggings", force: :cascade do |t| create_table "taggings", force: :cascade do |t|
t.integer "tag_id" t.integer "tag_id"
t.integer "taggable_id" t.integer "taggable_id"
t.string "taggable_type", limit: 510 t.string "taggable_type"
t.integer "tagger_id" t.integer "tagger_id"
t.string "tagger_type", limit: 510 t.string "tagger_type"
t.string "context", limit: 510 t.string "context"
t.datetime "created_at" t.datetime "created_at"
end end
...@@ -876,8 +885,8 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -876,8 +885,8 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
create_table "tags", force: :cascade do |t| create_table "tags", force: :cascade do |t|
t.string "name", limit: 510 t.string "name"
t.integer "taggings_count", default: 0 t.integer "taggings_count", default: 0
end end
add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree add_index "tags", ["name"], name: "index_tags_on_name", unique: true, using: :btree
...@@ -905,76 +914,76 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -905,76 +914,76 @@ ActiveRecord::Schema.define(version: 20160412175417) do
add_index "todos", ["user_id"], name: "index_todos_on_user_id", using: :btree add_index "todos", ["user_id"], name: "index_todos_on_user_id", using: :btree
create_table "users", force: :cascade do |t| create_table "users", force: :cascade do |t|
t.string "email", limit: 510, default: "", null: false t.string "email", default: "", null: false
t.string "encrypted_password", limit: 256, default: "", null: false t.string "encrypted_password", default: "", null: false
t.string "reset_password_token", limit: 510 t.string "reset_password_token"
t.datetime "reset_password_sent_at" t.datetime "reset_password_sent_at"
t.datetime "remember_created_at" t.datetime "remember_created_at"
t.integer "sign_in_count", default: 0 t.integer "sign_in_count", default: 0
t.datetime "current_sign_in_at" t.datetime "current_sign_in_at"
t.datetime "last_sign_in_at" t.datetime "last_sign_in_at"
t.string "current_sign_in_ip", limit: 510 t.string "current_sign_in_ip"
t.string "last_sign_in_ip", limit: 510 t.string "last_sign_in_ip"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "name", limit: 510 t.string "name"
t.boolean "admin", null: false t.boolean "admin", default: false, null: false
t.integer "projects_limit", default: 10 t.integer "projects_limit", default: 10
t.string "skype", limit: 510, default: "", null: false t.string "skype", default: "", null: false
t.string "linkedin", limit: 510, default: "", null: false t.string "linkedin", default: "", null: false
t.string "twitter", limit: 510, default: "", null: false t.string "twitter", default: "", null: false
t.string "authentication_token", limit: 510 t.string "authentication_token"
t.integer "theme_id", default: 1, null: false t.integer "theme_id", default: 1, null: false
t.string "bio", limit: 510 t.string "bio"
t.integer "failed_attempts", default: 0 t.integer "failed_attempts", default: 0
t.datetime "locked_at" t.datetime "locked_at"
t.string "username", limit: 510 t.string "username"
t.boolean "can_create_group", null: false t.boolean "can_create_group", default: true, null: false
t.boolean "can_create_team", null: false t.boolean "can_create_team", default: true, null: false
t.string "state", limit: 510 t.string "state"
t.integer "color_scheme_id", default: 1, null: false t.integer "color_scheme_id", default: 1, null: false
t.integer "notification_level", default: 1, null: false t.integer "notification_level", default: 1, null: false
t.datetime "password_expires_at" t.datetime "password_expires_at"
t.integer "created_by_id" t.integer "created_by_id"
t.string "avatar", limit: 510 t.datetime "last_credential_check_at"
t.string "confirmation_token", limit: 510 t.string "avatar"
t.string "confirmation_token"
t.datetime "confirmed_at" t.datetime "confirmed_at"
t.datetime "confirmation_sent_at" t.datetime "confirmation_sent_at"
t.string "unconfirmed_email", limit: 510 t.string "unconfirmed_email"
t.boolean "hide_no_ssh_key" t.boolean "hide_no_ssh_key", default: false
t.string "website_url", limit: 510, default: "", null: false t.string "website_url", default: "", null: false
t.datetime "last_credential_check_at" t.string "notification_email"
t.string "notification_email", limit: 255 t.boolean "hide_no_password", default: false
t.boolean "hide_no_password", default: false t.boolean "password_automatically_set", default: false
t.boolean "password_automatically_set", default: false t.string "location"
t.string "location", limit: 255 t.string "encrypted_otp_secret"
t.string "public_email", limit: 255, default: "", null: false t.string "encrypted_otp_secret_iv"
t.string "encrypted_otp_secret", limit: 255 t.string "encrypted_otp_secret_salt"
t.string "encrypted_otp_secret_iv", limit: 255 t.boolean "otp_required_for_login", default: false, null: false
t.string "encrypted_otp_secret_salt", limit: 255
t.boolean "otp_required_for_login", default: false, null: false
t.text "otp_backup_codes" t.text "otp_backup_codes"
t.integer "dashboard", default: 0 t.string "public_email", default: "", null: false
t.integer "project_view", default: 0 t.integer "dashboard", default: 0
t.integer "project_view", default: 0
t.integer "consumed_timestep" t.integer "consumed_timestep"
t.integer "layout", default: 0 t.integer "layout", default: 0
t.boolean "hide_project_limit", default: false t.boolean "hide_project_limit", default: false
t.string "unlock_token" t.string "unlock_token"
t.datetime "otp_grace_period_started_at" t.datetime "otp_grace_period_started_at"
t.boolean "ldap_email", default: false, null: false t.boolean "ldap_email", default: false, null: false
t.boolean "external", default: false t.boolean "external", default: false
end end
add_index "users", ["admin"], name: "index_users_on_admin", using: :btree add_index "users", ["admin"], name: "index_users_on_admin", using: :btree
add_index "users", ["authentication_token"], name: "users_authentication_token_key", unique: true, using: :btree add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree
add_index "users", ["confirmation_token"], name: "users_confirmation_token_key", unique: true, using: :btree add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
add_index "users", ["created_at", "id"], name: "index_users_on_created_at_and_id", using: :btree add_index "users", ["created_at", "id"], name: "index_users_on_created_at_and_id", using: :btree
add_index "users", ["current_sign_in_at"], name: "index_users_on_current_sign_in_at", using: :btree add_index "users", ["current_sign_in_at"], name: "index_users_on_current_sign_in_at", using: :btree
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["email"], name: "index_users_on_email_trigram", using: :gin, opclasses: {"email"=>"gin_trgm_ops"} add_index "users", ["email"], name: "index_users_on_email_trigram", using: :gin, opclasses: {"email"=>"gin_trgm_ops"}
add_index "users", ["email"], name: "users_email_key", unique: true, using: :btree
add_index "users", ["name"], name: "index_users_on_name", using: :btree add_index "users", ["name"], name: "index_users_on_name", using: :btree
add_index "users", ["name"], name: "index_users_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"} add_index "users", ["name"], name: "index_users_on_name_trigram", using: :gin, opclasses: {"name"=>"gin_trgm_ops"}
add_index "users", ["reset_password_token"], name: "users_reset_password_token_key", unique: true, using: :btree add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
add_index "users", ["username"], name: "index_users_on_username", using: :btree add_index "users", ["username"], name: "index_users_on_username", using: :btree
add_index "users", ["username"], name: "index_users_on_username_trigram", using: :gin, opclasses: {"username"=>"gin_trgm_ops"} add_index "users", ["username"], name: "index_users_on_username_trigram", using: :gin, opclasses: {"username"=>"gin_trgm_ops"}
...@@ -994,11 +1003,11 @@ ActiveRecord::Schema.define(version: 20160412175417) do ...@@ -994,11 +1003,11 @@ ActiveRecord::Schema.define(version: 20160412175417) do
t.integer "project_id" t.integer "project_id"
t.datetime "created_at" t.datetime "created_at"
t.datetime "updated_at" t.datetime "updated_at"
t.string "type", limit: 510, default: "ProjectHook" t.string "type", default: "ProjectHook"
t.integer "service_id" t.integer "service_id"
t.boolean "push_events", null: false t.boolean "push_events", default: true, null: false
t.boolean "issues_events", null: false t.boolean "issues_events", default: false, null: false
t.boolean "merge_requests_events", null: false t.boolean "merge_requests_events", default: false, null: false
t.boolean "tag_push_events", default: false t.boolean "tag_push_events", default: false
t.boolean "note_events", default: false, null: false t.boolean "note_events", default: false, null: false
t.boolean "enable_ssl_verification", default: true t.boolean "enable_ssl_verification", default: true
......
...@@ -3,7 +3,7 @@ ...@@ -3,7 +3,7 @@
## User documentation ## User documentation
- [API](api/README.md) Automate GitLab via a simple and powerful API. - [API](api/README.md) Automate GitLab via a simple and powerful API.
- [CI](ci/README.md) GitLab Continuous Integration (CI) getting started, .gitlab-ci.yml options, and examples. - [CI](ci/README.md) GitLab Continuous Integration (CI) getting started, `.gitlab-ci.yml` options, and examples.
- [GitLab as OAuth2 authentication service provider](integration/oauth_provider.md). It allows you to login to other applications from GitLab. - [GitLab as OAuth2 authentication service provider](integration/oauth_provider.md). It allows you to login to other applications from GitLab.
- [GitLab Basics](gitlab-basics/README.md) Find step by step how to start working on your commandline and on GitLab. - [GitLab Basics](gitlab-basics/README.md) Find step by step how to start working on your commandline and on GitLab.
- [Importing to GitLab](workflow/importing/README.md). - [Importing to GitLab](workflow/importing/README.md).
......
...@@ -126,6 +126,87 @@ Parameters: ...@@ -126,6 +126,87 @@ Parameters:
- `id` (required) - The ID or path of a group - `id` (required) - The ID or path of a group
- `project_id` (required) - The ID of a project - `project_id` (required) - The ID of a project
## Update group
Updates the project group. Only available to group owners and administrators.
```
PUT /groups/:id
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of the group |
| `name` | string | no | The name of the group |
| `path` | string | no | The path of the group |
| `description` | string | no | The description of the group |
| `visibility_level` | integer | no | The visibility level of the group. 0 for private, 10 for internal, 20 for public. |
```bash
curl -X PUT -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" "https://gitlab.example.com/api/v3/groups/5?name=Experimental"
```
Example response:
```json
{
"id": 5,
"name": "Experimental",
"path": "h5bp",
"description": "foo",
"visibility_level": 10,
"avatar_url": null,
"web_url": "http://gitlab.example.com/groups/h5bp",
"projects": [
{
"id": 9,
"description": "foo",
"default_branch": "master",
"tag_list": [],
"public": false,
"archived": false,
"visibility_level": 10,
"ssh_url_to_repo": "git@gitlab.example.com/html5-boilerplate.git",
"http_url_to_repo": "http://gitlab.example.com/h5bp/html5-boilerplate.git",
"web_url": "http://gitlab.example.com/h5bp/html5-boilerplate",
"name": "Html5 Boilerplate",
"name_with_namespace": "Experimental / Html5 Boilerplate",
"path": "html5-boilerplate",
"path_with_namespace": "h5bp/html5-boilerplate",
"issues_enabled": true,
"merge_requests_enabled": true,
"wiki_enabled": true,
"builds_enabled": true,
"snippets_enabled": true,
"created_at": "2016-04-05T21:40:50.169Z",
"last_activity_at": "2016-04-06T16:52:08.432Z",
"shared_runners_enabled": true,
"creator_id": 1,
"namespace": {
"id": 5,
"name": "Experimental",
"path": "h5bp",
"owner_id": null,
"created_at": "2016-04-05T21:40:49.152Z",
"updated_at": "2016-04-07T08:07:48.466Z",
"description": "foo",
"avatar": {
"url": null
},
"share_with_group_lock": false,
"visibility_level": 10
},
"avatar_url": null,
"star_count": 1,
"forks_count": 0,
"open_issues_count": 3,
"public_builds": true
}
]
}
```
## Remove group ## Remove group
Removes group with all projects inside. Removes group with all projects inside.
......
...@@ -351,6 +351,61 @@ DELETE /projects/:id/issues/:issue_id ...@@ -351,6 +351,61 @@ DELETE /projects/:id/issues/:issue_id
curl -X DELETE -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/4/issues/85 curl -X DELETE -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/4/issues/85
``` ```
## Move an issue
Moves an issue to a different project. If the operation is successful, a status
code `201` together with moved issue is returned. If the project, issue, or
target project is not found, error `404` is returned. If the target project
equals the source project or the user has insufficient permissions to move an
issue, error `400` together with an explaining error message is returned.
```
POST /projects/:id/issues/:issue_id/move
```
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project |
| `issue_id` | integer | yes | The ID of a project's issue |
| `to_project_id` | integer | yes | The ID of the new project |
```bash
curl -X POST -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/4/issues/85/move
```
Example response:
```json
{
"id": 92,
"iid": 11,
"project_id": 5,
"title": "Sit voluptas tempora quisquam aut doloribus et.",
"description": "Repellat voluptas quibusdam voluptatem exercitationem.",
"state": "opened",
"created_at": "2016-04-05T21:41:45.652Z",
"updated_at": "2016-04-07T12:20:17.596Z",
"labels": [],
"milestone": null,
"assignee": {
"name": "Miss Monserrate Beier",
"username": "axel.block",
"id": 12,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/46f6f7dc858ada7be1853f7fb96e81da?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/axel.block"
},
"author": {
"name": "Kris Steuber",
"username": "solon.cremin",
"id": 10,
"state": "active",
"avatar_url": "http://www.gravatar.com/avatar/7a190fecbaa68212a4b68aeb6e3acd10?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/solon.cremin"
}
}
```
## Comments on issues ## Comments on issues
Comments are done via the [notes](notes.md) resource. Comments are done via the [notes](notes.md) resource.
...@@ -23,42 +23,42 @@ Example response: ...@@ -23,42 +23,42 @@ Example response:
{ {
"name" : "bug", "name" : "bug",
"color" : "#d9534f", "color" : "#d9534f",
"description": "Bug reported by user" "description": "Bug reported by user",
"open_issues_count": 1,
"closed_issues_count": 0,
"open_merge_requests_count": 1
}, },
{ {
"color" : "#d9534f", "color" : "#d9534f",
"name" : "confirmed", "name" : "confirmed",
"description": "Confirmed issue" "description": "Confirmed issue",
"open_issues_count": 2,
"closed_issues_count": 5,
"open_merge_requests_count": 0
}, },
{ {
"name" : "critical", "name" : "critical",
"color" : "#d9534f", "color" : "#d9534f",
"description": "Criticalissue. Need fix ASAP" "description": "Criticalissue. Need fix ASAP",
}, "open_issues_count": 1,
{ "closed_issues_count": 3,
"color" : "#428bca", "open_merge_requests_count": 1
"name" : "discussion",
"description": "Issue that needs further discussion"
}, },
{ {
"name" : "documentation", "name" : "documentation",
"color" : "#f0ad4e", "color" : "#f0ad4e",
"description": "Issue about documentation" "description": "Issue about documentation",
"open_issues_count": 1,
"closed_issues_count": 0,
"open_merge_requests_count": 2
}, },
{ {
"color" : "#5cb85c", "color" : "#5cb85c",
"name" : "enhancement", "name" : "enhancement",
"description": "Enhancement proposal" "description": "Enhancement proposal",
}, "open_issues_count": 1,
{ "closed_issues_count": 0,
"color" : "#428bca", "open_merge_requests_count": 1
"name" : "suggestion",
"description": "Suggestion"
},
{
"color" : "#f0ad4e",
"name" : "support",
"description": "Support issue"
} }
] ]
``` ```
......
...@@ -32,6 +32,7 @@ Parameters: ...@@ -32,6 +32,7 @@ Parameters:
"created_at": "2013-09-30T13:46:01Z" "created_at": "2013-09-30T13:46:01Z"
}, },
"created_at": "2013-10-02T09:22:45Z", "created_at": "2013-10-02T09:22:45Z",
"updated_at": "2013-10-02T10:22:45Z",
"system": true, "system": true,
"upvote": false, "upvote": false,
"downvote": false, "downvote": false,
...@@ -51,6 +52,7 @@ Parameters: ...@@ -51,6 +52,7 @@ Parameters:
"created_at": "2013-09-30T13:46:01Z" "created_at": "2013-09-30T13:46:01Z"
}, },
"created_at": "2013-10-02T09:56:03Z", "created_at": "2013-10-02T09:56:03Z",
"updated_at": "2013-10-02T09:56:03Z",
"system": true, "system": true,
"upvote": false, "upvote": false,
"downvote": false, "downvote": false,
...@@ -103,6 +105,53 @@ Parameters: ...@@ -103,6 +105,53 @@ Parameters:
- `note_id` (required) - The ID of a note - `note_id` (required) - The ID of a note
- `body` (required) - The content of a note - `body` (required) - The content of a note
### Delete an issue note
Deletes an existing note of an issue. On success, this API method returns 200
and the deleted note. If the note does not exist, the API returns 404.
```
DELETE /projects/:id/issues/:issue_id/notes/:note_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project |
| `issue_id` | integer | yes | The ID of an issue |
| `note_id` | integer | yes | The ID of a note |
```bash
curl -X DELETE -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/5/issues/11/notes/636
```
Example Response:
```json
{
"id": 636,
"body": "This is a good idea.",
"attachment": null,
"author": {
"id": 1,
"username": "pipin",
"email": "admin@example.com",
"name": "Pip",
"state": "active",
"created_at": "2013-09-30T13:46:01Z",
"avatar_url": "http://www.gravatar.com/avatar/5224fd70153710e92fb8bcf79ac29d67?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/pipin"
},
"created_at": "2016-04-05T22:10:44.164Z",
"system": false,
"noteable_id": 11,
"noteable_type": "Issue",
"upvote": false,
"downvote": false
}
```
## Snippets ## Snippets
### List all snippet notes ### List all snippet notes
...@@ -180,6 +229,53 @@ Parameters: ...@@ -180,6 +229,53 @@ Parameters:
- `note_id` (required) - The ID of a note - `note_id` (required) - The ID of a note
- `body` (required) - The content of a note - `body` (required) - The content of a note
### Delete a snippet note
Deletes an existing note of a snippet. On success, this API method returns 200
and the deleted note. If the note does not exist, the API returns 404.
```
DELETE /projects/:id/snippets/:snippet_id/notes/:note_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project |
| `snippet_id` | integer | yes | The ID of a snippet |
| `note_id` | integer | yes | The ID of a note |
```bash
curl -X DELETE -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/5/snippets/52/notes/1659
```
Example Response:
```json
{
"id": 1659,
"body": "This is a good idea.",
"attachment": null,
"author": {
"id": 1,
"username": "pipin",
"email": "admin@example.com",
"name": "Pip",
"state": "active",
"created_at": "2013-09-30T13:46:01Z",
"avatar_url": "http://www.gravatar.com/avatar/5224fd70153710e92fb8bcf79ac29d67?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/pipin"
},
"created_at": "2016-04-06T16:51:53.239Z",
"system": false,
"noteable_id": 52,
"noteable_type": "Snippet",
"upvote": false,
"downvote": false
}
```
## Merge Requests ## Merge Requests
### List all merge request notes ### List all merge request notes
...@@ -223,6 +319,7 @@ Parameters: ...@@ -223,6 +319,7 @@ Parameters:
"created_at": "2013-09-30T13:46:01Z" "created_at": "2013-09-30T13:46:01Z"
}, },
"created_at": "2013-10-02T08:57:14Z", "created_at": "2013-10-02T08:57:14Z",
"updated_at": "2013-10-02T08:57:14Z",
"system": false, "system": false,
"upvote": false, "upvote": false,
"downvote": false, "downvote": false,
...@@ -259,3 +356,50 @@ Parameters: ...@@ -259,3 +356,50 @@ Parameters:
- `merge_request_id` (required) - The ID of a merge request - `merge_request_id` (required) - The ID of a merge request
- `note_id` (required) - The ID of a note - `note_id` (required) - The ID of a note
- `body` (required) - The content of a note - `body` (required) - The content of a note
### Delete a merge request note
Deletes an existing note of a merge request. On success, this API method returns
200 and the deleted note. If the note does not exist, the API returns 404.
```
DELETE /projects/:id/merge_requests/:merge_request_id/notes/:note_id
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project |
| `merge_request_id` | integer | yes | The ID of a merge request |
| `note_id` | integer | yes | The ID of a note |
```bash
curl -X DELETE -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/5/merge_requests/7/notes/1602
```
Example Response:
```json
{
"id": 1602,
"body": "This is a good idea.",
"attachment": null,
"author": {
"id": 1,
"username": "pipin",
"email": "admin@example.com",
"name": "Pip",
"state": "active",
"created_at": "2013-09-30T13:46:01Z",
"avatar_url": "http://www.gravatar.com/avatar/5224fd70153710e92fb8bcf79ac29d67?s=80&d=identicon",
"web_url": "https://gitlab.example.com/u/pipin"
},
"created_at": "2016-04-05T22:11:59.923Z",
"system": false,
"noteable_id": 7,
"noteable_type": "MergeRequest",
"upvote": false,
"downvote": false
}
```
...@@ -780,8 +780,10 @@ Parameters: ...@@ -780,8 +780,10 @@ Parameters:
- `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project - `id` (required) - The ID or NAMESPACE/PROJECT_NAME of a project
- `user_id` (required) - The ID of a team member - `user_id` (required) - The ID of a team member
This method is idempotent and can be called multiple times with the same parameters. This method removes the project member if the user has the proper access rights to do so.
Revoking team membership for a user who is not currently a team member is considered success. It returns a status code 403 if the member does not have the proper rights to perform this action.
In all other cases this method is idempotent and revoking team membership for a user who is not
currently a team member is considered success.
Please note that the returned JSON currently differs slightly. Thus you should not Please note that the returned JSON currently differs slightly. Thus you should not
rely on the returned JSON structure. rely on the returned JSON structure.
......
...@@ -38,6 +38,50 @@ Parameters: ...@@ -38,6 +38,50 @@ Parameters:
] ]
``` ```
## Get a single repository tag
Get a specific repository tag determined by its name. It returns `200` together
with the tag information if the tag exists. It returns `404` if the tag does not
exist.
```
GET /projects/:id/repository/tags/:tag_name
```
Parameters:
| Attribute | Type | Required | Description |
| --------- | ---- | -------- | ----------- |
| `id` | integer | yes | The ID of a project |
| `tag_name` | string | yes | The name of the tag |
```bash
curl -H "PRIVATE-TOKEN: 9koXpg98eAheJpvBs5tK" https://gitlab.example.com/api/v3/projects/5/repository/tags/v1.0.0
```
Example Response:
```json
{
"name": "v5.0.0",
"message": null,
"commit": {
"id": "60a8ff033665e1207714d6670fcd7b65304ec02f",
"message": "v5.0.0\n",
"parent_ids": [
"f61c062ff8bcbdb00e0a1b3317a91aed6ceee06b"
],
"authored_date": "2015-02-01T21:56:31.000+01:00",
"author_name": "Arthur Verschaeve",
"author_email": "contact@arthurverschaeve.be",
"committed_date": "2015-02-01T21:56:31.000+01:00",
"committer_name": "Arthur Verschaeve",
"committer_email": "contact@arthurverschaeve.be"
},
"release": null
}
```
## Create a new tag ## Create a new tag
Creates a new tag in the repository that points to the supplied ref. Creates a new tag in the repository that points to the supplied ref.
...@@ -148,4 +192,4 @@ Parameters: ...@@ -148,4 +192,4 @@ Parameters:
"tag_name": "1.0.0", "tag_name": "1.0.0",
"description": "Amazing release. Wow" "description": "Amazing release. Wow"
} }
``` ```
\ No newline at end of file
...@@ -30,7 +30,7 @@ This is the universal solution which works with any type of executor ...@@ -30,7 +30,7 @@ This is the universal solution which works with any type of executor
## SSH keys when using the Docker executor ## SSH keys when using the Docker executor
You will first need to create an SSH key pair. For more information, follow the You will first need to create an SSH key pair. For more information, follow the
instructions to [generate an SSH key](../ssh/README.md). instructions to [generate an SSH key](../../ssh/README.md).
Then, create a new **Secret Variable** in your project settings on GitLab Then, create a new **Secret Variable** in your project settings on GitLab
following **Settings > Variables**. As **Key** add the name `SSH_PRIVATE_KEY` following **Settings > Variables**. As **Key** add the name `SSH_PRIVATE_KEY`
...@@ -63,7 +63,7 @@ before_script: ...@@ -63,7 +63,7 @@ before_script:
As a final step, add the _public_ key from the one you created earlier to the As a final step, add the _public_ key from the one you created earlier to the
services that you want to have an access to from within the build environment. services that you want to have an access to from within the build environment.
If you are accessing a private GitLab repository you need to add it as a If you are accessing a private GitLab repository you need to add it as a
[deploy key](../ssh/README.md#deploy-keys). [deploy key](../../ssh/README.md#deploy-keys).
That's it! You can now have access to private servers or repositories in your That's it! You can now have access to private servers or repositories in your
build environment. build environment.
...@@ -79,12 +79,12 @@ on, and use that key for all projects that are run on this machine. ...@@ -79,12 +79,12 @@ on, and use that key for all projects that are run on this machine.
First, you need to login to the server that runs your builds. First, you need to login to the server that runs your builds.
Then from the terminal login as the `gitlab-runner` user and generate the SSH Then from the terminal login as the `gitlab-runner` user and generate the SSH
key pair as described in the [SSH keys documentation](../ssh/README.md). key pair as described in the [SSH keys documentation](../../ssh/README.md).
As a final step, add the _public_ key from the one you created earlier to the As a final step, add the _public_ key from the one you created earlier to the
services that you want to have an access to from within the build environment. services that you want to have an access to from within the build environment.
If you are accessing a private GitLab repository you need to add it as a If you are accessing a private GitLab repository you need to add it as a
[deploy key](../ssh/README.md#deploy-keys). [deploy key](../../ssh/README.md#deploy-keys).
Once done, try to login to the remote server in order to accept the fingerprint: Once done, try to login to the remote server in order to accept the fingerprint:
......
...@@ -530,6 +530,16 @@ See the [omniauth integration document](../integration/omniauth.md) ...@@ -530,6 +530,16 @@ See the [omniauth integration document](../integration/omniauth.md)
GitLab can build your projects. To enable that feature you need GitLab Runners to do that for you. GitLab can build your projects. To enable that feature you need GitLab Runners to do that for you.
Checkout the [GitLab Runner section](https://about.gitlab.com/gitlab-ci/#gitlab-runner) to install it Checkout the [GitLab Runner section](https://about.gitlab.com/gitlab-ci/#gitlab-runner) to install it
### Adding your Trusted Proxies
If you are using a reverse proxy on an separate machine, you may want to add the
proxy to the trusted proxies list. Otherwise users will appear signed in from the
proxy's IP address.
You can add trusted proxies in `config/gitlab.yml` by customizing the `trusted_proxies`
option in section 1. Save the file and [reconfigure GitLab](../administration/restart_gitlab.md)
for the changes to take effect.
### Custom Redis Connection ### Custom Redis Connection
If you'd like Resque to connect to a Redis server on a non-standard port or on a different host, you can configure its connection string via the `config/resque.yml` file. If you'd like Resque to connect to a Redis server on a non-standard port or on a different host, you can configure its connection string via the `config/resque.yml` file.
......
...@@ -120,6 +120,29 @@ OmniAuth provider for an existing user. ...@@ -120,6 +120,29 @@ OmniAuth provider for an existing user.
The chosen OmniAuth provider is now active and can be used to sign in to GitLab from then on. The chosen OmniAuth provider is now active and can be used to sign in to GitLab from then on.
## Configure OmniAuth Providers as External
>**Note:**
This setting was introduced with version 8.7 of GitLab
You can define which OmniAuth providers you want to be `external` so that all users
creating accounts via these providers will not be able to have access to internal
projects. You will need to use the full name of the provider, like `google_oauth2`
for Google. Refer to the examples for the full names of the supported providers.
**For Omnibus installations**
```ruby
gitlab_rails['omniauth_external_providers'] = ['twitter', 'google_oauth2']
```
**For installations from source**
```yaml
omniauth:
external_providers: ['twitter', 'google_oauth2']
```
## Using Custom Omniauth Providers ## Using Custom Omniauth Providers
>**Note:** >**Note:**
......
# GitLab JIRA integration # GitLab JIRA integration
_**Note:** >**Note:**
Full JIRA integration was previously exclusive to GitLab Enterprise Edition. Full JIRA integration was previously exclusive to GitLab Enterprise Edition.
With [GitLab 8.3 forward][8_3_post], this feature in now [backported][jira-ce] With [GitLab 8.3 forward][8_3_post], this feature in now [backported][jira-ce]
to GitLab Community Edition as well._ to GitLab Community Edition as well.
--- ---
...@@ -88,8 +88,9 @@ password as they will be needed when configuring GitLab in the next section. ...@@ -88,8 +88,9 @@ password as they will be needed when configuring GitLab in the next section.
### Configuring GitLab ### Configuring GitLab
_**Note:** The currently supported JIRA versions are v6.x and v7.x. and GitLab >**Note:**
7.8 or higher is required._ The currently supported JIRA versions are v6.x and v7.x. and GitLab
7.8 or higher is required.
--- ---
...@@ -113,13 +114,24 @@ Fill in the required details on the page, as described in the table below. ...@@ -113,13 +114,24 @@ Fill in the required details on the page, as described in the table below.
| `Api url` | The base URL of the JIRA API. It may be omitted, in which case GitLab will automatically use API version `2` based on the `project url`. It is of the form: `https://<jira_host_url>/rest/api/2`. | | `Api url` | The base URL of the JIRA API. It may be omitted, in which case GitLab will automatically use API version `2` based on the `project url`. It is of the form: `https://<jira_host_url>/rest/api/2`. |
| `Username` | The username of the user created in [configuring JIRA step](#configuring-jira). | | `Username` | The username of the user created in [configuring JIRA step](#configuring-jira). |
| `Password` |The password of the user created in [configuring JIRA step](#configuring-jira). | | `Password` |The password of the user created in [configuring JIRA step](#configuring-jira). |
| `JIRA issue transition` | This setting is very important to set up correctly. It is the ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (**Administration > Issues > Workflows**) by selecting **View** under **Operations** of the desired workflow of your project. The ID of each state can be found inside the parenthesis of each transition name under the **Transitions (id)** column ([see screenshot](img/jira_issues_workflow.png)). By default, this ID is set to `2` | | `JIRA issue transition` | This setting is very important to set up correctly. It is the ID of a transition that moves issues to a closed state. You can find this number under the JIRA workflow administration (**Administration > Issues > Workflows**) by selecting **View** under **Operations** of the desired workflow of your project. The ID of each state can be found inside the parenthesis of each transition name under the **Transitions (id)** column ([see screenshot][trans]). By default, this ID is set to `2`. |
After saving the configuration, your GitLab project will be able to interact After saving the configuration, your GitLab project will be able to interact
with the linked JIRA project. with the linked JIRA project.
For example, given the settings below:
- the JIRA URL is `https://jira.example.com`
- the project is named `GITLAB`
- the user is named `gitlab`
- the JIRA issue transition is 151 (based on the [JIRA issue transition][trans])
the following screenshot shows how the JIRA service settings should look like.
![JIRA service page](img/jira_service_page.png) ![JIRA service page](img/jira_service_page.png)
[trans]: img/jira_issues_workflow.png
--- ---
## JIRA issues ## JIRA issues
......
...@@ -66,6 +66,35 @@ the target branch. Click **Create directory** to finish. ...@@ -66,6 +66,35 @@ the target branch. Click **Create directory** to finish.
## Create a new branch ## Create a new branch
There are multiple ways to create a branch from GitLab's web interface.
### Create a new branch from an issue
>**Note:**
This feature was [introduced][ce-2808] in GitLab 8.6.
In case your development workflow dictates to have an issue for every merge
request, you can quickly create a branch right on the issue page which will be
tied with the issue itself. You can see a **New Branch** button after the issue
description, unless there is already a branch with the same name or a referenced
merge request.
![New Branch Button](img/new_branch_from_issue.png)
Once you click it, a new branch will be created that diverges from the default
branch of your project, by default `master`. The branch name will be based on
the title of the issue and as suffix it will have its ID. Thus, the example
screenshot above will yield a branch named
`et-cum-et-sed-expedita-repellat-consequatur-ut-assumenda-numquam-rerum-2`.
After the branch is created, you can edit files in the repository to fix
the issue. When a merge request is created based on the newly created branch,
the description field will automatically display the [issue closing pattern]
`Closes #ID`, where `ID` the ID of the issue. This will close the issue once the
merge request is merged.
### Create a new branch from a project's dashboard
If you want to make changes to several files before creating a new merge If you want to make changes to several files before creating a new merge
request, you can create a new branch up front. From a project's files page, request, you can create a new branch up front. From a project's files page,
choose **New branch** from the dropdown. choose **New branch** from the dropdown.
...@@ -118,3 +147,6 @@ appear that is labeled **Start a new merge request with these changes**. After ...@@ -118,3 +147,6 @@ appear that is labeled **Start a new merge request with these changes**. After
you commit the changes you will be taken to a new merge request form. you commit the changes you will be taken to a new merge request form.
![Start a new merge request with these changes](img/web_editor_start_new_merge_request.png) ![Start a new merge request with these changes](img/web_editor_start_new_merge_request.png)
[ce-2808]: https://gitlab.com/gitlab-org/gitlab-ce/merge_requests/2808
[issue closing pattern]: ../customization/issue_closing.md
...@@ -7,3 +7,9 @@ Feature: Profile Notifications ...@@ -7,3 +7,9 @@ Feature: Profile Notifications
Scenario: I visit notifications tab Scenario: I visit notifications tab
When I visit profile notifications page When I visit profile notifications page
Then I should see global notifications settings Then I should see global notifications settings
@javascript
Scenario: I edit Project Notifications
Given I visit profile notifications page
When I select Mention setting from dropdown
Then I should see Notification saved message
...@@ -9,4 +9,14 @@ class Spinach::Features::ProfileNotifications < Spinach::FeatureSteps ...@@ -9,4 +9,14 @@ class Spinach::Features::ProfileNotifications < Spinach::FeatureSteps
step 'I should see global notifications settings' do step 'I should see global notifications settings' do
expect(page).to have_content "Notifications" expect(page).to have_content "Notifications"
end end
step 'I select Mention setting from dropdown' do
select 'mention', from: 'notification_setting_level'
end
step 'I should see Notification saved message' do
page.within '.flash-container' do
expect(page).to have_content 'Notification settings saved'
end
end
end end
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -212,7 +212,7 @@ module API ...@@ -212,7 +212,7 @@ module API
expose :note, as: :body expose :note, as: :body
expose :attachment_identifier, as: :attachment expose :attachment_identifier, as: :attachment
expose :author, using: Entities::UserBasic expose :author, using: Entities::UserBasic
expose :created_at expose :created_at, :updated_at
expose :system?, as: :system expose :system?, as: :system
expose :noteable_id, :noteable_type expose :noteable_id, :noteable_type
# upvote? and downvote? are deprecated, always return false # upvote? and downvote? are deprecated, always return false
...@@ -263,14 +263,19 @@ module API ...@@ -263,14 +263,19 @@ module API
expose :id, :path, :kind expose :id, :path, :kind
end end
class ProjectAccess < Grape::Entity class Member < Grape::Entity
expose :access_level expose :access_level
expose :notification_level expose :notification_level do |member, options|
if member.notification_setting
NotificationSetting.levels[member.notification_setting.level]
end
end
end end
class GroupAccess < Grape::Entity class ProjectAccess < Member
expose :access_level end
expose :notification_level
class GroupAccess < Member
end end
class ProjectService < Grape::Entity class ProjectService < Grape::Entity
...@@ -301,6 +306,7 @@ module API ...@@ -301,6 +306,7 @@ module API
class Label < Grape::Entity class Label < Grape::Entity
expose :name, :color, :description expose :name, :color, :description
expose :open_issues_count, :closed_issues_count, :open_merge_requests_count
end end
class Compare < Grape::Entity class Compare < Grape::Entity
......
...@@ -23,8 +23,10 @@ module API ...@@ -23,8 +23,10 @@ module API
# Create group. Available only for users who can create groups. # Create group. Available only for users who can create groups.
# #
# Parameters: # Parameters:
# name (required) - The name of the group # name (required) - The name of the group
# path (required) - The path of the group # path (required) - The path of the group
# description (optional) - The description of the group
# visibility_level (optional) - The visibility level of the group
# Example Request: # Example Request:
# POST /groups # POST /groups
post do post do
...@@ -42,6 +44,28 @@ module API ...@@ -42,6 +44,28 @@ module API
end end
end end
# Update group. Available only for users who can administrate groups.
#
# Parameters:
# id (required) - The ID of a group
# path (optional) - The path of the group
# description (optional) - The description of the group
# visibility_level (optional) - The visibility level of the group
# Example Request:
# PUT /groups/:id
put ':id' do
group = find_group(params[:id])
authorize! :admin_group, group
attrs = attributes_for_keys [:name, :path, :description, :visibility_level]
if ::Groups::UpdateService.new(group, current_user, attrs).execute
present group, with: Entities::GroupDetail
else
render_validation_error!(group)
end
end
# Get a single group, with containing projects # Get a single group, with containing projects
# #
# Parameters: # Parameters:
......
...@@ -91,8 +91,7 @@ module API ...@@ -91,8 +91,7 @@ module API
if can?(current_user, :read_group, group) if can?(current_user, :read_group, group)
group group
else else
forbidden!("#{current_user.username} lacks sufficient "\ not_found!('Group')
"access to #{group.name}")
end end
end end
......
...@@ -195,6 +195,29 @@ module API ...@@ -195,6 +195,29 @@ module API
end end
end end
# Move an existing issue
#
# Parameters:
# id (required) - The ID of a project
# issue_id (required) - The ID of a project issue
# to_project_id (required) - The ID of the new project
# Example Request:
# POST /projects/:id/issues/:issue_id/move
post ':id/issues/:issue_id/move' do
required_attributes! [:to_project_id]
issue = user_project.issues.find(params[:issue_id])
new_project = Project.find(params[:to_project_id])
begin
issue = ::Issues::MoveService.new(user_project, current_user).execute(issue, new_project)
present issue, with: Entities::Issue, current_user: current_user
rescue ::Issues::MoveService::MoveError => error
render_api_error!(error.message, 400)
end
end
#
# Delete a project issue # Delete a project issue
# #
# Parameters: # Parameters:
......
...@@ -21,6 +21,7 @@ module API ...@@ -21,6 +21,7 @@ module API
# state (optional) - Return "active" or "closed" milestones # state (optional) - Return "active" or "closed" milestones
# Example Request: # Example Request:
# GET /projects/:id/milestones # GET /projects/:id/milestones
# GET /projects/:id/milestones?iid=42
# GET /projects/:id/milestones?state=active # GET /projects/:id/milestones?state=active
# GET /projects/:id/milestones?state=closed # GET /projects/:id/milestones?state=closed
get ":id/milestones" do get ":id/milestones" do
...@@ -28,6 +29,7 @@ module API ...@@ -28,6 +29,7 @@ module API
milestones = user_project.milestones milestones = user_project.milestones
milestones = filter_milestones_state(milestones, params[:state]) milestones = filter_milestones_state(milestones, params[:state])
milestones = filter_by_iid(milestones, params[:iid]) if params[:iid].present?
present paginate(milestones), with: Entities::Milestone present paginate(milestones), with: Entities::Milestone
end end
......
...@@ -112,6 +112,23 @@ module API ...@@ -112,6 +112,23 @@ module API
end end
end end
# Delete a +noteable+ note
#
# Parameters:
# id (required) - The ID of a project
# noteable_id (required) - The ID of an issue, MR, or snippet
# node_id (required) - The ID of a note
# Example Request:
# DELETE /projects/:id/issues/:noteable_id/notes/:note_id
# DELETE /projects/:id/snippets/:noteable_id/notes/:node_id
delete ":id/#{noteables_str}/:#{noteable_id_str}/notes/:note_id" do
note = user_project.notes.find(params[:note_id])
authorize! :admin_note, note
::Notes::DeleteService.new(user_project, current_user).execute(note)
present note, with: Entities::Note
end
end end
end end
end end
......
...@@ -93,12 +93,17 @@ module API ...@@ -93,12 +93,17 @@ module API
# Example Request: # Example Request:
# DELETE /projects/:id/members/:user_id # DELETE /projects/:id/members/:user_id
delete ":id/members/:user_id" do delete ":id/members/:user_id" do
authorize! :admin_project, user_project
project_member = user_project.project_members.find_by(user_id: params[:user_id]) project_member = user_project.project_members.find_by(user_id: params[:user_id])
unless project_member.nil?
project_member.destroy unless current_user.can?(:admin_project, user_project) ||
else current_user.can?(:destroy_project_member, project_member)
forbidden!
end
if project_member.nil?
{ message: "Access revoked", id: params[:user_id].to_i } { message: "Access revoked", id: params[:user_id].to_i }
else
project_member.destroy
end end
end end
end end
......
...@@ -98,7 +98,6 @@ module API ...@@ -98,7 +98,6 @@ module API
authorize! :download_code, user_project authorize! :download_code, user_project
begin begin
RepositoryArchiveCacheWorker.perform_async
header *Gitlab::Workhorse.send_git_archive(user_project, params[:sha], params[:format]) header *Gitlab::Workhorse.send_git_archive(user_project, params[:sha], params[:format])
rescue rescue
not_found!('File') not_found!('File')
......
...@@ -16,6 +16,20 @@ module API ...@@ -16,6 +16,20 @@ module API
with: Entities::RepoTag, project: user_project with: Entities::RepoTag, project: user_project
end end
# Get a single repository tag
#
# Parameters:
# id (required) - The ID of a project
# tag_name (required) - The name of the tag
# Example Request:
# GET /projects/:id/repository/tags/:tag_name
get ":id/repository/tags/:tag_name", requirements: { tag_name: /.+/ } do
tag = user_project.repository.find_tag(params[:tag_name])
not_found!('Tag') unless tag
present tag, with: Entities::RepoTag, project: user_project
end
# Create tag # Create tag
# #
# Parameters: # Parameters:
......
require 'gitlab/git' require 'gitlab/git'
module Gitlab module Gitlab
def self.com?
Gitlab.config.gitlab.url == 'https://gitlab.com'
end
end end
...@@ -104,6 +104,16 @@ module Gitlab ...@@ -104,6 +104,16 @@ module Gitlab
retval retval
end end
# Adds a tag to the current transaction (if any)
#
# name - The name of the tag to add.
# value - The value of the tag.
def self.tag_transaction(name, value)
trans = current_transaction
trans.add_tag(name, value) if trans
end
# When enabled this should be set before being used as the usual pattern # When enabled this should be set before being used as the usual pattern
# "@foo ||= bar" is _not_ thread-safe. # "@foo ||= bar" is _not_ thread-safe.
if enabled? if enabled?
......
...@@ -54,6 +54,12 @@ module Gitlab ...@@ -54,6 +54,12 @@ module Gitlab
@user ||= build_new_user @user ||= build_new_user
end end
if external_provider? && @user
@user.external = true
elsif @user
@user.external = false
end
@user @user
end end
...@@ -113,6 +119,10 @@ module Gitlab ...@@ -113,6 +119,10 @@ module Gitlab
end end
end end
def external_provider?
Gitlab.config.omniauth.external_providers.include?(auth_hash.provider)
end
def block_after_signup? def block_after_signup?
if creating_linked_ldap_user? if creating_linked_ldap_user?
ldap_config.block_auto_created_users ldap_config.block_auto_created_users
......
...@@ -26,7 +26,7 @@ module Gitlab ...@@ -26,7 +26,7 @@ module Gitlab
@user ||= build_new_user @user ||= build_new_user
end end
if external_users_enabled? if external_users_enabled? && @user
# Check if there is overlap between the user's groups and the external groups # Check if there is overlap between the user's groups and the external groups
# setting then set user as external or internal. # setting then set user as external or internal.
if (auth_hash.groups & Gitlab::Saml::Config.external_groups).empty? if (auth_hash.groups & Gitlab::Saml::Config.external_groups).empty?
...@@ -48,6 +48,7 @@ module Gitlab ...@@ -48,6 +48,7 @@ module Gitlab
end end
def changed? def changed?
return true unless gl_user
gl_user.changed? || gl_user.identities.any?(&:changed?) gl_user.changed? || gl_user.identities.any?(&:changed?)
end end
......
...@@ -5,12 +5,23 @@ namespace :gemojione do ...@@ -5,12 +5,23 @@ namespace :gemojione do
require 'json' require 'json'
dir = Gemojione.index.images_path dir = Gemojione.index.images_path
digests = []
aliases = Hash.new { |hash, key| hash[key] = [] }
aliases_path = File.join(Rails.root, 'fixtures', 'emojis', 'aliases.json')
digests = AwardEmoji.emojis.map do |name, emoji_hash| JSON.parse(File.read(aliases_path)).each do |alias_name, real_name|
aliases[real_name] << alias_name
end
AwardEmoji.emojis.map do |name, emoji_hash|
fpath = File.join(dir, "#{emoji_hash['unicode']}.png") fpath = File.join(dir, "#{emoji_hash['unicode']}.png")
digest = Digest::SHA256.file(fpath).hexdigest digest = Digest::SHA256.file(fpath).hexdigest
{ name: name, unicode: emoji_hash['unicode'], digest: digest } digests << { name: name, unicode: emoji_hash['unicode'], digest: digest }
aliases[name].each do |alias_name|
digests << { name: alias_name, unicode: emoji_hash['unicode'], digest: digest }
end
end end
out = File.join(Rails.root, 'fixtures', 'emojis', 'digests.json') out = File.join(Rails.root, 'fixtures', 'emojis', 'digests.json')
......
require 'spec_helper'
describe Groups::NotificationSettingsController do
let(:group) { create(:group) }
let(:user) { create(:user) }
describe '#update' do
context 'when not authorized' do
it 'redirects to sign in page' do
put :update,
group_id: group.to_param,
notification_setting: { level: :participating }
expect(response).to redirect_to(new_user_session_path)
end
end
context 'when authorized' do
before do
sign_in(user)
end
it 'returns success' do
put :update,
group_id: group.to_param,
notification_setting: { level: :participating }
expect(response.status).to eq 200
end
end
end
end
...@@ -157,6 +157,34 @@ describe Projects::MergeRequestsController do ...@@ -157,6 +157,34 @@ describe Projects::MergeRequestsController do
end end
end end
describe 'PUT #update' do
context 'there is no source project' do
let(:project) { create(:project) }
let(:fork_project) { create(:forked_project_with_submodules) }
let(:merge_request) { create(:merge_request, source_project: fork_project, source_branch: 'add-submodule-version-bump', target_branch: 'master', target_project: project) }
before do
fork_project.build_forked_project_link(forked_to_project_id: fork_project.id, forked_from_project_id: project.id)
fork_project.save
merge_request.reload
fork_project.destroy
end
it 'closes MR without errors' do
post :update,
namespace_id: project.namespace.path,
project_id: project.path,
id: merge_request.iid,
merge_request: {
state_event: 'close'
}
expect(response).to redirect_to([merge_request.target_project.namespace.becomes(Namespace), merge_request.target_project, merge_request])
expect(merge_request.reload.closed?).to be_truthy
end
end
end
describe "DELETE #destroy" do describe "DELETE #destroy" do
it "denies access to users unless they're admin or project owner" do it "denies access to users unless they're admin or project owner" do
delete :destroy, namespace_id: project.namespace.path, project_id: project.path, id: merge_request.iid delete :destroy, namespace_id: project.namespace.path, project_id: project.path, id: merge_request.iid
......
require 'spec_helper'
describe Projects::NotificationSettingsController do
let(:project) { create(:empty_project) }
let(:user) { create(:user) }
before do
project.team << [user, :developer]
end
describe '#update' do
context 'when not authorized' do
it 'redirects to sign in page' do
put :update,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
notification_setting: { level: :participating }
expect(response).to redirect_to(new_user_session_path)
end
end
context 'when authorized' do
before do
sign_in(user)
end
it 'returns success' do
put :update,
namespace_id: project.namespace.to_param,
project_id: project.to_param,
notification_setting: { level: :participating }
expect(response.status).to eq 200
end
end
end
end
...@@ -162,9 +162,4 @@ describe 'Commits' do ...@@ -162,9 +162,4 @@ describe 'Commits' do
end end
end end
end end
def ci_status_path(ci_commit)
project = ci_commit.project
builds_namespace_project_commit_path(project.namespace, project, ci_commit.sha)
end
end end
...@@ -76,6 +76,37 @@ describe 'Filter issues', feature: true do ...@@ -76,6 +76,37 @@ describe 'Filter issues', feature: true do
end end
end end
describe 'Filter issues for label from issues#index', js: true do
before do
visit namespace_project_issues_path(project.namespace, project)
find('.js-label-select').click
end
it 'should filter by any label' do
find('.dropdown-menu-labels a', text: 'Any Label').click
page.within '.labels-filter' do
expect(page).to have_content 'Any Label'
end
expect(find('.js-label-select .dropdown-toggle-text')).to have_content('Label')
end
it 'should filter by no label' do
find('.dropdown-menu-labels a', text: 'No Label').click
page.within '.labels-filter' do
expect(page).to have_content 'No Label'
end
expect(find('.js-label-select .dropdown-toggle-text')).to have_content('No Label')
end
it 'should filter by no label' do
find('.dropdown-menu-labels a', text: label.title).click
page.within '.labels-filter' do
expect(page).to have_content label.title
end
expect(find('.js-label-select .dropdown-toggle-text')).to have_content(label.title)
end
end
describe 'Filter issues for assignee and label from issues#index' do describe 'Filter issues for assignee and label from issues#index' do
before do before do
......
require 'spec_helper'
feature 'Edit Merge Request', feature: true do
let(:user) { create(:user) }
let(:project) { create(:project, :public) }
let(:merge_request) { create(:merge_request, :with_diffs, source_project: project) }
before do
project.team << [user, :master]
login_as user
visit edit_namespace_project_merge_request_path(project.namespace, project, merge_request)
end
context 'editing a MR' do
it 'form should have class js-quick-submit' do
expect(page).to have_selector('.js-quick-submit')
end
end
end
...@@ -100,8 +100,7 @@ feature 'Project', feature: true do ...@@ -100,8 +100,7 @@ feature 'Project', feature: true do
it 'click toggle and show dropdown', js: true do it 'click toggle and show dropdown', js: true do
find('.js-projects-dropdown-toggle').click find('.js-projects-dropdown-toggle').click
wait_for_ajax expect(page).to have_css('.dropdown-menu-projects .dropdown-content li', count: 1)
expect(page).to have_css('.select2-results li', count: 1)
end end
end end
......
...@@ -6,7 +6,7 @@ describe CiStatusHelper do ...@@ -6,7 +6,7 @@ describe CiStatusHelper do
let(:success_commit) { double("Ci::Commit", status: 'success') } let(:success_commit) { double("Ci::Commit", status: 'success') }
let(:failed_commit) { double("Ci::Commit", status: 'failed') } let(:failed_commit) { double("Ci::Commit", status: 'failed') }
describe 'ci_status_icon' do describe 'ci_icon_for_status' do
it { expect(helper.ci_icon_for_status(success_commit.status)).to include('fa-check') } it { expect(helper.ci_icon_for_status(success_commit.status)).to include('fa-check') }
it { expect(helper.ci_icon_for_status(failed_commit.status)).to include('fa-close') } it { expect(helper.ci_icon_for_status(failed_commit.status)).to include('fa-close') }
end end
......
...@@ -80,7 +80,7 @@ describe IssuesHelper do ...@@ -80,7 +80,7 @@ describe IssuesHelper do
end end
end end
describe '#url_for_new_issue' do describe 'url_for_new_issue' do
let(:issues_url) { ext_project.external_issue_tracker.new_issue_url } let(:issues_url) { ext_project.external_issue_tracker.new_issue_url }
let(:ext_expected) do let(:ext_expected) do
issues_url.gsub(':project_id', ext_project.id.to_s) issues_url.gsub(':project_id', ext_project.id.to_s)
...@@ -117,7 +117,7 @@ describe IssuesHelper do ...@@ -117,7 +117,7 @@ describe IssuesHelper do
end end
end end
describe "#merge_requests_sentence" do describe "merge_requests_sentence" do
subject { merge_requests_sentence(merge_requests)} subject { merge_requests_sentence(merge_requests)}
let(:merge_requests) do let(:merge_requests) do
[ build(:merge_request, iid: 1), build(:merge_request, iid: 2), [ build(:merge_request, iid: 1), build(:merge_request, iid: 2),
...@@ -127,7 +127,7 @@ describe IssuesHelper do ...@@ -127,7 +127,7 @@ describe IssuesHelper do
it { is_expected.to eq("!1, !2, or !3") } it { is_expected.to eq("!1, !2, or !3") }
end end
describe "#note_active_class" do describe "note_active_class" do
before do before do
@note = create :note @note = create :note
@note1 = create :note @note1 = create :note
...@@ -142,10 +142,25 @@ describe IssuesHelper do ...@@ -142,10 +142,25 @@ describe IssuesHelper do
end end
end end
describe "#awards_sort" do describe "awards_sort" do
it "sorts a hash so thumbsup and thumbsdown are always on top" do it "sorts a hash so thumbsup and thumbsdown are always on top" do
data = { "thumbsdown" => "some value", "lifter" => "some value", "thumbsup" => "some value" } data = { "thumbsdown" => "some value", "lifter" => "some value", "thumbsup" => "some value" }
expect(awards_sort(data).keys).to eq(["thumbsup", "thumbsdown", "lifter"]) expect(awards_sort(data).keys).to eq(["thumbsup", "thumbsdown", "lifter"])
end end
end end
describe "milestone_options" do
it "gets closed milestone from current issue" do
closed_milestone = create(:closed_milestone, project: project)
milestone1 = create(:milestone, project: project)
milestone2 = create(:milestone, project: project)
issue.update_attributes(milestone_id: closed_milestone.id)
options = milestone_options(issue)
expect(options).to have_selector('option[selected]', text: closed_milestone.title)
expect(options).to have_selector('option', text: milestone1.title)
expect(options).to have_selector('option', text: milestone2.title)
end
end
end end
...@@ -2,34 +2,15 @@ require 'spec_helper' ...@@ -2,34 +2,15 @@ require 'spec_helper'
describe NotificationsHelper do describe NotificationsHelper do
describe 'notification_icon' do describe 'notification_icon' do
let(:notification) { double(disabled?: false, participating?: false, watch?: false) } it { expect(notification_icon(:disabled)).to match('class="fa fa-microphone-slash fa-fw"') }
it { expect(notification_icon(:participating)).to match('class="fa fa-volume-up fa-fw"') }
context "disabled notification" do it { expect(notification_icon(:mention)).to match('class="fa fa-at fa-fw"') }
before { allow(notification).to receive(:disabled?).and_return(true) } it { expect(notification_icon(:global)).to match('class="fa fa-globe fa-fw"') }
it { expect(notification_icon(:watch)).to match('class="fa fa-eye fa-fw"') }
it "has a red icon" do end
expect(notification_icon(notification)).to match('class="fa fa-volume-off ns-mute"')
end
end
context "participating notification" do
before { allow(notification).to receive(:participating?).and_return(true) }
it "has a blue icon" do
expect(notification_icon(notification)).to match('class="fa fa-volume-down ns-part"')
end
end
context "watched notification" do
before { allow(notification).to receive(:watch?).and_return(true) }
it "has a green icon" do
expect(notification_icon(notification)).to match('class="fa fa-volume-up ns-watch"')
end
end
it "has a blue icon" do describe 'notification_title' do
expect(notification_icon(notification)).to match('class="fa fa-circle-o ns-default"') it { expect(notification_title(:watch)).to match('Watch') }
end it { expect(notification_title(:mention)).to match('On mention') }
end end
end end
%h1.title .header-content
%a %h1.title
GitLab Org %a
%a.project-item-select-holder{href: "/gitlab-org/gitlab-test"} GitLab Org
GitLab Test %a.project-item-select-holder{href: "/gitlab-org/gitlab-test"}
%input#project_path.project-item-select.js-projects-dropdown.ajax-project-select{type: "hidden", name: "project_path", "data-include-groups" => "false"} GitLab Test
%i.fa.chevron-down.dropdown-toggle-caret.js-projects-dropdown-toggle %i.fa.chevron-down.dropdown-toggle-caret.js-projects-dropdown-toggle{ "data-toggle" => "dropdown", "data-target" => ".header-content" }
.js-dropdown-menu-projects
.dropdown-menu.dropdown-select.dropdown-menu-projects
.dropdown-title
%span Go to a project
%button.dropdown-title-button.dropdown-menu-close{"aria-label" => "Close", type: "button"}
%i.fa.fa-times.dropdown-menu-close-icon
.dropdown-input
%input.dropdown-input-field{id: "", placeholder: "Search your projects", type: "search", value: ""}
%i.fa.fa-search.dropdown-input-search
%i.fa.fa-times.dropdown-input-clear.js-dropdown-input-clear{role: "button"}
.dropdown-content
.dropdown-loading
%i.fa.fa-spinner.fa-spin
#= require bootstrap
#= require select2 #= require select2
#= require gl_dropdown
#= require api #= require api
#= require project_select #= require project_select
#= require project #= require project
...@@ -14,9 +16,6 @@ describe 'Project Title', -> ...@@ -14,9 +16,6 @@ describe 'Project Title', ->
fixture.load('project_title.html') fixture.load('project_title.html')
@project = new Project() @project = new Project()
spyOn(@project, 'changeProject').and.callFake (url) ->
window.current_project_url = url
describe 'project list', -> describe 'project list', ->
beforeEach => beforeEach =>
@projects_data = fixture.load('projects.json')[0] @projects_data = fixture.load('projects.json')[0]
...@@ -29,18 +28,9 @@ describe 'Project Title', -> ...@@ -29,18 +28,9 @@ describe 'Project Title', ->
it 'to show on toggle click', => it 'to show on toggle click', =>
$('.js-projects-dropdown-toggle').click() $('.js-projects-dropdown-toggle').click()
expect($('.header-content').hasClass('open')).toBe(true)
expect($('.title .select2-container').hasClass('select2-dropdown-open')).toBe(true)
expect($('.ajax-project-dropdown li').length).toBe(@projects_data.length)
it 'hide dropdown', -> it 'hide dropdown', ->
$("#select2-drop-mask").click() $(".dropdown-menu-close-icon").click()
expect($('.title .select2-container').hasClass('select2-dropdown-open')).toBe(false)
it 'change project when clicking item', ->
$('.js-projects-dropdown-toggle').click()
$('.ajax-project-dropdown li:nth-child(2)').trigger('mouseup')
expect($('.title .select2-container').hasClass('select2-dropdown-open')).toBe(false) expect($('.header-content').hasClass('open')).toBe(false)
expect(window.current_project_url).toBe('http://localhost:3000/h5bp/html5-boilerplate')
...@@ -8,7 +8,7 @@ describe CiStatus do ...@@ -8,7 +8,7 @@ describe CiStatus do
describe '.status' do describe '.status' do
before do before do
allow(@object).to receive(:all).and_return(statuses) allow(@object).to receive(:all).and_return(CommitStatus.where(id: statuses))
end end
subject { @object.status } subject { @object.status }
......
...@@ -98,4 +98,29 @@ describe Gitlab::Metrics do ...@@ -98,4 +98,29 @@ describe Gitlab::Metrics do
end end
end end
end end
describe '.tag_transaction' do
context 'without a transaction' do
it 'does nothing' do
expect_any_instance_of(Gitlab::Metrics::Transaction).
not_to receive(:add_tag)
Gitlab::Metrics.tag_transaction(:foo, 'bar')
end
end
context 'with a transaction' do
let(:transaction) { Gitlab::Metrics::Transaction.new }
it 'adds the tag to the transaction' do
expect(Gitlab::Metrics).to receive(:current_transaction).
and_return(transaction)
expect(transaction).to receive(:add_tag).
with(:foo, 'bar')
Gitlab::Metrics.tag_transaction(:foo, 'bar')
end
end
end
end end
...@@ -15,20 +15,20 @@ describe Gitlab::OAuth::User, lib: true do ...@@ -15,20 +15,20 @@ describe Gitlab::OAuth::User, lib: true do
end end
let(:ldap_user) { Gitlab::LDAP::Person.new(Net::LDAP::Entry.new, 'ldapmain') } let(:ldap_user) { Gitlab::LDAP::Person.new(Net::LDAP::Entry.new, 'ldapmain') }
describe :persisted? do describe '#persisted?' do
let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') } let!(:existing_user) { create(:omniauth_user, extern_uid: 'my-uid', provider: 'my-provider') }
it "finds an existing user based on uid and provider (facebook)" do it "finds an existing user based on uid and provider (facebook)" do
expect( oauth_user.persisted? ).to be_truthy expect( oauth_user.persisted? ).to be_truthy
end end
it "returns false if use is not found in database" do it 'returns false if user is not found in database' do
allow(auth_hash).to receive(:uid).and_return('non-existing') allow(auth_hash).to receive(:uid).and_return('non-existing')
expect( oauth_user.persisted? ).to be_falsey expect( oauth_user.persisted? ).to be_falsey
end end
end end
describe :save do describe '#save' do
def stub_omniauth_config(messages) def stub_omniauth_config(messages)
allow(Gitlab.config.omniauth).to receive_messages(messages) allow(Gitlab.config.omniauth).to receive_messages(messages)
end end
...@@ -40,8 +40,27 @@ describe Gitlab::OAuth::User, lib: true do ...@@ -40,8 +40,27 @@ describe Gitlab::OAuth::User, lib: true do
let(:provider) { 'twitter' } let(:provider) { 'twitter' }
describe 'signup' do describe 'signup' do
shared_examples "to verify compliance with allow_single_sign_on" do shared_examples 'to verify compliance with allow_single_sign_on' do
context "with new allow_single_sign_on enabled syntax" do context 'provider is marked as external' do
it 'should mark user as external' do
stub_omniauth_config(allow_single_sign_on: ['twitter'], external_providers: ['twitter'])
oauth_user.save
expect(gl_user).to be_valid
expect(gl_user.external).to be_truthy
end
end
context 'provider was external, now has been removed' do
it 'should mark existing user internal' do
create(:omniauth_user, extern_uid: 'my-uid', provider: 'twitter', external: true)
stub_omniauth_config(allow_single_sign_on: ['twitter'], external_providers: ['facebook'])
oauth_user.save
expect(gl_user).to be_valid
expect(gl_user.external).to be_falsey
end
end
context 'with new allow_single_sign_on enabled syntax' do
before { stub_omniauth_config(allow_single_sign_on: ['twitter']) } before { stub_omniauth_config(allow_single_sign_on: ['twitter']) }
it "creates a user from Omniauth" do it "creates a user from Omniauth" do
...@@ -67,16 +86,16 @@ describe Gitlab::OAuth::User, lib: true do ...@@ -67,16 +86,16 @@ describe Gitlab::OAuth::User, lib: true do
end end
end end
context "with new allow_single_sign_on disabled syntax" do context 'with new allow_single_sign_on disabled syntax' do
before { stub_omniauth_config(allow_single_sign_on: []) } before { stub_omniauth_config(allow_single_sign_on: []) }
it "throws an error" do it 'throws an error' do
expect{ oauth_user.save }.to raise_error StandardError expect{ oauth_user.save }.to raise_error StandardError
end end
end end
context "with old allow_single_sign_on disabled (Default)" do context 'with old allow_single_sign_on disabled (Default)' do
before { stub_omniauth_config(allow_single_sign_on: false) } before { stub_omniauth_config(allow_single_sign_on: false) }
it "throws an error" do it 'throws an error' do
expect{ oauth_user.save }.to raise_error StandardError expect{ oauth_user.save }.to raise_error StandardError
end end
end end
......
require 'rails_helper'
describe Gitlab, lib: true do
describe '.com?' do
it 'is true when on GitLab.com' do
stub_config_setting(url: 'https://gitlab.com')
expect(described_class.com?).to eq true
end
it 'is false when not on GitLab.com' do
stub_config_setting(url: 'http://example.com')
expect(described_class.com?).to eq false
end
end
end
require 'rails_helper'
RSpec.describe NotificationSetting, type: :model do
describe "Associations" do
it { is_expected.to belong_to(:user) }
it { is_expected.to belong_to(:source) }
end
describe "Validation" do
subject { NotificationSetting.new(source_id: 1, source_type: 'Project') }
it { is_expected.to validate_presence_of(:user) }
it { is_expected.to validate_presence_of(:source) }
it { is_expected.to validate_presence_of(:level) }
it { is_expected.to validate_uniqueness_of(:user_id).scoped_to([:source_id, :source_type]).with_message(/already exists in source/) }
end
end
...@@ -393,6 +393,8 @@ describe Repository, models: true do ...@@ -393,6 +393,8 @@ describe Repository, models: true do
describe '#expire_cache' do describe '#expire_cache' do
it 'expires all caches' do it 'expires all caches' do
expect(repository).to receive(:expire_branch_cache) expect(repository).to receive(:expire_branch_cache)
expect(repository).to receive(:expire_branch_count_cache)
expect(repository).to receive(:expire_tag_count_cache)
repository.expire_cache repository.expire_cache
end end
......
...@@ -42,9 +42,10 @@ describe API::API, api: true do ...@@ -42,9 +42,10 @@ describe API::API, api: true do
end end
end end
it "users not part of the group should get access error" do it 'users not part of the group should get access error' do
get api("/groups/#{group_with_members.id}/members", stranger) get api("/groups/#{group_with_members.id}/members", stranger)
expect(response.status).to eq(403)
expect(response.status).to eq(404)
end end
end end
end end
...@@ -165,12 +166,13 @@ describe API::API, api: true do ...@@ -165,12 +166,13 @@ describe API::API, api: true do
end end
end end
describe "DELETE /groups/:id/members/:user_id" do describe 'DELETE /groups/:id/members/:user_id' do
context "when not a member of the group" do context 'when not a member of the group' do
it "should not delete guest's membership of group_with_members" do it "should not delete guest's membership of group_with_members" do
random_user = create(:user) random_user = create(:user)
delete api("/groups/#{group_with_members.id}/members/#{owner.id}", random_user) delete api("/groups/#{group_with_members.id}/members/#{owner.id}", random_user)
expect(response.status).to eq(403)
expect(response.status).to eq(404)
end end
end end
......
...@@ -61,7 +61,8 @@ describe API::API, api: true do ...@@ -61,7 +61,8 @@ describe API::API, api: true do
it "should not return a group not attached to user1" do it "should not return a group not attached to user1" do
get api("/groups/#{group2.id}", user1) get api("/groups/#{group2.id}", user1)
expect(response.status).to eq(403)
expect(response.status).to eq(404)
end end
end end
...@@ -92,9 +93,54 @@ describe API::API, api: true do ...@@ -92,9 +93,54 @@ describe API::API, api: true do
it 'should not return a group not attached to user1' do it 'should not return a group not attached to user1' do
get api("/groups/#{group2.path}", user1) get api("/groups/#{group2.path}", user1)
expect(response.status).to eq(404)
end
end
end
describe 'PUT /groups/:id' do
let(:new_group_name) { 'New Group'}
context 'when authenticated as the group owner' do
it 'updates the group' do
put api("/groups/#{group1.id}", user1), name: new_group_name
expect(response.status).to eq(200)
expect(json_response['name']).to eq(new_group_name)
end
it 'returns 404 for a non existing group' do
put api('/groups/1328', user1)
expect(response.status).to eq(404)
end
end
context 'when authenticated as the admin' do
it 'updates the group' do
put api("/groups/#{group1.id}", admin), name: new_group_name
expect(response.status).to eq(200)
expect(json_response['name']).to eq(new_group_name)
end
end
context 'when authenticated as an user that can see the group' do
it 'does not updates the group' do
put api("/groups/#{group1.id}", user2), name: new_group_name
expect(response.status).to eq(403) expect(response.status).to eq(403)
end end
end end
context 'when authenticated as an user that cannot see the group' do
it 'returns 404 when trying to update the group' do
put api("/groups/#{group2.id}", user1), name: new_group_name
expect(response.status).to eq(404)
end
end
end end
describe "GET /groups/:id/projects" do describe "GET /groups/:id/projects" do
...@@ -113,7 +159,8 @@ describe API::API, api: true do ...@@ -113,7 +159,8 @@ describe API::API, api: true do
it "should not return a group not attached to user1" do it "should not return a group not attached to user1" do
get api("/groups/#{group2.id}/projects", user1) get api("/groups/#{group2.id}/projects", user1)
expect(response.status).to eq(403)
expect(response.status).to eq(404)
end end
end end
...@@ -145,7 +192,8 @@ describe API::API, api: true do ...@@ -145,7 +192,8 @@ describe API::API, api: true do
it 'should not return a group not attached to user1' do it 'should not return a group not attached to user1' do
get api("/groups/#{group2.path}/projects", user1) get api("/groups/#{group2.path}/projects", user1)
expect(response.status).to eq(403)
expect(response.status).to eq(404)
end end
end end
end end
...@@ -203,7 +251,8 @@ describe API::API, api: true do ...@@ -203,7 +251,8 @@ describe API::API, api: true do
it "should not remove a group not attached to user1" do it "should not remove a group not attached to user1" do
delete api("/groups/#{group2.id}", user1) delete api("/groups/#{group2.id}", user1)
expect(response.status).to eq(403)
expect(response.status).to eq(404)
end end
end end
......
...@@ -7,7 +7,7 @@ describe API::API, api: true do ...@@ -7,7 +7,7 @@ describe API::API, api: true do
let(:author) { create(:author) } let(:author) { create(:author) }
let(:assignee) { create(:assignee) } let(:assignee) { create(:assignee) }
let(:admin) { create(:user, :admin) } let(:admin) { create(:user, :admin) }
let!(:project) { create(:project, :public, namespace: user.namespace ) } let!(:project) { create(:project, :public, creator_id: user.id, namespace: user.namespace ) }
let!(:closed_issue) do let!(:closed_issue) do
create :closed_issue, create :closed_issue,
author: user, author: user,
...@@ -501,4 +501,72 @@ describe API::API, api: true do ...@@ -501,4 +501,72 @@ describe API::API, api: true do
end end
end end
end end
describe '/projects/:id/issues/:issue_id/move' do
let!(:target_project) { create(:project, path: 'project2', creator_id: user.id, namespace: user.namespace ) }
let!(:target_project2) { create(:project, creator_id: non_member.id, namespace: non_member.namespace ) }
it 'moves an issue' do
post api("/projects/#{project.id}/issues/#{issue.id}/move", user),
to_project_id: target_project.id
expect(response.status).to eq(201)
expect(json_response['project_id']).to eq(target_project.id)
end
context 'when source and target projects are the same' do
it 'returns 400 when trying to move an issue' do
post api("/projects/#{project.id}/issues/#{issue.id}/move", user),
to_project_id: project.id
expect(response.status).to eq(400)
expect(json_response['message']).to eq('Cannot move issue to project it originates from!')
end
end
context 'when the user does not have the permission to move issues' do
it 'returns 400 when trying to move an issue' do
post api("/projects/#{project.id}/issues/#{issue.id}/move", user),
to_project_id: target_project2.id
expect(response.status).to eq(400)
expect(json_response['message']).to eq('Cannot move issue due to insufficient permissions!')
end
end
it 'moves the issue to another namespace if I am admin' do
post api("/projects/#{project.id}/issues/#{issue.id}/move", admin),
to_project_id: target_project2.id
expect(response.status).to eq(201)
expect(json_response['project_id']).to eq(target_project2.id)
end
context 'when issue does not exist' do
it 'returns 404 when trying to move an issue' do
post api("/projects/#{project.id}/issues/123/move", user),
to_project_id: target_project.id
expect(response.status).to eq(404)
end
end
context 'when source project does not exist' do
it 'returns 404 when trying to move an issue' do
post api("/projects/123/issues/#{issue.id}/move", user),
to_project_id: target_project.id
expect(response.status).to eq(404)
end
end
context 'when target project does not exist' do
it 'returns 404 when trying to move an issue' do
post api("/projects/#{project.id}/issues/#{issue.id}/move", user),
to_project_id: 123
expect(response.status).to eq(404)
end
end
end
end end
...@@ -50,10 +50,12 @@ describe API::API, api: true do ...@@ -50,10 +50,12 @@ describe API::API, api: true do
end end
it 'should return a project milestone by iid' do it 'should return a project milestone by iid' do
get api("/projects/#{project.id}/milestones?iid=#{milestone.iid}", user) get api("/projects/#{project.id}/milestones?iid=#{closed_milestone.iid}", user)
expect(response.status).to eq 200 expect(response.status).to eq 200
expect(json_response.first['title']).to eq milestone.title expect(json_response.size).to eq(1)
expect(json_response.first['id']).to eq milestone.id expect(json_response.first['title']).to eq closed_milestone.title
expect(json_response.first['id']).to eq closed_milestone.id
end end
it 'should return 401 error if user not authenticated' do it 'should return 401 error if user not authenticated' do
......
...@@ -241,4 +241,65 @@ describe API::API, api: true do ...@@ -241,4 +241,65 @@ describe API::API, api: true do
end end
end end
describe 'DELETE /projects/:id/noteable/:noteable_id/notes/:note_id' do
context 'when noteable is an Issue' do
it 'deletes a note' do
delete api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user)
expect(response.status).to eq(200)
# Check if note is really deleted
delete api("/projects/#{project.id}/issues/#{issue.id}/"\
"notes/#{issue_note.id}", user)
expect(response.status).to eq(404)
end
it 'returns a 404 error when note id not found' do
delete api("/projects/#{project.id}/issues/#{issue.id}/notes/123", user)
expect(response.status).to eq(404)
end
end
context 'when noteable is a Snippet' do
it 'deletes a note' do
delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/#{snippet_note.id}", user)
expect(response.status).to eq(200)
# Check if note is really deleted
delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/#{snippet_note.id}", user)
expect(response.status).to eq(404)
end
it 'returns a 404 error when note id not found' do
delete api("/projects/#{project.id}/snippets/#{snippet.id}/"\
"notes/123", user)
expect(response.status).to eq(404)
end
end
context 'when noteable is a Merge Request' do
it 'deletes a note' do
delete api("/projects/#{project.id}/merge_requests/"\
"#{merge_request.id}/notes/#{merge_request_note.id}", user)
expect(response.status).to eq(200)
# Check if note is really deleted
delete api("/projects/#{project.id}/merge_requests/"\
"#{merge_request.id}/notes/#{merge_request_note.id}", user)
expect(response.status).to eq(404)
end
it 'returns a 404 error when note id not found' do
delete api("/projects/#{project.id}/merge_requests/"\
"#{merge_request.id}/notes/123", user)
expect(response.status).to eq(404)
end
end
end
end end
...@@ -118,8 +118,10 @@ describe API::API, api: true do ...@@ -118,8 +118,10 @@ describe API::API, api: true do
end end
describe "DELETE /projects/:id/members/:user_id" do describe "DELETE /projects/:id/members/:user_id" do
before { project_member } before do
before { project_member2 } project_member
project_member2
end
it "should remove user from project team" do it "should remove user from project team" do
expect do expect do
...@@ -132,6 +134,7 @@ describe API::API, api: true do ...@@ -132,6 +134,7 @@ describe API::API, api: true do
expect do expect do
delete api("/projects/#{project.id}/members/#{user3.id}", user) delete api("/projects/#{project.id}/members/#{user3.id}", user)
end.to_not change { ProjectMember.count } end.to_not change { ProjectMember.count }
expect(response.status).to eq(200)
end end
it "should return 200 if team member already removed" do it "should return 200 if team member already removed" do
...@@ -145,8 +148,19 @@ describe API::API, api: true do ...@@ -145,8 +148,19 @@ describe API::API, api: true do
delete api("/projects/#{project.id}/members/1000000", user) delete api("/projects/#{project.id}/members/1000000", user)
end.to change { ProjectMember.count }.by(0) end.to change { ProjectMember.count }.by(0)
expect(response.status).to eq(200) expect(response.status).to eq(200)
expect(json_response['message']).to eq("Access revoked")
expect(json_response['id']).to eq(1000000) expect(json_response['id']).to eq(1000000)
expect(json_response['message']).to eq('Access revoked')
end
context 'when the user is not an admin or owner' do
it 'can leave the project' do
expect do
delete api("/projects/#{project.id}/members/#{user3.id}", user3)
end.to change { ProjectMember.count }.by(-1)
expect(response.status).to eq(200)
expect(json_response['id']).to eq(project_member2.id)
end
end end
end end
end end
...@@ -40,6 +40,23 @@ describe API::API, api: true do ...@@ -40,6 +40,23 @@ describe API::API, api: true do
end end
end end
describe 'GET /projects/:id/repository/tags/:tag_name' do
let(:tag_name) { project.repository.tag_names.sort.reverse.first }
it 'returns a specific tag' do
get api("/projects/#{project.id}/repository/tags/#{tag_name}", user)
expect(response.status).to eq(200)
expect(json_response['name']).to eq(tag_name)
end
it 'returns 404 for an invalid tag name' do
get api("/projects/#{project.id}/repository/tags/foobar", user)
expect(response.status).to eq(404)
end
end
describe 'POST /projects/:id/repository/tags' do describe 'POST /projects/:id/repository/tags' do
context 'lightweight tags' do context 'lightweight tags' do
it 'should create a new tag' do it 'should create a new tag' do
......
require 'spec_helper'
describe Notes::DeleteService, services: true do
describe '#execute' do
it 'deletes a note' do
project = create(:empty_project)
issue = create(:issue, project: project)
note = create(:note, project: project, noteable: issue)
described_class.new(project, note.author).execute(note)
expect(project.issues.find(issue.id).notes).not_to include(note)
end
end
end
...@@ -88,12 +88,9 @@ describe NotificationService, services: true do ...@@ -88,12 +88,9 @@ describe NotificationService, services: true do
note.project.namespace_id = group.id note.project.namespace_id = group.id
note.project.group.add_user(@u_watcher, GroupMember::MASTER) note.project.group.add_user(@u_watcher, GroupMember::MASTER)
note.project.save note.project.save
user_project = note.project.project_members.find_by_user_id(@u_watcher.id)
user_project.notification_level = Notification::N_PARTICIPATING @u_watcher.notification_settings_for(note.project).participating!
user_project.save @u_watcher.notification_settings_for(note.project.group).global!
group_member = note.project.group.group_members.find_by_user_id(@u_watcher.id)
group_member.notification_level = Notification::N_GLOBAL
group_member.save
ActionMailer::Base.deliveries.clear ActionMailer::Base.deliveries.clear
end end
...@@ -215,7 +212,7 @@ describe NotificationService, services: true do ...@@ -215,7 +212,7 @@ describe NotificationService, services: true do
end end
it do it do
@u_committer.update_attributes(notification_level: Notification::N_MENTION) @u_committer.update_attributes(notification_level: :mention)
notification.new_note(note) notification.new_note(note)
should_not_email(@u_committer) should_not_email(@u_committer)
end end
...@@ -246,7 +243,7 @@ describe NotificationService, services: true do ...@@ -246,7 +243,7 @@ describe NotificationService, services: true do
end end
it do it do
issue.assignee.update_attributes(notification_level: Notification::N_MENTION) issue.assignee.update_attributes(notification_level: :mention)
notification.new_issue(issue, @u_disabled) notification.new_issue(issue, @u_disabled)
should_not_email(issue.assignee) should_not_email(issue.assignee)
...@@ -596,13 +593,13 @@ describe NotificationService, services: true do ...@@ -596,13 +593,13 @@ describe NotificationService, services: true do
end end
def build_team(project) def build_team(project)
@u_watcher = create(:user, notification_level: Notification::N_WATCH) @u_watcher = create(:user, notification_level: :watch)
@u_participating = create(:user, notification_level: Notification::N_PARTICIPATING) @u_participating = create(:user, notification_level: :participating)
@u_participant_mentioned = create(:user, username: 'participant', notification_level: Notification::N_PARTICIPATING) @u_participant_mentioned = create(:user, username: 'participant', notification_level: :participating)
@u_disabled = create(:user, notification_level: Notification::N_DISABLED) @u_disabled = create(:user, notification_level: :disabled)
@u_mentioned = create(:user, username: 'mention', notification_level: Notification::N_MENTION) @u_mentioned = create(:user, username: 'mention', notification_level: :mention)
@u_committer = create(:user, username: 'committer') @u_committer = create(:user, username: 'committer')
@u_not_mentioned = create(:user, username: 'regular', notification_level: Notification::N_PARTICIPATING) @u_not_mentioned = create(:user, username: 'regular', notification_level: :participating)
@u_outsider_mentioned = create(:user, username: 'outsider') @u_outsider_mentioned = create(:user, username: 'outsider')
project.team << [@u_watcher, :master] project.team << [@u_watcher, :master]
...@@ -617,8 +614,8 @@ describe NotificationService, services: true do ...@@ -617,8 +614,8 @@ describe NotificationService, services: true do
def add_users_with_subscription(project, issuable) def add_users_with_subscription(project, issuable)
@subscriber = create :user @subscriber = create :user
@unsubscriber = create :user @unsubscriber = create :user
@subscribed_participant = create(:user, username: 'subscribed_participant', notification_level: Notification::N_PARTICIPATING) @subscribed_participant = create(:user, username: 'subscribed_participant', notification_level: :participating)
@watcher_and_subscriber = create(:user, notification_level: Notification::N_WATCH) @watcher_and_subscriber = create(:user, notification_level: :watch)
project.team << [@subscribed_participant, :master] project.team << [@subscribed_participant, :master]
project.team << [@subscriber, :master] project.team << [@subscriber, :master]
......
/*
* Date Format 1.2.3
* (c) 2007-2009 Steven Levithan <stevenlevithan.com>
* MIT license
*
* Includes enhancements by Scott Trenda <scott.trenda.net>
* and Kris Kowal <cixar.com/~kris.kowal/>
*
* Accepts a date, a mask, or a date and a mask.
* Returns a formatted version of the given date.
* The date defaults to the current date/time.
* The mask defaults to dateFormat.masks.default.
*/
var dateFormat = function () {
var token = /d{1,4}|m{1,4}|yy(?:yy)?|([HhMsTt])\1?|[LloSZ]|"[^"]*"|'[^']*'/g,
timezone = /\b(?:[PMCEA][SDP]T|(?:Pacific|Mountain|Central|Eastern|Atlantic) (?:Standard|Daylight|Prevailing) Time|(?:GMT|UTC)(?:[-+]\d{4})?)\b/g,
timezoneClip = /[^-+\dA-Z]/g,
pad = function (val, len) {
val = String(val);
len = len || 2;
while (val.length < len) val = "0" + val;
return val;
};
// Regexes and supporting functions are cached through closure
return function (date, mask, utc) {
var dF = dateFormat;
// You can't provide utc if you skip other args (use the "UTC:" mask prefix)
if (arguments.length == 1 && Object.prototype.toString.call(date) == "[object String]" && !/\d/.test(date)) {
mask = date;
date = undefined;
}
// Passing date through Date applies Date.parse, if necessary
date = date ? new Date(date) : new Date;
if (isNaN(date)) throw SyntaxError("invalid date");
mask = String(dF.masks[mask] || mask || dF.masks["default"]);
// Allow setting the utc argument via the mask
if (mask.slice(0, 4) == "UTC:") {
mask = mask.slice(4);
utc = true;
}
var _ = utc ? "getUTC" : "get",
d = date[_ + "Date"](),
D = date[_ + "Day"](),
m = date[_ + "Month"](),
y = date[_ + "FullYear"](),
H = date[_ + "Hours"](),
M = date[_ + "Minutes"](),
s = date[_ + "Seconds"](),
L = date[_ + "Milliseconds"](),
o = utc ? 0 : date.getTimezoneOffset(),
flags = {
d: d,
dd: pad(d),
ddd: dF.i18n.dayNames[D],
dddd: dF.i18n.dayNames[D + 7],
m: m + 1,
mm: pad(m + 1),
mmm: dF.i18n.monthNames[m],
mmmm: dF.i18n.monthNames[m + 12],
yy: String(y).slice(2),
yyyy: y,
h: H % 12 || 12,
hh: pad(H % 12 || 12),
H: H,
HH: pad(H),
M: M,
MM: pad(M),
s: s,
ss: pad(s),
l: pad(L, 3),
L: pad(L > 99 ? Math.round(L / 10) : L),
t: H < 12 ? "a" : "p",
tt: H < 12 ? "am" : "pm",
T: H < 12 ? "A" : "P",
TT: H < 12 ? "AM" : "PM",
Z: utc ? "UTC" : (String(date).match(timezone) || [""]).pop().replace(timezoneClip, ""),
o: (o > 0 ? "-" : "+") + pad(Math.floor(Math.abs(o) / 60) * 100 + Math.abs(o) % 60, 4),
S: ["th", "st", "nd", "rd"][d % 10 > 3 ? 0 : (d % 100 - d % 10 != 10) * d % 10]
};
return mask.replace(token, function ($0) {
return $0 in flags ? flags[$0] : $0.slice(1, $0.length - 1);
});
};
}();
// Some common format strings
dateFormat.masks = {
"default": "ddd mmm dd yyyy HH:MM:ss",
shortDate: "m/d/yy",
mediumDate: "mmm d, yyyy",
longDate: "mmmm d, yyyy",
fullDate: "dddd, mmmm d, yyyy",
shortTime: "h:MM TT",
mediumTime: "h:MM:ss TT",
longTime: "h:MM:ss TT Z",
isoDate: "yyyy-mm-dd",
isoTime: "HH:MM:ss",
isoDateTime: "yyyy-mm-dd'T'HH:MM:ss",
isoUtcDateTime: "UTC:yyyy-mm-dd'T'HH:MM:ss'Z'"
};
// Internationalization strings
dateFormat.i18n = {
dayNames: [
"Sun", "Mon", "Tue", "Wed", "Thu", "Fri", "Sat",
"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"
],
monthNames: [
"Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec",
"January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"
]
};
// For convenience...
Date.prototype.format = function (mask, utc) {
return dateFormat(this, mask, utc);
};
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