Commit f815094e authored by Dmitriy Zaporozhets's avatar Dmitriy Zaporozhets

Merge branch 'master' of gitlab.com:gitlab-org/gitlab-ce

parents b6117074 b5ea3550
...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date. ...@@ -2,6 +2,7 @@ Please view this file on the master branch, on stable branches it's out of date.
v 7.12.0 (unreleased) v 7.12.0 (unreleased)
- Refactor permission checks with issues and merge requests project settings (Stan Hu) - Refactor permission checks with issues and merge requests project settings (Stan Hu)
- Fix Markdown preview not working in Edit Milestone page (Stan Hu)
- Add web hook support for note events (Stan Hu) - Add web hook support for note events (Stan Hu)
- Disable "New Issue" and "New Merge Request" buttons when features are disabled in project settings (Stan Hu) - Disable "New Issue" and "New Merge Request" buttons when features are disabled in project settings (Stan Hu)
- Remove Rack Attack monkey patches and bump to version 4.3.0 (Stan Hu) - Remove Rack Attack monkey patches and bump to version 4.3.0 (Stan Hu)
......
...@@ -239,7 +239,7 @@ group :development, :test do ...@@ -239,7 +239,7 @@ group :development, :test do
gem 'minitest', '~> 5.3.0' gem 'minitest', '~> 5.3.0'
# Generate Fake data # Generate Fake data
gem "ffaker" gem 'ffaker', '~> 2.0.0'
# Guard # Guard
gem 'guard-rspec' gem 'guard-rspec'
......
...@@ -176,7 +176,7 @@ GEM ...@@ -176,7 +176,7 @@ GEM
faraday_middleware (0.9.0) faraday_middleware (0.9.0)
faraday (>= 0.7.4, < 0.9) faraday (>= 0.7.4, < 0.9)
fastercsv (1.5.5) fastercsv (1.5.5)
ffaker (1.22.1) ffaker (2.0.0)
ffi (1.9.8) ffi (1.9.8)
fog (1.21.0) fog (1.21.0)
fog-brightbox fog-brightbox
...@@ -547,9 +547,9 @@ GEM ...@@ -547,9 +547,9 @@ GEM
sdoc (0.3.20) sdoc (0.3.20)
json (>= 1.1.3) json (>= 1.1.3)
rdoc (~> 3.10) rdoc (~> 3.10)
seed-fu (2.3.1) seed-fu (2.3.5)
activerecord (>= 3.1, < 4.2) activerecord (>= 3.1, < 4.3)
activesupport (>= 3.1, < 4.2) activesupport (>= 3.1, < 4.3)
select2-rails (3.5.2) select2-rails (3.5.2)
thor (~> 0.14) thor (~> 0.14)
settingslogic (2.0.9) settingslogic (2.0.9)
...@@ -589,7 +589,7 @@ GEM ...@@ -589,7 +589,7 @@ GEM
capybara (>= 2.0.0) capybara (>= 2.0.0)
railties (>= 3) railties (>= 3)
spinach (>= 0.4) spinach (>= 0.4)
spring (1.3.3) spring (1.3.6)
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.0.0)
...@@ -713,7 +713,7 @@ DEPENDENCIES ...@@ -713,7 +713,7 @@ DEPENDENCIES
email_spec email_spec
enumerize enumerize
factory_girl_rails factory_girl_rails
ffaker ffaker (~> 2.0.0)
fog (~> 1.14) fog (~> 1.14)
font-awesome-rails (~> 4.2) font-awesome-rails (~> 4.2)
foreman foreman
......
class @ZenMode class @ZenMode
@fullscreen_prefix = 'fullscreen_'
constructor: -> constructor: ->
@active_zen_area = null @active_zen_area = null
@active_checkbox = null @active_checkbox = null
...@@ -23,7 +21,7 @@ class @ZenMode ...@@ -23,7 +21,7 @@ class @ZenMode
if checkbox.checked if checkbox.checked
# Disable other keyboard shortcuts in ZEN mode # Disable other keyboard shortcuts in ZEN mode
Mousetrap.pause() Mousetrap.pause()
@udpateActiveZenArea(checkbox) @updateActiveZenArea(checkbox)
else else
@exitZenMode() @exitZenMode()
...@@ -32,14 +30,11 @@ class @ZenMode ...@@ -32,14 +30,11 @@ class @ZenMode
@exitZenMode() @exitZenMode()
e.preventDefault() e.preventDefault()
$(window).on 'hashchange', @updateZenModeFromLocationHash updateActiveZenArea: (checkbox) =>
udpateActiveZenArea: (checkbox) =>
@active_checkbox = $(checkbox) @active_checkbox = $(checkbox)
@active_checkbox.prop('checked', true) @active_checkbox.prop('checked', true)
@active_zen_area = @active_checkbox.parent().find('textarea') @active_zen_area = @active_checkbox.parent().find('textarea')
@active_zen_area.focus() @active_zen_area.focus()
window.location.hash = ZenMode.fullscreen_prefix + @active_checkbox.prop('id')
exitZenMode: => exitZenMode: =>
if @active_zen_area isnt null if @active_zen_area isnt null
...@@ -51,17 +46,3 @@ class @ZenMode ...@@ -51,17 +46,3 @@ class @ZenMode
window.scrollTo(window.pageXOffset, @scroll_position) window.scrollTo(window.pageXOffset, @scroll_position)
# Enable dropzone when leaving ZEN mode # Enable dropzone when leaving ZEN mode
Dropzone.forElement('.div-dropzone').enable() Dropzone.forElement('.div-dropzone').enable()
checkboxFromLocationHash: (e) ->
id = $.trim(window.location.hash.replace('#' + ZenMode.fullscreen_prefix, ''))
if id
return $('.zennable input[type=checkbox]#' + id)[0]
else
return null
updateZenModeFromLocationHash: (e) =>
checkbox = @checkboxFromLocationHash()
if checkbox
@udpateActiveZenArea(checkbox)
else
@exitZenMode()
module LabelsHelper module LabelsHelper
include ActionView::Helpers::TagHelper include ActionView::Helpers::TagHelper
# Link to a Label
#
# label - Label object to link to
# project - Project object which will be used as the context for the label's
# link. If omitted, defaults to `@project`, or the label's own
# project.
# block - An optional block that will be passed to `link_to`, forming the
# body of the link element. If omitted, defaults to
# `render_colored_label`.
#
# Examples:
#
# # Allow the generated link to use the label's own project
# link_to_label(label)
#
# # Force the generated link to use @project
# @project = Project.first
# link_to_label(label)
#
# # Force the generated link to use a provided project
# link_to_label(label, project: Project.last)
#
# # Customize link body with a block
# link_to_label(label) { "My Custom Label Text" }
#
# Returns a String
def link_to_label(label, project: nil, &block)
project ||= @project || label.project
link = namespace_project_issues_path(project.namespace, project,
label_name: label.name)
if block_given?
link_to link, &block
else
link_to render_colored_label(label), link
end
end
def project_label_names def project_label_names
@project.labels.pluck(:title) @project.labels.pluck(:title)
end end
......
...@@ -30,5 +30,4 @@ ...@@ -30,5 +30,4 @@
%label Labels %label Labels
.issue-show-labels .issue-show-labels
- @issue.labels.each do |label| - @issue.labels.each do |label|
= link_to namespace_project_issues_path(@project.namespace, @project, label_name: label.name) do = link_to_label(label)
= render_colored_label(label)
...@@ -8,8 +8,7 @@ ...@@ -8,8 +8,7 @@
= link_to_gfm issue.title, issue_path(issue), class: "row_title" = link_to_gfm issue.title, issue_path(issue), class: "row_title"
.issue-labels .issue-labels
- issue.labels.each do |label| - issue.labels.each do |label|
= link_to namespace_project_issues_path(issue.project.namespace, issue.project, label_name: label.name) do = link_to_label(label, project: issue.project)
= render_colored_label(label)
.pull-right.light .pull-right.light
- if issue.closed? - if issue.closed?
%span %span
......
%li{id: dom_id(label)} %li{id: dom_id(label)}
= render_colored_label(label) = link_to_label(label)
.pull-right .pull-right
%strong.append-right-20 %strong.append-right-20
= link_to namespace_project_issues_path(@project.namespace, @project, label_name: label.name) do = link_to_label(label) do
= pluralize label.open_issues_count, 'open issue' = pluralize label.open_issues_count, 'open issue'
- if can? current_user, :admin_label, @project - if can? current_user, :admin_label, @project
......
...@@ -27,5 +27,4 @@ ...@@ -27,5 +27,4 @@
%label Labels %label Labels
.merge-request-show-labels .merge-request-show-labels
- @merge_request.labels.each do |label| - @merge_request.labels.each do |label|
= link_to namespace_project_merge_requests_path(@project.namespace, @project, label_name: label.name) do = link_to_label(label)
= render_colored_label(label)
...@@ -4,8 +4,7 @@ ...@@ -4,8 +4,7 @@
= link_to_gfm merge_request.title, merge_request_path(merge_request), class: "row_title" = link_to_gfm merge_request.title, merge_request_path(merge_request), class: "row_title"
.merge-request-labels .merge-request-labels
- merge_request.labels.each do |label| - merge_request.labels.each do |label|
= link_to namespace_project_merge_requests_path(merge_request.project.namespace, merge_request.project, label_name: label.name) do = link_to_label(label, project: merge_request.project)
= render_colored_label(label)
.pull-right.light .pull-right.light
- if merge_request.merged? - if merge_request.merged?
%span %span
......
...@@ -3,6 +3,5 @@ begin ...@@ -3,6 +3,5 @@ begin
load File.expand_path("../spring", __FILE__) load File.expand_path("../spring", __FILE__)
rescue LoadError rescue LoadError
end end
require_relative '../config/boot' require 'bundler/setup'
require 'rake' load Gem.bin_path('rake', 'rake')
Rake.application.run
#!/usr/bin/env ruby #!/usr/bin/env ruby
# This file loads spring without using Bundler, in order to be fast # This file loads spring without using Bundler, in order to be fast.
# It gets overwritten when you run the `spring binstub` command # It gets overwritten when you run the `spring binstub` command.
unless defined?(Spring) unless defined?(Spring)
require "rubygems" require "rubygems"
require "bundler" require "bundler"
if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ spring \((.*?)\)$.*?^$/m) if match = Bundler.default_lockfile.read.match(/^GEM$.*?^ (?: )*spring \((.*?)\)$.*?^$/m)
ENV["GEM_PATH"] = ([Bundler.bundle_path.to_s] + Gem.path).join(File::PATH_SEPARATOR) Gem.paths = { "GEM_PATH" => [Bundler.bundle_path.to_s, *Gem.path].uniq }
ENV["GEM_HOME"] = ""
Gem.paths = ENV
gem "spring", match[1] gem "spring", match[1]
require "spring/binstub" require "spring/binstub"
end end
......
...@@ -23,7 +23,7 @@ Sidekiq::Testing.inline! do ...@@ -23,7 +23,7 @@ Sidekiq::Testing.inline! do
name: group_path.titleize, name: group_path.titleize,
path: group_path path: group_path
) )
group.description = Faker::Lorem.sentence group.description = FFaker::Lorem.sentence
group.save group.save
group.add_owner(User.first) group.add_owner(User.first)
...@@ -35,7 +35,7 @@ Sidekiq::Testing.inline! do ...@@ -35,7 +35,7 @@ Sidekiq::Testing.inline! do
import_url: url, import_url: url,
namespace_id: group.id, namespace_id: group.id,
name: project_path.titleize, name: project_path.titleize,
description: Faker::Lorem.sentence, description: FFaker::Lorem.sentence,
visibility_level: Gitlab::VisibilityLevel.values.sample visibility_level: Gitlab::VisibilityLevel.values.sample
} }
......
...@@ -2,9 +2,9 @@ Gitlab::Seeder.quiet do ...@@ -2,9 +2,9 @@ Gitlab::Seeder.quiet do
(2..20).each do |i| (2..20).each do |i|
begin begin
User.create!( User.create!(
username: Faker::Internet.user_name, username: FFaker::Internet.user_name,
name: Faker::Name.name, name: FFaker::Name.name,
email: Faker::Internet.email, email: FFaker::Internet.email,
confirmed_at: DateTime.now, confirmed_at: DateTime.now,
password: '12345678' password: '12345678'
) )
......
...@@ -3,7 +3,7 @@ Gitlab::Seeder.quiet do ...@@ -3,7 +3,7 @@ Gitlab::Seeder.quiet do
(1..5).each do |i| (1..5).each do |i|
milestone_params = { milestone_params = {
title: "v#{i}.0", title: "v#{i}.0",
description: Faker::Lorem.sentence, description: FFaker::Lorem.sentence,
state: ['opened', 'closed'].sample, state: ['opened', 'closed'].sample,
} }
......
...@@ -2,8 +2,8 @@ Gitlab::Seeder.quiet do ...@@ -2,8 +2,8 @@ Gitlab::Seeder.quiet do
Project.all.each do |project| Project.all.each do |project|
(1..10).each do |i| (1..10).each do |i|
issue_params = { issue_params = {
title: Faker::Lorem.sentence(6), title: FFaker::Lorem.sentence(6),
description: Faker::Lorem.sentence, description: FFaker::Lorem.sentence,
state: ['opened', 'closed'].sample, state: ['opened', 'closed'].sample,
milestone: project.milestones.sample, milestone: project.milestones.sample,
assignee: project.team.users.sample assignee: project.team.users.sample
......
...@@ -10,8 +10,8 @@ Gitlab::Seeder.quiet do ...@@ -10,8 +10,8 @@ Gitlab::Seeder.quiet do
params = { params = {
source_branch: source_branch, source_branch: source_branch,
target_branch: target_branch, target_branch: target_branch,
title: Faker::Lorem.sentence(6), title: FFaker::Lorem.sentence(6),
description: Faker::Lorem.sentences(3).join(" "), description: FFaker::Lorem.sentences(3).join(" "),
milestone: project.milestones.sample, milestone: project.milestones.sample,
assignee: project.team.users.sample assignee: project.team.users.sample
} }
......
...@@ -28,8 +28,8 @@ eos ...@@ -28,8 +28,8 @@ eos
PersonalSnippet.seed(:id, [{ PersonalSnippet.seed(:id, [{
id: i, id: i,
author_id: user.id, author_id: user.id,
title: Faker::Lorem.sentence(3), title: FFaker::Lorem.sentence(3),
file_name: Faker::Internet.domain_word + '.rb', file_name: FFaker::Internet.domain_word + '.rb',
visibility_level: Gitlab::VisibilityLevel.values.sample, visibility_level: Gitlab::VisibilityLevel.values.sample,
content: content, content: content,
}]) }])
......
...@@ -6,7 +6,7 @@ Gitlab::Seeder.quiet do ...@@ -6,7 +6,7 @@ Gitlab::Seeder.quiet do
note_params = { note_params = {
noteable_type: 'Issue', noteable_type: 'Issue',
noteable_id: issue.id, noteable_id: issue.id,
note: Faker::Lorem.sentence, note: FFaker::Lorem.sentence,
} }
Notes::CreateService.new(project, user, note_params).execute Notes::CreateService.new(project, user, note_params).execute
...@@ -21,7 +21,7 @@ Gitlab::Seeder.quiet do ...@@ -21,7 +21,7 @@ Gitlab::Seeder.quiet do
note_params = { note_params = {
noteable_type: 'MergeRequest', noteable_type: 'MergeRequest',
noteable_id: mr.id, noteable_id: mr.id,
note: Faker::Lorem.sentence, note: FFaker::Lorem.sentence,
} }
Notes::CreateService.new(project, user, note_params).execute Notes::CreateService.new(project, user, note_params).execute
......
...@@ -23,7 +23,7 @@ class Spinach::Features::ProjectHooks < Spinach::FeatureSteps ...@@ -23,7 +23,7 @@ class Spinach::Features::ProjectHooks < Spinach::FeatureSteps
end end
step 'I submit new hook' do step 'I submit new hook' do
@url = Faker::Internet.uri("http") @url = FFaker::Internet.uri("http")
fill_in "hook_url", with: @url fill_in "hook_url", with: @url
expect { click_button "Add Web Hook" }.to change(ProjectHook, :count).by(1) expect { click_button "Add Web Hook" }.to change(ProjectHook, :count).by(1)
end end
......
...@@ -84,11 +84,11 @@ module Gitlab ...@@ -84,11 +84,11 @@ module Gitlab
# #
# Returns a Hash. # Returns a Hash.
def label_params(id, name) def label_params(id, name)
if id > 0 if name
{ id: id }
else
# TODO (rspeicher): Don't strip single quotes if we decide to only use double quotes for surrounding. # TODO (rspeicher): Don't strip single quotes if we decide to only use double quotes for surrounding.
{ name: name.tr('\'"', '') } { name: name.tr('\'"', '') }
else
{ id: id }
end end
end end
end end
......
...@@ -2,23 +2,23 @@ include ActionDispatch::TestProcess ...@@ -2,23 +2,23 @@ include ActionDispatch::TestProcess
FactoryGirl.define do FactoryGirl.define do
sequence :sentence, aliases: [:title, :content] do sequence :sentence, aliases: [:title, :content] do
Faker::Lorem.sentence FFaker::Lorem.sentence
end end
sequence :name do sequence :name do
Faker::Name.name FFaker::Name.name
end end
sequence :file_name do sequence :file_name do
Faker::Internet.user_name FFaker::Internet.user_name
end end
sequence(:url) { Faker::Internet.uri('http') } sequence(:url) { FFaker::Internet.uri('http') }
factory :user, aliases: [:author, :assignee, :owner, :creator] do factory :user, aliases: [:author, :assignee, :owner, :creator] do
email { Faker::Internet.email } email { FFaker::Internet.email }
name name
sequence(:username) { |n| "#{Faker::Internet.user_name}#{n}" } sequence(:username) { |n| "#{FFaker::Internet.user_name}#{n}" }
password "12345678" password "12345678"
confirmed_at { Time.now } confirmed_at { Time.now }
confirmation_token { nil } confirmation_token { nil }
...@@ -122,12 +122,12 @@ FactoryGirl.define do ...@@ -122,12 +122,12 @@ FactoryGirl.define do
factory :email do factory :email do
user user
email do email do
Faker::Internet.email('alias') FFaker::Internet.email('alias')
end end
factory :another_email do factory :another_email do
email do email do
Faker::Internet.email('another.alias') FFaker::Internet.email('another.alias')
end end
end end
end end
......
...@@ -26,7 +26,7 @@ describe "Admin::Hooks", feature: true do ...@@ -26,7 +26,7 @@ describe "Admin::Hooks", feature: true do
describe "New Hook" do describe "New Hook" do
before do before do
@url = Faker::Internet.uri("http") @url = FFaker::Internet.uri("http")
visit admin_hooks_path visit admin_hooks_path
fill_in "hook_url", with: @url fill_in "hook_url", with: @url
expect { click_button "Add System Hook" }.to change(SystemHook, :count).by(1) expect { click_button "Add System Hook" }.to change(SystemHook, :count).by(1)
......
require 'spec_helper' require 'spec_helper'
describe LabelsHelper do describe LabelsHelper do
it { expect(text_color_for_bg('#EEEEEE')).to eq('#333333') } describe 'link_to_label' do
it { expect(text_color_for_bg('#222E2E')).to eq('#FFFFFF') } let(:project) { create(:empty_project) }
let(:label) { create(:label, project: project) }
context 'with @project set' do
before do
@project = project
end
it 'uses the instance variable' do
expect(label).not_to receive(:project)
link_to_label(label)
end
end
context 'without @project set' do
it "uses the label's project" do
expect(label).to receive(:project).and_return(project)
link_to_label(label)
end
end
context 'with a named project argument' do
it 'uses the provided project' do
arg = double('project')
expect(arg).to receive(:namespace).and_return('foo')
expect(arg).to receive(:to_param).and_return('foo')
link_to_label(label, project: arg)
end
it 'takes precedence over other types' do
@project = project
expect(@project).not_to receive(:namespace)
expect(label).not_to receive(:project)
arg = double('project', namespace: 'foo', to_param: 'foo')
link_to_label(label, project: arg)
end
end
context 'with block' do
it 'passes the block to link_to' do
link = link_to_label(label) { 'Foo' }
expect(link).to match('Foo')
end
end
context 'without block' do
it 'uses render_colored_label as the link content' do
expect(self).to receive(:render_colored_label).
with(label).and_return('Foo')
expect(link_to_label(label)).to match('Foo')
end
end
end
describe 'text_color_for_bg' do
it 'uses light text on dark backgrounds' do
expect(text_color_for_bg('#222E2E')).to eq('#FFFFFF')
end
it 'uses dark text on light backgrounds' do
expect(text_color_for_bg('#EEEEEE')).to eq('#333333')
end
end
end end
...@@ -149,5 +149,12 @@ module Gitlab::Markdown ...@@ -149,5 +149,12 @@ module Gitlab::Markdown
end end
end end
end end
describe 'edge cases' do
it 'gracefully handles non-references matching the pattern' do
exp = act = '(format nil "~0f" 3.0) ; 3.0'
expect(filter(act).to_html).to eq exp
end
end
end end
end end
...@@ -185,7 +185,7 @@ describe Notify do ...@@ -185,7 +185,7 @@ describe Notify do
context 'for issues' do context 'for issues' do
let(:issue) { create(:issue, author: current_user, assignee: assignee, project: project) } let(:issue) { create(:issue, author: current_user, assignee: assignee, project: project) }
let(:issue_with_description) { create(:issue, author: current_user, assignee: assignee, project: project, description: Faker::Lorem.sentence) } let(:issue_with_description) { create(:issue, author: current_user, assignee: assignee, project: project, description: FFaker::Lorem.sentence) }
describe 'that are new' do describe 'that are new' do
subject { Notify.new_issue_email(issue.assignee_id, issue.id) } subject { Notify.new_issue_email(issue.assignee_id, issue.id) }
...@@ -273,7 +273,7 @@ describe Notify do ...@@ -273,7 +273,7 @@ describe Notify do
context 'for merge requests' do context 'for merge requests' do
let(:merge_author) { create(:user) } let(:merge_author) { create(:user) }
let(:merge_request) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project) } let(:merge_request) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project) }
let(:merge_request_with_description) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project, description: Faker::Lorem.sentence) } let(:merge_request_with_description) { create(:merge_request, author: current_user, assignee: assignee, source_project: project, target_project: project, description: FFaker::Lorem.sentence) }
describe 'that are new' do describe 'that are new' do
subject { Notify.new_merge_request_email(merge_request.assignee_id, merge_request.id) } subject { Notify.new_merge_request_email(merge_request.assignee_id, merge_request.id) }
......
...@@ -165,7 +165,7 @@ describe API::API, api: true do ...@@ -165,7 +165,7 @@ describe API::API, api: true do
it "should assign attributes to project" do it "should assign attributes to project" do
project = attributes_for(:project, { project = attributes_for(:project, {
path: 'camelCasePath', path: 'camelCasePath',
description: Faker::Lorem.sentence, description: FFaker::Lorem.sentence,
issues_enabled: false, issues_enabled: false,
merge_requests_enabled: false, merge_requests_enabled: false,
wiki_enabled: false wiki_enabled: false
...@@ -274,7 +274,7 @@ describe API::API, api: true do ...@@ -274,7 +274,7 @@ describe API::API, api: true do
it 'should assign attributes to project' do it 'should assign attributes to project' do
project = attributes_for(:project, { project = attributes_for(:project, {
description: Faker::Lorem.sentence, description: FFaker::Lorem.sentence,
issues_enabled: false, issues_enabled: false,
merge_requests_enabled: false, merge_requests_enabled: false,
wiki_enabled: false wiki_enabled: false
......
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