From b1b354b0f86daae9a2cf19869dd3e6cb2d9ffd5e Mon Sep 17 00:00:00 2001 From: Andrey Kumanyaev Date: Thu, 21 Mar 2013 01:46:30 +0400 Subject: [PATCH] remove trailing spaces --- app/contexts/issues_bulk_update_context.rb | 4 ++-- app/models/milestone.rb | 4 ++-- lib/api.rb | 4 ++-- lib/api/groups.rb | 2 +- lib/api/system_hooks.rb | 140 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++---------------------------------------------------------------------- lib/gitlab/inline_diff.rb | 4 ++-- lib/tasks/gitlab/bulk_add_permission.rake | 2 +- spec/models/merge_request_spec.rb | 2 +- spec/models/milestone_spec.rb | 2 +- spec/requests/api/groups_spec.rb | 20 ++++++++++---------- spec/requests/api/system_hooks_spec.rb | 162 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++--------------------------------------------------------------------------------- 11 files changed, 173 insertions(+), 173 deletions(-) diff --git a/app/contexts/issues_bulk_update_context.rb b/app/contexts/issues_bulk_update_context.rb index 7c3c1d4..7981259 100644 --- a/app/contexts/issues_bulk_update_context.rb +++ b/app/contexts/issues_bulk_update_context.rb @@ -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? } diff --git a/app/models/milestone.rb b/app/models/milestone.rb index 759f353..023b8dd 100644 --- a/app/models/milestone.rb +++ b/app/models/milestone.rb @@ -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? diff --git a/lib/api.rb b/lib/api.rb index d241f9b..082769d 100644 --- a/lib/api.rb +++ b/lib/api.rb @@ -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 diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 52fa8ef..efdbeb1 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -70,7 +70,7 @@ module Gitlab else not_found! end - end + end end end end diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb index da0b005..9e3574e 100644 --- a/lib/api/system_hooks.rb +++ b/lib/api/system_hooks.rb @@ -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 \ No newline at end of file +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 diff --git a/lib/gitlab/inline_diff.rb b/lib/gitlab/inline_diff.rb index 7a0a321..b39fd0d 100644 --- a/lib/gitlab/inline_diff.rb +++ b/lib/gitlab/inline_diff.rb @@ -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, "") line end - + end end diff --git a/lib/tasks/gitlab/bulk_add_permission.rake b/lib/tasks/gitlab/bulk_add_permission.rake index d8e2316..c270232 100644 --- a/lib/tasks/gitlab/bulk_add_permission.rake +++ b/lib/tasks/gitlab/bulk_add_permission.rake @@ -21,4 +21,4 @@ namespace :gitlab do UsersProject.add_users_into_projects(project_ids, Array.wrap(user.id), UsersProject::DEVELOPER) end end -end \ No newline at end of file +end diff --git a/spec/models/merge_request_spec.rb b/spec/models/merge_request_spec.rb index c64c053..a466080 100644 --- a/spec/models/merge_request_spec.rb +++ b/spec/models/merge_request_spec.rb @@ -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 diff --git a/spec/models/milestone_spec.rb b/spec/models/milestone_spec.rb index f74fea0..efab551 100644 --- a/spec/models/milestone_spec.rb +++ b/spec/models/milestone_spec.rb @@ -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 diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 3719983..cf284b6 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -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 diff --git a/spec/requests/api/system_hooks_spec.rb b/spec/requests/api/system_hooks_spec.rb index fe1b324..647e31c 100644 --- a/spec/requests/api/system_hooks_spec.rb +++ b/spec/requests/api/system_hooks_spec.rb @@ -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 \ No newline at end of file +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 -- libgit2 0.21.2