Commit b1b354b0f86daae9a2cf19869dd3e6cb2d9ffd5e

Authored by Andrey Kumanyaev
1 parent 67ccc8b5

remove trailing spaces

app/contexts/issues_bulk_update_context.rb
... ... @@ -7,7 +7,7 @@ class IssuesBulkUpdateContext < BaseContext
7 7 assignee_id = update_data[:assignee_id]
8 8 status = update_data[:status]
9 9  
10   - opts = {}
  10 + opts = {}
11 11 opts[:milestone_id] = milestone_id if milestone_id.present?
12 12 opts[:assignee_id] = assignee_id if assignee_id.present?
13 13 opts[:closed] = (status == "closed") if status.present?
... ... @@ -15,7 +15,7 @@ class IssuesBulkUpdateContext < BaseContext
15 15 issues = Issue.where(id: issues_ids).all
16 16 issues = issues.select { |issue| can?(current_user, :modify_issue, issue) }
17 17 issues.each { |issue| issue.update_attributes(opts) }
18   - {
  18 + {
19 19 count: issues.count,
20 20 success: !issues.count.zero?
21 21 }
... ...
app/models/milestone.rb
... ... @@ -72,9 +72,9 @@ class Milestone < ActiveRecord::Base
72 72 if due_date.past?
73 73 "expired at #{due_date.stamp("Aug 21, 2011")}"
74 74 else
75   - "expires at #{due_date.stamp("Aug 21, 2011")}"
  75 + "expires at #{due_date.stamp("Aug 21, 2011")}"
76 76 end
77   - end
  77 + end
78 78 end
79 79  
80 80 def can_be_closed?
... ...
lib/api.rb
... ... @@ -17,13 +17,13 @@ module Gitlab
17 17 message << exception.annoted_source_code.to_s if exception.respond_to?(:annoted_source_code)
18 18 message << " " << trace.join("\n ")
19 19  
20   - API.logger.add Logger::FATAL, message
  20 + API.logger.add Logger::FATAL, message
21 21 rack_response({'message' => '500 Internal Server Error'}, 500)
22 22 end
23 23  
24 24 format :json
25 25 helpers APIHelpers
26   -
  26 +
27 27 mount Groups
28 28 mount Users
29 29 mount Projects
... ...
lib/api/groups.rb
... ... @@ -70,7 +70,7 @@ module Gitlab
70 70 else
71 71 not_found!
72 72 end
73   - end
  73 + end
74 74 end
75 75 end
76 76 end
... ...
lib/api/system_hooks.rb
1   -module Gitlab
2   - # Hooks API
3   - class SystemHooks < Grape::API
4   - before {
5   - authenticate!
6   - authenticated_as_admin!
7   - }
8   -
9   - resource :hooks do
10   - # Get the list of system hooks
11   - #
12   - # Example Request:
13   - # GET /hooks
14   - get do
15   - @hooks = SystemHook.all
16   - present @hooks, with: Entities::Hook
17   - end
18   -
19   - # Create new system hook
20   - #
21   - # Parameters:
22   - # url (required) - url for system hook
23   - # Example Request
24   - # POST /hooks
25   - post do
26   - attrs = attributes_for_keys [:url]
27   - required_attributes! [:url]
28   - @hook = SystemHook.new attrs
29   - if @hook.save
30   - present @hook, with: Entities::Hook
31   - else
32   - not_found!
33   - end
34   - end
35   -
36   - # Test a hook
37   - #
38   - # Example Request
39   - # GET /hooks/:id
40   - get ":id" do
41   - @hook = SystemHook.find(params[:id])
42   - data = {
43   - event_name: "project_create",
44   - name: "Ruby",
45   - path: "ruby",
46   - project_id: 1,
47   - owner_name: "Someone",
48   - owner_email: "example@gitlabhq.com"
49   - }
50   - @hook.execute(data)
51   - data
52   - end
53   -
54   - # Delete a hook. This is an idempotent function.
55   - #
56   - # Parameters:
57   - # id (required) - ID of the hook
58   - # Example Request:
59   - # DELETE /hooks/:id
60   - delete ":id" do
61   - begin
62   - @hook = SystemHook.find(params[:id])
63   - @hook.destroy
64   - rescue
65   - # SystemHook raises an Error if no hook with id found
66   - end
67   - end
68   - end
69   - end
70   -end
71 1 \ No newline at end of file
  2 +module Gitlab
  3 + # Hooks API
  4 + class SystemHooks < Grape::API
  5 + before {
  6 + authenticate!
  7 + authenticated_as_admin!
  8 + }
  9 +
  10 + resource :hooks do
  11 + # Get the list of system hooks
  12 + #
  13 + # Example Request:
  14 + # GET /hooks
  15 + get do
  16 + @hooks = SystemHook.all
  17 + present @hooks, with: Entities::Hook
  18 + end
  19 +
  20 + # Create new system hook
  21 + #
  22 + # Parameters:
  23 + # url (required) - url for system hook
  24 + # Example Request
  25 + # POST /hooks
  26 + post do
  27 + attrs = attributes_for_keys [:url]
  28 + required_attributes! [:url]
  29 + @hook = SystemHook.new attrs
  30 + if @hook.save
  31 + present @hook, with: Entities::Hook
  32 + else
  33 + not_found!
  34 + end
  35 + end
  36 +
  37 + # Test a hook
  38 + #
  39 + # Example Request
  40 + # GET /hooks/:id
  41 + get ":id" do
  42 + @hook = SystemHook.find(params[:id])
  43 + data = {
  44 + event_name: "project_create",
  45 + name: "Ruby",
  46 + path: "ruby",
  47 + project_id: 1,
  48 + owner_name: "Someone",
  49 + owner_email: "example@gitlabhq.com"
  50 + }
  51 + @hook.execute(data)
  52 + data
  53 + end
  54 +
  55 + # Delete a hook. This is an idempotent function.
  56 + #
  57 + # Parameters:
  58 + # id (required) - ID of the hook
  59 + # Example Request:
  60 + # DELETE /hooks/:id
  61 + delete ":id" do
  62 + begin
  63 + @hook = SystemHook.find(params[:id])
  64 + @hook.destroy
  65 + rescue
  66 + # SystemHook raises an Error if no hook with id found
  67 + end
  68 + end
  69 + end
  70 + end
  71 +end
... ...
lib/gitlab/inline_diff.rb
... ... @@ -4,7 +4,7 @@ module Gitlab
4 4  
5 5 START = ""
6 6 FINISH = ""
7   -
  7 +
8 8 def processing diff_arr
9 9 indexes = _indexes_of_changed_lines diff_arr
10 10  
... ... @@ -60,7 +60,7 @@ module Gitlab
60 60 line.gsub!(FINISH, "</span>")
61 61 line
62 62 end
63   -
  63 +
64 64 end
65 65  
66 66 end
... ...
lib/tasks/gitlab/bulk_add_permission.rake
... ... @@ -21,4 +21,4 @@ namespace :gitlab do
21 21 UsersProject.add_users_into_projects(project_ids, Array.wrap(user.id), UsersProject::DEVELOPER)
22 22 end
23 23 end
24   -end
25 24 \ No newline at end of file
  25 +end
... ...
spec/models/merge_request_spec.rb
... ... @@ -36,7 +36,7 @@ describe MergeRequest do
36 36 it { should respond_to(:can_be_merged?) }
37 37 it { should respond_to(:cannot_be_merged?) }
38 38 end
39   -
  39 +
40 40 describe 'modules' do
41 41 it { should include_module(Issuable) }
42 42 end
... ...
spec/models/milestone_spec.rb
... ... @@ -134,7 +134,7 @@ describe Milestone do
134 134  
135 135 it 'should be false if milestone active and not all nestied issues closed' do
136 136 issue.milestone = milestone
137   - issue.save
  137 + issue.save
138 138  
139 139 milestone.can_be_closed?.should be_false
140 140 end
... ...
spec/requests/api/groups_spec.rb
... ... @@ -26,7 +26,7 @@ describe Gitlab::API do
26 26 json_response.first['name'].should == group1.name
27 27 end
28 28 end
29   -
  29 +
30 30 context "when authenticated as admin" do
31 31 it "admin: should return an array of all groups" do
32 32 get api("/groups", admin)
... ... @@ -36,7 +36,7 @@ describe Gitlab::API do
36 36 end
37 37 end
38 38 end
39   -
  39 +
40 40 describe "GET /groups/:id" do
41 41 context "when authenticated as user" do
42 42 it "should return one of user1's groups" do
... ... @@ -44,32 +44,32 @@ describe Gitlab::API do
44 44 response.status.should == 200
45 45 json_response['name'] == group1.name
46 46 end
47   -
  47 +
48 48 it "should not return a non existing group" do
49 49 get api("/groups/1328", user1)
50 50 response.status.should == 404
51 51 end
52   -
  52 +
53 53 it "should not return a group not attached to user1" do
54 54 get api("/groups/#{group2.id}", user1)
55 55 response.status.should == 404
56 56 end
57 57 end
58   -
  58 +
59 59 context "when authenticated as admin" do
60 60 it "should return any existing group" do
61 61 get api("/groups/#{group2.id}", admin)
62 62 response.status.should == 200
63 63 json_response['name'] == group2.name
64 64 end
65   -
  65 +
66 66 it "should not return a non existing group" do
67 67 get api("/groups/1328", admin)
68 68 response.status.should == 404
69 69 end
70 70 end
71 71 end
72   -
  72 +
73 73 describe "POST /groups" do
74 74 context "when authenticated as user" do
75 75 it "should not create group" do
... ... @@ -77,7 +77,7 @@ describe Gitlab::API do
77 77 response.status.should == 403
78 78 end
79 79 end
80   -
  80 +
81 81 context "when authenticated as admin" do
82 82 it "should create group" do
83 83 post api("/groups", admin), attributes_for(:group)
... ... @@ -104,8 +104,8 @@ describe Gitlab::API do
104 104 describe "POST /groups/:id/projects/:project_id" do
105 105 let(:project) { create(:project) }
106 106 before(:each) do
107   - project.stub!(:transfer).and_return(true)
108   - Project.stub(:find).and_return(project)
  107 + project.stub!(:transfer).and_return(true)
  108 + Project.stub(:find).and_return(project)
109 109 end
110 110  
111 111  
... ...
spec/requests/api/system_hooks_spec.rb
1   -require 'spec_helper'
2   -
3   -describe Gitlab::API do
4   - include ApiHelpers
5   -
6   - let(:user) { create(:user) }
7   - let(:admin) { create(:admin) }
8   - let!(:hook) { create(:system_hook, url: "http://example.com") }
9   -
10   - before { stub_request(:post, hook.url) }
11   -
12   - describe "GET /hooks" do
13   - context "when no user" do
14   - it "should return authentication error" do
15   - get api("/hooks")
16   - response.status.should == 401
17   - end
18   - end
19   -
20   - context "when not an admin" do
21   - it "should return forbidden error" do
22   - get api("/hooks", user)
23   - response.status.should == 403
24   - end
25   - end
26   -
27   - context "when authenticated as admin" do
28   - it "should return an array of hooks" do
29   - get api("/hooks", admin)
30   - response.status.should == 200
31   - json_response.should be_an Array
32   - json_response.first['url'].should == hook.url
33   - end
34   - end
35   - end
36   -
37   - describe "POST /hooks" do
38   - it "should create new hook" do
39   - expect {
40   - post api("/hooks", admin), url: 'http://example.com'
41   - }.to change { SystemHook.count }.by(1)
42   - end
43   -
44   - it "should respond with 400 if url not given" do
45   - post api("/hooks", admin)
46   - response.status.should == 400
47   - end
48   -
49   - it "should not create new hook without url" do
50   - expect {
51   - post api("/hooks", admin)
52   - }.to_not change { SystemHook.count }
53   - end
54   - end
55   -
56   - describe "GET /hooks/:id" do
57   - it "should return hook by id" do
58   - get api("/hooks/#{hook.id}", admin)
59   - response.status.should == 200
60   - json_response['event_name'].should == 'project_create'
61   - end
62   -
63   - it "should return 404 on failure" do
64   - get api("/hooks/404", admin)
65   - response.status.should == 404
66   - end
67   - end
68   -
69   - describe "DELETE /hooks/:id" do
70   - it "should delete a hook" do
71   - expect {
72   - delete api("/hooks/#{hook.id}", admin)
73   - }.to change { SystemHook.count }.by(-1)
74   - end
75   -
76   - it "should return success if hook id not found" do
77   - delete api("/hooks/12345", admin)
78   - response.status.should == 200
79   - end
80   - end
81   -end
82 1 \ No newline at end of file
  2 +require 'spec_helper'
  3 +
  4 +describe Gitlab::API do
  5 + include ApiHelpers
  6 +
  7 + let(:user) { create(:user) }
  8 + let(:admin) { create(:admin) }
  9 + let!(:hook) { create(:system_hook, url: "http://example.com") }
  10 +
  11 + before { stub_request(:post, hook.url) }
  12 +
  13 + describe "GET /hooks" do
  14 + context "when no user" do
  15 + it "should return authentication error" do
  16 + get api("/hooks")
  17 + response.status.should == 401
  18 + end
  19 + end
  20 +
  21 + context "when not an admin" do
  22 + it "should return forbidden error" do
  23 + get api("/hooks", user)
  24 + response.status.should == 403
  25 + end
  26 + end
  27 +
  28 + context "when authenticated as admin" do
  29 + it "should return an array of hooks" do
  30 + get api("/hooks", admin)
  31 + response.status.should == 200
  32 + json_response.should be_an Array
  33 + json_response.first['url'].should == hook.url
  34 + end
  35 + end
  36 + end
  37 +
  38 + describe "POST /hooks" do
  39 + it "should create new hook" do
  40 + expect {
  41 + post api("/hooks", admin), url: 'http://example.com'
  42 + }.to change { SystemHook.count }.by(1)
  43 + end
  44 +
  45 + it "should respond with 400 if url not given" do
  46 + post api("/hooks", admin)
  47 + response.status.should == 400
  48 + end
  49 +
  50 + it "should not create new hook without url" do
  51 + expect {
  52 + post api("/hooks", admin)
  53 + }.to_not change { SystemHook.count }
  54 + end
  55 + end
  56 +
  57 + describe "GET /hooks/:id" do
  58 + it "should return hook by id" do
  59 + get api("/hooks/#{hook.id}", admin)
  60 + response.status.should == 200
  61 + json_response['event_name'].should == 'project_create'
  62 + end
  63 +
  64 + it "should return 404 on failure" do
  65 + get api("/hooks/404", admin)
  66 + response.status.should == 404
  67 + end
  68 + end
  69 +
  70 + describe "DELETE /hooks/:id" do
  71 + it "should delete a hook" do
  72 + expect {
  73 + delete api("/hooks/#{hook.id}", admin)
  74 + }.to change { SystemHook.count }.by(-1)
  75 + end
  76 +
  77 + it "should return success if hook id not found" do
  78 + delete api("/hooks/12345", admin)
  79 + response.status.should == 200
  80 + end
  81 + end
  82 +end
... ...