remove trailing spaces
This commit is contained in:
parent
67ccc8b52a
commit
b1b354b0f8
11 changed files with 173 additions and 173 deletions
|
@ -7,7 +7,7 @@ class IssuesBulkUpdateContext < BaseContext
|
||||||
assignee_id = update_data[:assignee_id]
|
assignee_id = update_data[:assignee_id]
|
||||||
status = update_data[:status]
|
status = update_data[:status]
|
||||||
|
|
||||||
opts = {}
|
opts = {}
|
||||||
opts[:milestone_id] = milestone_id if milestone_id.present?
|
opts[:milestone_id] = milestone_id if milestone_id.present?
|
||||||
opts[:assignee_id] = assignee_id if assignee_id.present?
|
opts[:assignee_id] = assignee_id if assignee_id.present?
|
||||||
opts[:closed] = (status == "closed") if status.present?
|
opts[:closed] = (status == "closed") if status.present?
|
||||||
|
@ -15,7 +15,7 @@ class IssuesBulkUpdateContext < BaseContext
|
||||||
issues = Issue.where(id: issues_ids).all
|
issues = Issue.where(id: issues_ids).all
|
||||||
issues = issues.select { |issue| can?(current_user, :modify_issue, issue) }
|
issues = issues.select { |issue| can?(current_user, :modify_issue, issue) }
|
||||||
issues.each { |issue| issue.update_attributes(opts) }
|
issues.each { |issue| issue.update_attributes(opts) }
|
||||||
{
|
{
|
||||||
count: issues.count,
|
count: issues.count,
|
||||||
success: !issues.count.zero?
|
success: !issues.count.zero?
|
||||||
}
|
}
|
||||||
|
|
|
@ -72,9 +72,9 @@ class Milestone < ActiveRecord::Base
|
||||||
if due_date.past?
|
if due_date.past?
|
||||||
"expired at #{due_date.stamp("Aug 21, 2011")}"
|
"expired at #{due_date.stamp("Aug 21, 2011")}"
|
||||||
else
|
else
|
||||||
"expires at #{due_date.stamp("Aug 21, 2011")}"
|
"expires at #{due_date.stamp("Aug 21, 2011")}"
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
def can_be_closed?
|
def can_be_closed?
|
||||||
|
|
|
@ -17,13 +17,13 @@ module Gitlab
|
||||||
message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
|
message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
|
||||||
message << " " << trace.join("\n ")
|
message << " " << trace.join("\n ")
|
||||||
|
|
||||||
API.logger.add Logger::FATAL, message
|
API.logger.add Logger::FATAL, message
|
||||||
rack_response({'message' => '500 Internal Server Error'}, 500)
|
rack_response({'message' => '500 Internal Server Error'}, 500)
|
||||||
end
|
end
|
||||||
|
|
||||||
format :json
|
format :json
|
||||||
helpers APIHelpers
|
helpers APIHelpers
|
||||||
|
|
||||||
mount Groups
|
mount Groups
|
||||||
mount Users
|
mount Users
|
||||||
mount Projects
|
mount Projects
|
||||||
|
|
|
@ -70,7 +70,7 @@ module Gitlab
|
||||||
else
|
else
|
||||||
not_found!
|
not_found!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,70 +1,70 @@
|
||||||
module Gitlab
|
module Gitlab
|
||||||
# Hooks API
|
# Hooks API
|
||||||
class SystemHooks < Grape::API
|
class SystemHooks < Grape::API
|
||||||
before {
|
before {
|
||||||
authenticate!
|
authenticate!
|
||||||
authenticated_as_admin!
|
authenticated_as_admin!
|
||||||
}
|
}
|
||||||
|
|
||||||
resource :hooks do
|
resource :hooks do
|
||||||
# Get the list of system hooks
|
# Get the list of system hooks
|
||||||
#
|
#
|
||||||
# Example Request:
|
# Example Request:
|
||||||
# GET /hooks
|
# GET /hooks
|
||||||
get do
|
get do
|
||||||
@hooks = SystemHook.all
|
@hooks = SystemHook.all
|
||||||
present @hooks, with: Entities::Hook
|
present @hooks, with: Entities::Hook
|
||||||
end
|
end
|
||||||
|
|
||||||
# Create new system hook
|
# Create new system hook
|
||||||
#
|
#
|
||||||
# Parameters:
|
# Parameters:
|
||||||
# url (required) - url for system hook
|
# url (required) - url for system hook
|
||||||
# Example Request
|
# Example Request
|
||||||
# POST /hooks
|
# POST /hooks
|
||||||
post do
|
post do
|
||||||
attrs = attributes_for_keys [:url]
|
attrs = attributes_for_keys [:url]
|
||||||
required_attributes! [:url]
|
required_attributes! [:url]
|
||||||
@hook = SystemHook.new attrs
|
@hook = SystemHook.new attrs
|
||||||
if @hook.save
|
if @hook.save
|
||||||
present @hook, with: Entities::Hook
|
present @hook, with: Entities::Hook
|
||||||
else
|
else
|
||||||
not_found!
|
not_found!
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
# Test a hook
|
# Test a hook
|
||||||
#
|
#
|
||||||
# Example Request
|
# Example Request
|
||||||
# GET /hooks/:id
|
# GET /hooks/:id
|
||||||
get ":id" do
|
get ":id" do
|
||||||
@hook = SystemHook.find(params[:id])
|
@hook = SystemHook.find(params[:id])
|
||||||
data = {
|
data = {
|
||||||
event_name: "project_create",
|
event_name: "project_create",
|
||||||
name: "Ruby",
|
name: "Ruby",
|
||||||
path: "ruby",
|
path: "ruby",
|
||||||
project_id: 1,
|
project_id: 1,
|
||||||
owner_name: "Someone",
|
owner_name: "Someone",
|
||||||
owner_email: "example@gitlabhq.com"
|
owner_email: "example@gitlabhq.com"
|
||||||
}
|
}
|
||||||
@hook.execute(data)
|
@hook.execute(data)
|
||||||
data
|
data
|
||||||
end
|
end
|
||||||
|
|
||||||
# Delete a hook. This is an idempotent function.
|
# Delete a hook. This is an idempotent function.
|
||||||
#
|
#
|
||||||
# Parameters:
|
# Parameters:
|
||||||
# id (required) - ID of the hook
|
# id (required) - ID of the hook
|
||||||
# Example Request:
|
# Example Request:
|
||||||
# DELETE /hooks/:id
|
# DELETE /hooks/:id
|
||||||
delete ":id" do
|
delete ":id" do
|
||||||
begin
|
begin
|
||||||
@hook = SystemHook.find(params[:id])
|
@hook = SystemHook.find(params[:id])
|
||||||
@hook.destroy
|
@hook.destroy
|
||||||
rescue
|
rescue
|
||||||
# SystemHook raises an Error if no hook with id found
|
# SystemHook raises an Error if no hook with id found
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -4,7 +4,7 @@ module Gitlab
|
||||||
|
|
||||||
START = "#!idiff-start!#"
|
START = "#!idiff-start!#"
|
||||||
FINISH = "#!idiff-finish!#"
|
FINISH = "#!idiff-finish!#"
|
||||||
|
|
||||||
def processing diff_arr
|
def processing diff_arr
|
||||||
indexes = _indexes_of_changed_lines diff_arr
|
indexes = _indexes_of_changed_lines diff_arr
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ module Gitlab
|
||||||
line.gsub!(FINISH, "</span>")
|
line.gsub!(FINISH, "</span>")
|
||||||
line
|
line
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
@ -21,4 +21,4 @@ namespace :gitlab do
|
||||||
UsersProject.add_users_into_projects(project_ids, Array.wrap(user.id), UsersProject::DEVELOPER)
|
UsersProject.add_users_into_projects(project_ids, Array.wrap(user.id), UsersProject::DEVELOPER)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -36,7 +36,7 @@ describe MergeRequest do
|
||||||
it { should respond_to(:can_be_merged?) }
|
it { should respond_to(:can_be_merged?) }
|
||||||
it { should respond_to(:cannot_be_merged?) }
|
it { should respond_to(:cannot_be_merged?) }
|
||||||
end
|
end
|
||||||
|
|
||||||
describe 'modules' do
|
describe 'modules' do
|
||||||
it { should include_module(Issuable) }
|
it { should include_module(Issuable) }
|
||||||
end
|
end
|
||||||
|
|
|
@ -134,7 +134,7 @@ describe Milestone do
|
||||||
|
|
||||||
it 'should be false if milestone active and not all nestied issues closed' do
|
it 'should be false if milestone active and not all nestied issues closed' do
|
||||||
issue.milestone = milestone
|
issue.milestone = milestone
|
||||||
issue.save
|
issue.save
|
||||||
|
|
||||||
milestone.can_be_closed?.should be_false
|
milestone.can_be_closed?.should be_false
|
||||||
end
|
end
|
||||||
|
|
|
@ -26,7 +26,7 @@ describe Gitlab::API do
|
||||||
json_response.first['name'].should == group1.name
|
json_response.first['name'].should == group1.name
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when authenticated as admin" do
|
context "when authenticated as admin" do
|
||||||
it "admin: should return an array of all groups" do
|
it "admin: should return an array of all groups" do
|
||||||
get api("/groups", admin)
|
get api("/groups", admin)
|
||||||
|
@ -36,7 +36,7 @@ describe Gitlab::API do
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /groups/:id" do
|
describe "GET /groups/:id" do
|
||||||
context "when authenticated as user" do
|
context "when authenticated as user" do
|
||||||
it "should return one of user1's groups" do
|
it "should return one of user1's groups" do
|
||||||
|
@ -44,32 +44,32 @@ describe Gitlab::API do
|
||||||
response.status.should == 200
|
response.status.should == 200
|
||||||
json_response['name'] == group1.name
|
json_response['name'] == group1.name
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not return a non existing group" do
|
it "should not return a non existing group" do
|
||||||
get api("/groups/1328", user1)
|
get api("/groups/1328", user1)
|
||||||
response.status.should == 404
|
response.status.should == 404
|
||||||
end
|
end
|
||||||
|
|
||||||
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)
|
||||||
response.status.should == 404
|
response.status.should == 404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when authenticated as admin" do
|
context "when authenticated as admin" do
|
||||||
it "should return any existing group" do
|
it "should return any existing group" do
|
||||||
get api("/groups/#{group2.id}", admin)
|
get api("/groups/#{group2.id}", admin)
|
||||||
response.status.should == 200
|
response.status.should == 200
|
||||||
json_response['name'] == group2.name
|
json_response['name'] == group2.name
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not return a non existing group" do
|
it "should not return a non existing group" do
|
||||||
get api("/groups/1328", admin)
|
get api("/groups/1328", admin)
|
||||||
response.status.should == 404
|
response.status.should == 404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "POST /groups" do
|
describe "POST /groups" do
|
||||||
context "when authenticated as user" do
|
context "when authenticated as user" do
|
||||||
it "should not create group" do
|
it "should not create group" do
|
||||||
|
@ -77,7 +77,7 @@ describe Gitlab::API do
|
||||||
response.status.should == 403
|
response.status.should == 403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when authenticated as admin" do
|
context "when authenticated as admin" do
|
||||||
it "should create group" do
|
it "should create group" do
|
||||||
post api("/groups", admin), attributes_for(:group)
|
post api("/groups", admin), attributes_for(:group)
|
||||||
|
@ -104,8 +104,8 @@ describe Gitlab::API do
|
||||||
describe "POST /groups/:id/projects/:project_id" do
|
describe "POST /groups/:id/projects/:project_id" do
|
||||||
let(:project) { create(:project) }
|
let(:project) { create(:project) }
|
||||||
before(:each) do
|
before(:each) do
|
||||||
project.stub!(:transfer).and_return(true)
|
project.stub!(:transfer).and_return(true)
|
||||||
Project.stub(:find).and_return(project)
|
Project.stub(:find).and_return(project)
|
||||||
end
|
end
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -1,81 +1,81 @@
|
||||||
require 'spec_helper'
|
require 'spec_helper'
|
||||||
|
|
||||||
describe Gitlab::API do
|
describe Gitlab::API do
|
||||||
include ApiHelpers
|
include ApiHelpers
|
||||||
|
|
||||||
let(:user) { create(:user) }
|
let(:user) { create(:user) }
|
||||||
let(:admin) { create(:admin) }
|
let(:admin) { create(:admin) }
|
||||||
let!(:hook) { create(:system_hook, url: "http://example.com") }
|
let!(:hook) { create(:system_hook, url: "http://example.com") }
|
||||||
|
|
||||||
before { stub_request(:post, hook.url) }
|
before { stub_request(:post, hook.url) }
|
||||||
|
|
||||||
describe "GET /hooks" do
|
describe "GET /hooks" do
|
||||||
context "when no user" do
|
context "when no user" do
|
||||||
it "should return authentication error" do
|
it "should return authentication error" do
|
||||||
get api("/hooks")
|
get api("/hooks")
|
||||||
response.status.should == 401
|
response.status.should == 401
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when not an admin" do
|
context "when not an admin" do
|
||||||
it "should return forbidden error" do
|
it "should return forbidden error" do
|
||||||
get api("/hooks", user)
|
get api("/hooks", user)
|
||||||
response.status.should == 403
|
response.status.should == 403
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
context "when authenticated as admin" do
|
context "when authenticated as admin" do
|
||||||
it "should return an array of hooks" do
|
it "should return an array of hooks" do
|
||||||
get api("/hooks", admin)
|
get api("/hooks", admin)
|
||||||
response.status.should == 200
|
response.status.should == 200
|
||||||
json_response.should be_an Array
|
json_response.should be_an Array
|
||||||
json_response.first['url'].should == hook.url
|
json_response.first['url'].should == hook.url
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "POST /hooks" do
|
describe "POST /hooks" do
|
||||||
it "should create new hook" do
|
it "should create new hook" do
|
||||||
expect {
|
expect {
|
||||||
post api("/hooks", admin), url: 'http://example.com'
|
post api("/hooks", admin), url: 'http://example.com'
|
||||||
}.to change { SystemHook.count }.by(1)
|
}.to change { SystemHook.count }.by(1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should respond with 400 if url not given" do
|
it "should respond with 400 if url not given" do
|
||||||
post api("/hooks", admin)
|
post api("/hooks", admin)
|
||||||
response.status.should == 400
|
response.status.should == 400
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should not create new hook without url" do
|
it "should not create new hook without url" do
|
||||||
expect {
|
expect {
|
||||||
post api("/hooks", admin)
|
post api("/hooks", admin)
|
||||||
}.to_not change { SystemHook.count }
|
}.to_not change { SystemHook.count }
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "GET /hooks/:id" do
|
describe "GET /hooks/:id" do
|
||||||
it "should return hook by id" do
|
it "should return hook by id" do
|
||||||
get api("/hooks/#{hook.id}", admin)
|
get api("/hooks/#{hook.id}", admin)
|
||||||
response.status.should == 200
|
response.status.should == 200
|
||||||
json_response['event_name'].should == 'project_create'
|
json_response['event_name'].should == 'project_create'
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return 404 on failure" do
|
it "should return 404 on failure" do
|
||||||
get api("/hooks/404", admin)
|
get api("/hooks/404", admin)
|
||||||
response.status.should == 404
|
response.status.should == 404
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
||||||
describe "DELETE /hooks/:id" do
|
describe "DELETE /hooks/:id" do
|
||||||
it "should delete a hook" do
|
it "should delete a hook" do
|
||||||
expect {
|
expect {
|
||||||
delete api("/hooks/#{hook.id}", admin)
|
delete api("/hooks/#{hook.id}", admin)
|
||||||
}.to change { SystemHook.count }.by(-1)
|
}.to change { SystemHook.count }.by(-1)
|
||||||
end
|
end
|
||||||
|
|
||||||
it "should return success if hook id not found" do
|
it "should return success if hook id not found" do
|
||||||
delete api("/hooks/12345", admin)
|
delete api("/hooks/12345", admin)
|
||||||
response.status.should == 200
|
response.status.should == 200
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in a new issue