remove trailing spaces

This commit is contained in:
Andrey Kumanyaev 2013-03-21 01:46:30 +04:00
parent 67ccc8b52a
commit b1b354b0f8
11 changed files with 173 additions and 173 deletions

View file

@ -7,7 +7,7 @@ class IssuesBulkUpdateContext < BaseContext
assignee_id = update_data[:assignee_id]
status = update_data[:status]
opts = {}
opts = {}
opts[:milestone_id] = milestone_id if milestone_id.present?
opts[:assignee_id] = assignee_id if assignee_id.present?
opts[:closed] = (status == "closed") if status.present?
@ -15,7 +15,7 @@ class IssuesBulkUpdateContext < BaseContext
issues = Issue.where(id: issues_ids).all
issues = issues.select { |issue| can?(current_user, :modify_issue, issue) }
issues.each { |issue| issue.update_attributes(opts) }
{
{
count: issues.count,
success: !issues.count.zero?
}

View file

@ -72,9 +72,9 @@ class Milestone < ActiveRecord::Base
if due_date.past?
"expired at #{due_date.stamp("Aug 21, 2011")}"
else
"expires at #{due_date.stamp("Aug 21, 2011")}"
"expires at #{due_date.stamp("Aug 21, 2011")}"
end
end
end
end
def can_be_closed?

View file

@ -17,13 +17,13 @@ module Gitlab
message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
message << " " << trace.join("\n ")
API.logger.add Logger::FATAL, message
API.logger.add Logger::FATAL, message
rack_response({'message' => '500 Internal Server Error'}, 500)
end
format :json
helpers APIHelpers
mount Groups
mount Users
mount Projects

View file

@ -70,7 +70,7 @@ module Gitlab
else
not_found!
end
end
end
end
end
end

View file

@ -1,70 +1,70 @@
module Gitlab
# Hooks API
class SystemHooks < Grape::API
before {
authenticate!
authenticated_as_admin!
}
resource :hooks do
# Get the list of system hooks
#
# Example Request:
# GET /hooks
get do
@hooks = SystemHook.all
present @hooks, with: Entities::Hook
end
# Create new system hook
#
# Parameters:
# url (required) - url for system hook
# Example Request
# POST /hooks
post do
attrs = attributes_for_keys [:url]
required_attributes! [:url]
@hook = SystemHook.new attrs
if @hook.save
present @hook, with: Entities::Hook
else
not_found!
end
end
# Test a hook
#
# Example Request
# GET /hooks/:id
get ":id" do
@hook = SystemHook.find(params[:id])
data = {
event_name: "project_create",
name: "Ruby",
path: "ruby",
project_id: 1,
owner_name: "Someone",
owner_email: "example@gitlabhq.com"
}
@hook.execute(data)
data
end
# Delete a hook. This is an idempotent function.
#
# Parameters:
# id (required) - ID of the hook
# Example Request:
# DELETE /hooks/:id
delete ":id" do
begin
@hook = SystemHook.find(params[:id])
@hook.destroy
rescue
# SystemHook raises an Error if no hook with id found
end
end
end
end
end
module Gitlab
# Hooks API
class SystemHooks < Grape::API
before {
authenticate!
authenticated_as_admin!
}
resource :hooks do
# Get the list of system hooks
#
# Example Request:
# GET /hooks
get do
@hooks = SystemHook.all
present @hooks, with: Entities::Hook
end
# Create new system hook
#
# Parameters:
# url (required) - url for system hook
# Example Request
# POST /hooks
post do
attrs = attributes_for_keys [:url]
required_attributes! [:url]
@hook = SystemHook.new attrs
if @hook.save
present @hook, with: Entities::Hook
else
not_found!
end
end
# Test a hook
#
# Example Request
# GET /hooks/:id
get ":id" do
@hook = SystemHook.find(params[:id])
data = {
event_name: "project_create",
name: "Ruby",
path: "ruby",
project_id: 1,
owner_name: "Someone",
owner_email: "example@gitlabhq.com"
}
@hook.execute(data)
data
end
# Delete a hook. This is an idempotent function.
#
# Parameters:
# id (required) - ID of the hook
# Example Request:
# DELETE /hooks/:id
delete ":id" do
begin
@hook = SystemHook.find(params[:id])
@hook.destroy
rescue
# SystemHook raises an Error if no hook with id found
end
end
end
end
end

View file

@ -4,7 +4,7 @@ module Gitlab
START = "#!idiff-start!#"
FINISH = "#!idiff-finish!#"
def processing diff_arr
indexes = _indexes_of_changed_lines diff_arr
@ -60,7 +60,7 @@ module Gitlab
line.gsub!(FINISH, "</span>")
line
end
end
end

View file

@ -21,4 +21,4 @@ namespace :gitlab do
UsersProject.add_users_into_projects(project_ids, Array.wrap(user.id), UsersProject::DEVELOPER)
end
end
end
end

View file

@ -36,7 +36,7 @@ describe MergeRequest do
it { should respond_to(:can_be_merged?) }
it { should respond_to(:cannot_be_merged?) }
end
describe 'modules' do
it { should include_module(Issuable) }
end

View file

@ -134,7 +134,7 @@ describe Milestone do
it 'should be false if milestone active and not all nestied issues closed' do
issue.milestone = milestone
issue.save
issue.save
milestone.can_be_closed?.should be_false
end

View file

@ -26,7 +26,7 @@ describe Gitlab::API do
json_response.first['name'].should == group1.name
end
end
context "when authenticated as admin" do
it "admin: should return an array of all groups" do
get api("/groups", admin)
@ -36,7 +36,7 @@ describe Gitlab::API do
end
end
end
describe "GET /groups/:id" do
context "when authenticated as user" do
it "should return one of user1's groups" do
@ -44,32 +44,32 @@ describe Gitlab::API do
response.status.should == 200
json_response['name'] == group1.name
end
it "should not return a non existing group" do
get api("/groups/1328", user1)
response.status.should == 404
end
it "should not return a group not attached to user1" do
get api("/groups/#{group2.id}", user1)
response.status.should == 404
end
end
context "when authenticated as admin" do
it "should return any existing group" do
get api("/groups/#{group2.id}", admin)
response.status.should == 200
json_response['name'] == group2.name
end
it "should not return a non existing group" do
get api("/groups/1328", admin)
response.status.should == 404
end
end
end
describe "POST /groups" do
context "when authenticated as user" do
it "should not create group" do
@ -77,7 +77,7 @@ describe Gitlab::API do
response.status.should == 403
end
end
context "when authenticated as admin" do
it "should create group" do
post api("/groups", admin), attributes_for(:group)
@ -104,8 +104,8 @@ describe Gitlab::API do
describe "POST /groups/:id/projects/:project_id" do
let(:project) { create(:project) }
before(:each) do
project.stub!(:transfer).and_return(true)
Project.stub(:find).and_return(project)
project.stub!(:transfer).and_return(true)
Project.stub(:find).and_return(project)
end

View file

@ -1,81 +1,81 @@
require 'spec_helper'
describe Gitlab::API do
include ApiHelpers
let(:user) { create(:user) }
let(:admin) { create(:admin) }
let!(:hook) { create(:system_hook, url: "http://example.com") }
before { stub_request(:post, hook.url) }
describe "GET /hooks" do
context "when no user" do
it "should return authentication error" do
get api("/hooks")
response.status.should == 401
end
end
context "when not an admin" do
it "should return forbidden error" do
get api("/hooks", user)
response.status.should == 403
end
end
context "when authenticated as admin" do
it "should return an array of hooks" do
get api("/hooks", admin)
response.status.should == 200
json_response.should be_an Array
json_response.first['url'].should == hook.url
end
end
end
describe "POST /hooks" do
it "should create new hook" do
expect {
post api("/hooks", admin), url: 'http://example.com'
}.to change { SystemHook.count }.by(1)
end
it "should respond with 400 if url not given" do
post api("/hooks", admin)
response.status.should == 400
end
it "should not create new hook without url" do
expect {
post api("/hooks", admin)
}.to_not change { SystemHook.count }
end
end
describe "GET /hooks/:id" do
it "should return hook by id" do
get api("/hooks/#{hook.id}", admin)
response.status.should == 200
json_response['event_name'].should == 'project_create'
end
it "should return 404 on failure" do
get api("/hooks/404", admin)
response.status.should == 404
end
end
describe "DELETE /hooks/:id" do
it "should delete a hook" do
expect {
delete api("/hooks/#{hook.id}", admin)
}.to change { SystemHook.count }.by(-1)
end
it "should return success if hook id not found" do
delete api("/hooks/12345", admin)
response.status.should == 200
end
end
end
require 'spec_helper'
describe Gitlab::API do
include ApiHelpers
let(:user) { create(:user) }
let(:admin) { create(:admin) }
let!(:hook) { create(:system_hook, url: "http://example.com") }
before { stub_request(:post, hook.url) }
describe "GET /hooks" do
context "when no user" do
it "should return authentication error" do
get api("/hooks")
response.status.should == 401
end
end
context "when not an admin" do
it "should return forbidden error" do
get api("/hooks", user)
response.status.should == 403
end
end
context "when authenticated as admin" do
it "should return an array of hooks" do
get api("/hooks", admin)
response.status.should == 200
json_response.should be_an Array
json_response.first['url'].should == hook.url
end
end
end
describe "POST /hooks" do
it "should create new hook" do
expect {
post api("/hooks", admin), url: 'http://example.com'
}.to change { SystemHook.count }.by(1)
end
it "should respond with 400 if url not given" do
post api("/hooks", admin)
response.status.should == 400
end
it "should not create new hook without url" do
expect {
post api("/hooks", admin)
}.to_not change { SystemHook.count }
end
end
describe "GET /hooks/:id" do
it "should return hook by id" do
get api("/hooks/#{hook.id}", admin)
response.status.should == 200
json_response['event_name'].should == 'project_create'
end
it "should return 404 on failure" do
get api("/hooks/404", admin)
response.status.should == 404
end
end
describe "DELETE /hooks/:id" do
it "should delete a hook" do
expect {
delete api("/hooks/#{hook.id}", admin)
}.to change { SystemHook.count }.by(-1)
end
it "should return success if hook id not found" do
delete api("/hooks/12345", admin)
response.status.should == 200
end
end
end