Commit d99594273d57b2d5ed7c748b3185712960b89478
1 parent
128f2845
Exists in
master
and in
4 other branches
Style changes from review with @randx
-Some changes around calling origional methods for !for_fork? merge requests. Other changes to follow Change-Id: I009c716ce2475b9efa3fd07aee9215fca7a1c150
Showing
26 changed files
with
153 additions
and
163 deletions
Show diff stats
app/contexts/filter_context.rb
... | ... | @@ -20,12 +20,12 @@ class FilterContext |
20 | 20 | end |
21 | 21 | |
22 | 22 | case params[:status] |
23 | - when 'closed' | |
24 | - items.closed | |
25 | - when 'all' | |
26 | - items | |
27 | - else | |
28 | - items.opened | |
23 | + when 'closed' | |
24 | + items.closed | |
25 | + when 'all' | |
26 | + items | |
27 | + else | |
28 | + items.opened | |
29 | 29 | end |
30 | 30 | end |
31 | 31 | end | ... | ... |
app/controllers/projects/merge_requests_controller.rb
... | ... | @@ -124,7 +124,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController |
124 | 124 | @target_branches |
125 | 125 | end |
126 | 126 | |
127 | - | |
128 | 127 | def ci_status |
129 | 128 | status = project.gitlab_ci_service.commit_status(merge_request.last_commit.sha) |
130 | 129 | response = {status: status} |
... | ... | @@ -134,12 +133,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController |
134 | 133 | |
135 | 134 | protected |
136 | 135 | |
137 | - | |
138 | 136 | def selected_target_project |
139 | 137 | ((@project.id.to_s == params[:target_project_id]) || @project.forked_project_link.nil?) ? @project : @project.forked_project_link.forked_from_project |
140 | 138 | end |
141 | 139 | |
142 | - | |
143 | 140 | def merge_request |
144 | 141 | @merge_request ||= MergeRequest.find_by_id(params[:id]) |
145 | 142 | end | ... | ... |
app/helpers/merge_requests_helper.rb
1 | 1 | module MergeRequestsHelper |
2 | 2 | def new_mr_path_from_push_event(event) |
3 | 3 | new_project_merge_request_path( |
4 | - event.project, | |
5 | - new_mr_from_push_event(event, event.project) | |
4 | + event.project, | |
5 | + new_mr_from_push_event(event, event.project) | |
6 | 6 | ) |
7 | 7 | end |
8 | 8 | |
9 | 9 | def new_mr_path_for_fork_from_push_event(event) |
10 | 10 | new_project_merge_request_path( |
11 | - event.project, | |
12 | - new_mr_from_push_event(event, event.project.forked_from_project) | |
11 | + event.project, | |
12 | + new_mr_from_push_event(event, event.project.forked_from_project) | |
13 | 13 | ) |
14 | 14 | end |
15 | 15 | |
16 | - | |
17 | 16 | def new_mr_from_push_event(event, target_project) |
18 | 17 | return :merge_request => { |
19 | - source_project_id: event.project.id, | |
20 | - target_project_id: target_project.id, | |
21 | - source_branch: event.branch_name, | |
22 | - target_branch: target_project.repository.root_ref, | |
23 | - title: event.branch_name.titleize | |
18 | + source_project_id: event.project.id, | |
19 | + target_project_id: target_project.id, | |
20 | + source_branch: event.branch_name, | |
21 | + target_branch: target_project.repository.root_ref, | |
22 | + title: event.branch_name.titleize | |
24 | 23 | } |
25 | 24 | end |
26 | 25 | ... | ... |
app/mailers/emails/merge_requests.rb
... | ... | @@ -2,7 +2,7 @@ module Emails |
2 | 2 | module MergeRequests |
3 | 3 | def new_merge_request_email(recipient_id, merge_request_id) |
4 | 4 | @merge_request = MergeRequest.find(merge_request_id) |
5 | - mail(to: @merge_request.assignee_email, subject: subject("new merge request !#{@merge_request.id}", @merge_request.title)) | |
5 | + mail(to: recipient(recipient_id), subject: subject("new merge request !#{@merge_request.id}", @merge_request.title)) | |
6 | 6 | end |
7 | 7 | |
8 | 8 | def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id) | ... | ... |
app/models/merge_request.rb
... | ... | @@ -26,8 +26,8 @@ class MergeRequest < ActiveRecord::Base |
26 | 26 | |
27 | 27 | include Issuable |
28 | 28 | |
29 | - belongs_to :target_project, :foreign_key => :target_project_id, class_name: "Project" | |
30 | - belongs_to :source_project, :foreign_key => :source_project_id, class_name: "Project" | |
29 | + belongs_to :target_project, foreign_key: :target_project_id, class_name: "Project" | |
30 | + belongs_to :source_project, foreign_key: :source_project_id, class_name: "Project" | |
31 | 31 | |
32 | 32 | attr_accessible :title, :assignee_id, :source_project_id, :source_branch, :target_project_id, :target_branch, :milestone_id, :author_id_of_changes, :state_event |
33 | 33 | |
... | ... | @@ -149,7 +149,11 @@ class MergeRequest < ActiveRecord::Base |
149 | 149 | end |
150 | 150 | |
151 | 151 | def unmerged_diffs |
152 | - diffs = Gitlab::Satellite::MergeAction.new(author, self).diffs_between_satellite | |
152 | + if for_fork? | |
153 | + diffs = Gitlab::Satellite::MergeAction.new(author, self).diffs_between_satellite | |
154 | + else | |
155 | + diffs = target_project.repository.diffs_between(source_branch, target_branch) | |
156 | + end | |
153 | 157 | diffs ||= [] |
154 | 158 | diffs |
155 | 159 | end |
... | ... | @@ -172,7 +176,7 @@ class MergeRequest < ActiveRecord::Base |
172 | 176 | |
173 | 177 | def probably_merged? |
174 | 178 | unmerged_commits.empty? && |
175 | - commits.any? && opened? | |
179 | + commits.any? && opened? | |
176 | 180 | end |
177 | 181 | |
178 | 182 | def reloaded_commits |
... | ... | @@ -185,11 +189,15 @@ class MergeRequest < ActiveRecord::Base |
185 | 189 | end |
186 | 190 | |
187 | 191 | def unmerged_commits |
188 | - commits = Gitlab::Satellite::MergeAction.new(self.author, self).commits_between | |
192 | + if for_fork? | |
193 | + commits = Gitlab::Satellite::MergeAction.new(self.author, self).commits_between | |
194 | + else | |
195 | + commits = target_project.repository.commits_between(self.target_branch, self.source_branch) | |
196 | + end | |
189 | 197 | if commits.present? |
190 | 198 | commits = Commit.decorate(commits). |
191 | - sort_by(&:created_at). | |
192 | - reverse | |
199 | + sort_by(&:created_at). | |
200 | + reverse | |
193 | 201 | end |
194 | 202 | commits |
195 | 203 | end | ... | ... |
app/models/note.rb
... | ... | @@ -32,8 +32,8 @@ class Note < ActiveRecord::Base |
32 | 32 | delegate :name, :email, to: :author, prefix: true |
33 | 33 | |
34 | 34 | validates :note, :project, presence: true |
35 | - validates :line_code, format: {with: /\A[a-z0-9]+_\d+_\d+\Z/}, allow_blank: true | |
36 | - validates :attachment, file_size: {maximum: 10.megabytes.to_i} | |
35 | + validates :line_code, format: { with: /\A[a-z0-9]+_\d+_\d+\Z/ }, allow_blank: true | |
36 | + validates :attachment, file_size: { maximum: 10.megabytes.to_i } | |
37 | 37 | |
38 | 38 | validates :noteable_id, presence: true, if: ->(n) { n.noteable_type.present? && n.noteable_type != 'Commit' } |
39 | 39 | validates :commit_id, presence: true, if: ->(n) { n.noteable_type == 'Commit' } |
... | ... | @@ -42,13 +42,13 @@ class Note < ActiveRecord::Base |
42 | 42 | |
43 | 43 | # Scopes |
44 | 44 | scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) } |
45 | - scope :inline, -> { where("line_code IS NOT NULL") } | |
46 | - scope :not_inline, -> { where(line_code: [nil, '']) } | |
45 | + scope :inline, ->{ where("line_code IS NOT NULL") } | |
46 | + scope :not_inline, ->{ where(line_code: [nil, '']) } | |
47 | 47 | |
48 | - scope :common, -> { where(noteable_type: ["", nil]) } | |
49 | - scope :fresh, -> { order("created_at ASC, id ASC") } | |
50 | - scope :inc_author_project, -> { includes(:project, :author) } | |
51 | - scope :inc_author, -> { includes(:author) } | |
48 | + scope :common, ->{ where(noteable_type: ["", nil]) } | |
49 | + scope :fresh, ->{ order("created_at ASC, id ASC") } | |
50 | + scope :inc_author_project, ->{ includes(:project, :author) } | |
51 | + scope :inc_author, ->{ includes(:author) } | |
52 | 52 | |
53 | 53 | def self.create_status_change_note(noteable, project, author, status) |
54 | 54 | create({ |
... | ... | @@ -61,8 +61,8 @@ class Note < ActiveRecord::Base |
61 | 61 | |
62 | 62 | def commit_author |
63 | 63 | @commit_author ||= |
64 | - project.users.find_by_email(noteable.author_email) || | |
65 | - project.users.find_by_name(noteable.author_name) | |
64 | + project.users.find_by_email(noteable.author_email) || | |
65 | + project.users.find_by_name(noteable.author_name) | |
66 | 66 | rescue |
67 | 67 | nil |
68 | 68 | end |
... | ... | @@ -97,8 +97,8 @@ class Note < ActiveRecord::Base |
97 | 97 | # otherwise false is returned |
98 | 98 | def downvote? |
99 | 99 | votable? && (note.start_with?('-1') || |
100 | - note.start_with?(':-1:') | |
101 | - ) | |
100 | + note.start_with?(':-1:') | |
101 | + ) | |
102 | 102 | end |
103 | 103 | |
104 | 104 | def for_commit? |
... | ... | @@ -146,8 +146,8 @@ class Note < ActiveRecord::Base |
146 | 146 | # otherwise false is returned |
147 | 147 | def upvote? |
148 | 148 | votable? && (note.start_with?('+1') || |
149 | - note.start_with?(':+1:') | |
150 | - ) | |
149 | + note.start_with?(':+1:') | |
150 | + ) | |
151 | 151 | end |
152 | 152 | |
153 | 153 | def votable? | ... | ... |
app/observers/merge_request_observer.rb
... | ... | @@ -2,8 +2,7 @@ class MergeRequestObserver < ActivityObserver |
2 | 2 | observe :merge_request |
3 | 3 | |
4 | 4 | def after_create(merge_request) |
5 | - event_author_id = merge_request.author_id | |
6 | - if event_author_id | |
5 | + if merge_request.author_id | |
7 | 6 | create_event(merge_request, Event.determine_action(merge_request)) |
8 | 7 | end |
9 | 8 | |
... | ... | @@ -24,11 +23,11 @@ class MergeRequestObserver < ActivityObserver |
24 | 23 | return true if merge_request.merge_event |
25 | 24 | |
26 | 25 | Event.create( |
27 | - project: merge_request.target_project, | |
28 | - target_id: merge_request.id, | |
29 | - target_type: merge_request.class.name, | |
30 | - action: Event::MERGED, | |
31 | - author_id: merge_request.author_id_of_changes | |
26 | + project: merge_request.target_project, | |
27 | + target_id: merge_request.id, | |
28 | + target_type: merge_request.class.name, | |
29 | + action: Event::MERGED, | |
30 | + author_id: merge_request.author_id_of_changes | |
32 | 31 | ) |
33 | 32 | end |
34 | 33 | |
... | ... | @@ -41,14 +40,13 @@ class MergeRequestObserver < ActivityObserver |
41 | 40 | notification.reassigned_merge_request(merge_request, current_user) if merge_request.is_being_reassigned? |
42 | 41 | end |
43 | 42 | |
44 | - | |
45 | 43 | def create_event(record, status) |
46 | 44 | Event.create( |
47 | - project: record.target_project, | |
48 | - target_id: record.id, | |
49 | - target_type: record.class.name, | |
50 | - action: status, | |
51 | - author_id: record.author_id | |
45 | + project: record.target_project, | |
46 | + target_id: record.id, | |
47 | + target_type: record.class.name, | |
48 | + action: status, | |
49 | + author_id: record.author_id | |
52 | 50 | ) |
53 | 51 | end |
54 | 52 | ... | ... |
app/services/notification_service.rb
... | ... | @@ -80,9 +80,7 @@ class NotificationService |
80 | 80 | # * project team members with notification level higher then Participating |
81 | 81 | # |
82 | 82 | def merge_mr(merge_request) |
83 | - recipients = reject_muted_users([merge_request.author, merge_request.assignee], merge_request.source_project) | |
84 | - recipients = recipients.concat(reject_muted_users([merge_request.author, merge_request.assignee], merge_request.target_project)) | |
85 | - recipients = recipients.concat(project_watchers(merge_request.source_project)) | |
83 | + recipients = reject_muted_users([merge_request.author, merge_request.assignee], merge_request.target_project) | |
86 | 84 | recipients = recipients.concat(project_watchers(merge_request.target_project)).uniq |
87 | 85 | |
88 | 86 | recipients.each do |recipient| |
... | ... | @@ -104,7 +102,7 @@ class NotificationService |
104 | 102 | # ignore wall messages |
105 | 103 | return true unless note.noteable_type.present? |
106 | 104 | |
107 | - opts = {noteable_type: note.noteable_type, project_id: note.project_id} | |
105 | + opts = { noteable_type: note.noteable_type, project_id: note.project_id } | |
108 | 106 | |
109 | 107 | if note.commit_id.present? |
110 | 108 | opts.merge!(commit_id: note.commit_id) | ... | ... |
app/views/projects/commits/_commits.html.haml
app/views/projects/merge_requests/_form.html.haml
1 | -= form_for [@source_project, @merge_request], html: { class: "#{controller.action_name}-merge-request form-horizontal" } do |form_helper| | |
1 | += form_for [@source_project, @merge_request], html: { class: "#{controller.action_name}-merge-request form-horizontal" } do |f| | |
2 | 2 | -if @merge_request.errors.any? |
3 | 3 | .alert.alert-error |
4 | 4 | %ul |
... | ... | @@ -51,9 +51,9 @@ |
51 | 51 | |
52 | 52 | .form-actions |
53 | 53 | - if @merge_request.new_record? |
54 | - = form_helper.submit 'Submit merge request', class: "btn btn-create" | |
54 | + = f.submit 'Submit merge request', class: "btn btn-create" | |
55 | 55 | -else |
56 | - = form_helper.submit 'Save changes', class: "btn btn-save" | |
56 | + = f.submit 'Save changes', class: "btn btn-save" | |
57 | 57 | - if @merge_request.new_record? |
58 | 58 | = link_to project_merge_requests_path(@source_project), class: "btn btn-cancel" do |
59 | 59 | Cancel | ... | ... |
app/views/projects/merge_requests/_merge_request.html.haml
... | ... | @@ -8,9 +8,14 @@ |
8 | 8 | = "MERGED" |
9 | 9 | - else |
10 | 10 | %span.pull-right |
11 | - = "#{merge_request.source_project.path_with_namespace}/#{merge_request.source_branch}" | |
12 | - %i.icon-angle-right | |
13 | - = "#{merge_request.target_project.path_with_namespace}/#{merge_request.target_branch}" | |
11 | + - if merge_request.for_fork? | |
12 | + = "#{merge_request.source_project.path_with_namespace}/#{merge_request.source_branch}" | |
13 | + %i.icon-angle-right | |
14 | + = "#{merge_request.target_project.path_with_namespace}/#{merge_request.target_branch}" | |
15 | + - else | |
16 | + = "#{merge_request.source_branch}" | |
17 | + %i.icon-angle-right | |
18 | + = "#{merge_request.target_branch}" | |
14 | 19 | .merge-request-info |
15 | 20 | - if merge_request.author |
16 | 21 | authored by #{link_to_member(merge_request.source_project, merge_request.author)} | ... | ... |
app/views/projects/merge_requests/show/_mr_title.html.haml
1 | 1 | %h3.page-title |
2 | 2 | = "Merge Request ##{@merge_request.id}:" |
3 | 3 | |
4 | - %span.label-project= @merge_request.source_project.path_with_namespace | |
5 | - %span.label-branch= @merge_request.source_branch | |
6 | - → | |
7 | - %span.label-project= @merge_request.target_project.path_with_namespace | |
8 | - %span.label-branch= @merge_request.target_branch | |
4 | + -if @merge_request.for_fork? | |
5 | + %span.label-project= @merge_request.source_project.path_with_namespace | |
6 | + %span.label-branch= @merge_request.source_branch | |
7 | + → | |
8 | + %span.label-project= @merge_request.target_project.path_with_namespace | |
9 | + %span.label-branch= @merge_request.target_branch | |
10 | + - else | |
11 | + %span.label-branch= @merge_request.source_branch | |
12 | + → | |
13 | + %span.label-branch= @merge_request.target_branch | |
9 | 14 | |
10 | 15 | %span.pull-right |
11 | 16 | - if can?(current_user, :modify_merge_request, @merge_request) | ... | ... |
app/views/search/_result.html.haml
... | ... | @@ -26,7 +26,10 @@ |
26 | 26 | %span ##{merge_request.id} |
27 | 27 | %strong.term |
28 | 28 | = truncate merge_request.title, length: 50 |
29 | - %span.light (#{merge_request.source_project.name_with_namespace}:#{merge_request.source_branch} → #{merge_request.target_project.name_with_namespace}:#{merge_request.target_branch}) | |
29 | + - if merge_request.for_fork? | |
30 | + %span.light (#{merge_request.source_project.name_with_namespace}:#{merge_request.source_branch} → #{merge_request.target_project.name_with_namespace}:#{merge_request.target_branch}) | |
31 | + - else | |
32 | + %span.light (#{merge_request.source_branch} → #{merge_request.target_branch}) | |
30 | 33 | - @issues.each do |issue| |
31 | 34 | %li |
32 | 35 | issue: | ... | ... |
db/migrate/20130419190306_allow_merges_for_forks.rb
... | ... | @@ -2,7 +2,7 @@ class AllowMergesForForks < ActiveRecord::Migration |
2 | 2 | |
3 | 3 | def self.up |
4 | 4 | add_column :merge_requests, :target_project_id, :integer, :null => false |
5 | - MergeRequest.connection.execute("update merge_requests set target_project_id=project_id") | |
5 | + MergeRequest.update_all("target_project_id = project_id") | |
6 | 6 | rename_column :merge_requests, :project_id, :source_project_id |
7 | 7 | end |
8 | 8 | ... | ... |
features/project/forked_merge_requests.feature
... | ... | @@ -20,7 +20,6 @@ Feature: Project Forked Merge Requests |
20 | 20 | And I submit the merge request |
21 | 21 | Then I should see merge request "Merge Request On Forked Project" |
22 | 22 | |
23 | - | |
24 | 23 | @javascript |
25 | 24 | Scenario: I should see a push widget for forked merge requests |
26 | 25 | Given project "Forked Shop" has push event |
... | ... | @@ -39,7 +38,6 @@ Feature: Project Forked Merge Requests |
39 | 38 | And I click link edit "Merge Request On Forked Project" |
40 | 39 | Then I see the edit page prefilled for "Merge Request On Forked Project" |
41 | 40 | |
42 | - | |
43 | 41 | @javascript |
44 | 42 | Scenario: I cannot submit an invalid merge request |
45 | 43 | Given I visit project "Forked Shop" merge requests page | ... | ... |
features/steps/project/project_forked_merge_requests.rb
... | ... | @@ -109,25 +109,25 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps |
109 | 109 | @forked_project = Project.find_by_name("Forked Shop") |
110 | 110 | |
111 | 111 | data = { |
112 | - before: "0000000000000000000000000000000000000000", | |
113 | - after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e", | |
114 | - ref: "refs/heads/new_design", | |
115 | - user_id: @user.id, | |
116 | - user_name: @user.name, | |
117 | - repository: { | |
118 | - name: @forked_project.name, | |
119 | - url: "localhost/rubinius", | |
120 | - description: "", | |
121 | - homepage: "localhost/rubinius", | |
122 | - private: true | |
123 | - } | |
112 | + before: "0000000000000000000000000000000000000000", | |
113 | + after: "0220c11b9a3e6c69dc8fd35321254ca9a7b98f7e", | |
114 | + ref: "refs/heads/new_design", | |
115 | + user_id: @user.id, | |
116 | + user_name: @user.name, | |
117 | + repository: { | |
118 | + name: @forked_project.name, | |
119 | + url: "localhost/rubinius", | |
120 | + description: "", | |
121 | + homepage: "localhost/rubinius", | |
122 | + private: true | |
123 | + } | |
124 | 124 | } |
125 | 125 | |
126 | 126 | @event = Event.create( |
127 | - project: @forked_project, | |
128 | - action: Event::PUSHED, | |
129 | - data: data, | |
130 | - author_id: @user.id | |
127 | + project: @forked_project, | |
128 | + action: Event::PUSHED, | |
129 | + data: data, | |
130 | + author_id: @user.id | |
131 | 131 | ) |
132 | 132 | end |
133 | 133 | ... | ... |
lib/gitlab/satellite/action.rb
1 | 1 | module Gitlab |
2 | 2 | module Satellite |
3 | 3 | class Action |
4 | - DEFAULT_OPTIONS = {git_timeout: 30.seconds} | |
4 | + DEFAULT_OPTIONS = { git_timeout: 30.seconds } | |
5 | 5 | |
6 | 6 | attr_accessor :options, :project, :user |
7 | 7 | |
... | ... | @@ -39,8 +39,8 @@ module Gitlab |
39 | 39 | def prepare_satellite!(repo) |
40 | 40 | project.satellite.clear_and_update! |
41 | 41 | |
42 | - repo.config['user.name']=user.name | |
43 | - repo.config['user.email']=user.email | |
42 | + repo.config['user.name'] = user.name | |
43 | + repo.config['user.email'] = user.email | |
44 | 44 | end |
45 | 45 | |
46 | 46 | def default_options(options = {}) | ... | ... |
lib/gitlab/satellite/satellite.rb
1 | 1 | module Gitlab |
2 | - class SatelliteNotExistError < StandardError; | |
3 | - end | |
2 | + class SatelliteNotExistError < StandardError; end | |
4 | 3 | |
5 | 4 | module Satellite |
6 | 5 | class Satellite |
... | ... | @@ -22,9 +21,9 @@ module Gitlab |
22 | 21 | raise SatelliteNotExistError.new("Satellite doesn't exist") |
23 | 22 | end |
24 | 23 | |
25 | - | |
26 | 24 | def clear_and_update! |
27 | 25 | raise_no_satellite unless exists? |
26 | + | |
28 | 27 | File.exists? path |
29 | 28 | @repo = nil |
30 | 29 | clear_working_dir! |
... | ... | @@ -68,7 +67,6 @@ module Gitlab |
68 | 67 | end |
69 | 68 | end |
70 | 69 | |
71 | - | |
72 | 70 | def lock_file |
73 | 71 | create_locks_dir unless File.exists?(lock_files_dir) |
74 | 72 | File.join(lock_files_dir, "satellite_#{project.id}.lock") | ... | ... |
spec/factories.rb
... | ... | @@ -117,9 +117,9 @@ FactoryGirl.define do |
117 | 117 | source_branch "stable" # pretend bcf03b5d |
118 | 118 | st_commits do |
119 | 119 | [ |
120 | - source_project.repository.commit('bcf03b5d').to_hash, | |
121 | - source_project.repository.commit('bcf03b5d~1').to_hash, | |
122 | - source_project.repository.commit('bcf03b5d~2').to_hash | |
120 | + source_project.repository.commit('bcf03b5d').to_hash, | |
121 | + source_project.repository.commit('bcf03b5d~1').to_hash, | |
122 | + source_project.repository.commit('bcf03b5d~2').to_hash | |
123 | 123 | ] |
124 | 124 | end |
125 | 125 | st_diffs do | ... | ... |
spec/factories_spec.rb
1 | 1 | require 'spec_helper' |
2 | 2 | |
3 | 3 | INVALID_FACTORIES = [ |
4 | - :key_with_a_space_in_the_middle, | |
5 | - :invalid_key, | |
4 | + :key_with_a_space_in_the_middle, | |
5 | + :invalid_key, | |
6 | 6 | ] |
7 | 7 | |
8 | 8 | FactoryGirl.factories.map(&:name).each do |factory_name| |
9 | 9 | next if INVALID_FACTORIES.include?(factory_name) |
10 | - | |
11 | 10 | describe "#{factory_name} factory" do |
12 | 11 | it 'should be valid' do |
13 | 12 | build(factory_name).should be_valid | ... | ... |
spec/features/security/project_access_spec.rb
spec/lib/gitlab/satellite/action_spec.rb
1 | 1 | require 'spec_helper' |
2 | 2 | |
3 | 3 | describe 'Gitlab::Satellite::Action' do |
4 | - | |
5 | - | |
6 | 4 | let(:project) { create(:project_with_code) } |
7 | 5 | let(:user) { create(:user) } |
8 | 6 | |
9 | - | |
10 | 7 | describe '#prepare_satellite!' do |
11 | 8 | |
12 | 9 | it 'create a repository with a parking branch and one remote: origin' do |
... | ... | @@ -50,11 +47,8 @@ describe 'Gitlab::Satellite::Action' do |
50 | 47 | repo.config['user.name'].should ==user.name |
51 | 48 | repo.config['user.email'].should ==user.email |
52 | 49 | end |
53 | - | |
54 | - | |
55 | 50 | end |
56 | 51 | |
57 | - | |
58 | 52 | describe '#in_locked_and_timed_satellite' do |
59 | 53 | |
60 | 54 | it 'should make use of a lockfile' do | ... | ... |
spec/lib/gitlab/satellite/merge_action_spec.rb
... | ... | @@ -11,7 +11,6 @@ describe 'Gitlab::Satellite::MergeAction' do |
11 | 11 | #these commits are quite close together, itended to make string diffs/format patches small |
12 | 12 | @close_commit1 = ['2_3_notes_fix', '8470d70da67355c9c009e4401746b1d5410af2e3'] |
13 | 13 | @close_commit2 = ['scss_refactoring', 'f0f14c8eaba69ebddd766498a9d0b0e79becd633'] |
14 | - | |
15 | 14 | end |
16 | 15 | |
17 | 16 | let(:project) { create(:project_with_code) } |
... | ... | @@ -53,7 +52,6 @@ describe 'Gitlab::Satellite::MergeAction' do |
53 | 52 | end |
54 | 53 | end |
55 | 54 | |
56 | - | |
57 | 55 | describe '#format_patch' do |
58 | 56 | context 'on fork' do |
59 | 57 | it 'should build a format patch' do |
... | ... | @@ -76,7 +74,6 @@ describe 'Gitlab::Satellite::MergeAction' do |
76 | 74 | end |
77 | 75 | end |
78 | 76 | |
79 | - | |
80 | 77 | describe '#diffs_between_satellite tested against diff_in_satellite' do |
81 | 78 | |
82 | 79 | def is_a_matching_diff(diff, diffs) |
... | ... | @@ -109,7 +106,6 @@ describe 'Gitlab::Satellite::MergeAction' do |
109 | 106 | merge_request.source_branch = @master[0] |
110 | 107 | diffs = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diffs_between_satellite |
111 | 108 | |
112 | - | |
113 | 109 | merge_request.target_branch = @close_commit1[0] |
114 | 110 | merge_request.source_branch = @master[0] |
115 | 111 | diff = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diff_in_satellite |
... | ... | @@ -119,7 +115,6 @@ describe 'Gitlab::Satellite::MergeAction' do |
119 | 115 | end |
120 | 116 | end |
121 | 117 | |
122 | - | |
123 | 118 | describe '#can_be_merged?' do |
124 | 119 | context 'on fork' do |
125 | 120 | it 'return true or false depending on if something is mergable' do |
... | ... | @@ -145,5 +140,4 @@ describe 'Gitlab::Satellite::MergeAction' do |
145 | 140 | end |
146 | 141 | end |
147 | 142 | end |
148 | - | |
149 | 143 | end |
150 | 144 | \ No newline at end of file | ... | ... |
spec/observers/merge_request_observer_spec.rb
spec/requests/api/projects_spec.rb
... | ... | @@ -15,8 +15,7 @@ describe API::API do |
15 | 15 | let!(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } |
16 | 16 | let!(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) } |
17 | 17 | |
18 | - before { | |
19 | - project.team << [user, :reporter] } | |
18 | + before { project.team << [user, :reporter] } | |
20 | 19 | |
21 | 20 | describe "GET /projects" do |
22 | 21 | context "when unauthenticated" do |
... | ... | @@ -48,16 +47,16 @@ describe API::API do |
48 | 47 | it "should not create new project" do |
49 | 48 | expect { |
50 | 49 | post api("/projects", user2), name: 'foo' |
51 | - }.to change { Project.count }.by(0) | |
50 | + }.to change {Project.count}.by(0) | |
52 | 51 | end |
53 | 52 | end |
54 | 53 | |
55 | 54 | it "should create new project without path" do |
56 | - expect { post api("/projects", user), name: 'foo' }.to change { Project.count }.by(1) | |
55 | + expect { post api("/projects", user), name: 'foo' }.to change {Project.count}.by(1) | |
57 | 56 | end |
58 | 57 | |
59 | 58 | it "should not create new project without name" do |
60 | - expect { post api("/projects", user) }.to_not change { Project.count } | |
59 | + expect { post api("/projects", user) }.to_not change {Project.count} | |
61 | 60 | end |
62 | 61 | |
63 | 62 | it "should return a 400 error if name not given" do |
... | ... | @@ -91,17 +90,17 @@ describe API::API do |
91 | 90 | |
92 | 91 | it "should assign attributes to project" do |
93 | 92 | project = attributes_for(:project, { |
94 | - description: Faker::Lorem.sentence, | |
95 | - default_branch: 'stable', | |
96 | - issues_enabled: false, | |
97 | - wall_enabled: false, | |
98 | - merge_requests_enabled: false, | |
99 | - wiki_enabled: false | |
93 | + description: Faker::Lorem.sentence, | |
94 | + default_branch: 'stable', | |
95 | + issues_enabled: false, | |
96 | + wall_enabled: false, | |
97 | + merge_requests_enabled: false, | |
98 | + wiki_enabled: false | |
100 | 99 | }) |
101 | 100 | |
102 | 101 | post api("/projects", user), project |
103 | 102 | |
104 | - project.each_pair do |k, v| | |
103 | + project.each_pair do |k,v| | |
105 | 104 | next if k == :path |
106 | 105 | json_response[k.to_s].should == v |
107 | 106 | end |
... | ... | @@ -127,11 +126,11 @@ describe API::API do |
127 | 126 | before { admin } |
128 | 127 | |
129 | 128 | it "should create new project without path" do |
130 | - expect { post api("/projects/user/#{user.id}", admin), name: 'foo' }.to change { Project.count }.by(1) | |
129 | + expect { post api("/projects/user/#{user.id}", admin), name: 'foo' }.to change {Project.count}.by(1) | |
131 | 130 | end |
132 | 131 | |
133 | 132 | it "should not create new project without name" do |
134 | - expect { post api("/projects/user/#{user.id}", admin) }.to_not change { Project.count } | |
133 | + expect { post api("/projects/user/#{user.id}", admin) }.to_not change {Project.count} | |
135 | 134 | end |
136 | 135 | |
137 | 136 | it "should respond with 201 on success" do |
... | ... | @@ -146,17 +145,17 @@ describe API::API do |
146 | 145 | |
147 | 146 | it "should assign attributes to project" do |
148 | 147 | project = attributes_for(:project, { |
149 | - description: Faker::Lorem.sentence, | |
150 | - default_branch: 'stable', | |
151 | - issues_enabled: false, | |
152 | - wall_enabled: false, | |
153 | - merge_requests_enabled: false, | |
154 | - wiki_enabled: false | |
148 | + description: Faker::Lorem.sentence, | |
149 | + default_branch: 'stable', | |
150 | + issues_enabled: false, | |
151 | + wall_enabled: false, | |
152 | + merge_requests_enabled: false, | |
153 | + wiki_enabled: false | |
155 | 154 | }) |
156 | 155 | |
157 | 156 | post api("/projects/user/#{user.id}", admin), project |
158 | 157 | |
159 | - project.each_pair do |k, v| | |
158 | + project.each_pair do |k,v| | |
160 | 159 | next if k == :path |
161 | 160 | json_response[k.to_s].should == v |
162 | 161 | end |
... | ... | @@ -269,7 +268,7 @@ describe API::API do |
269 | 268 | it "should add user to project team" do |
270 | 269 | expect { |
271 | 270 | post api("/projects/#{project.id}/members", user), user_id: user2.id, |
272 | - access_level: UsersProject::DEVELOPER | |
271 | + access_level: UsersProject::DEVELOPER | |
273 | 272 | }.to change { UsersProject.count }.by(1) |
274 | 273 | |
275 | 274 | response.status.should == 201 |
... | ... | @@ -279,10 +278,10 @@ describe API::API do |
279 | 278 | |
280 | 279 | it "should return a 201 status if user is already project member" do |
281 | 280 | post api("/projects/#{project.id}/members", user), user_id: user2.id, |
282 | - access_level: UsersProject::DEVELOPER | |
281 | + access_level: UsersProject::DEVELOPER | |
283 | 282 | expect { |
284 | 283 | post api("/projects/#{project.id}/members", user), user_id: user2.id, |
285 | - access_level: UsersProject::DEVELOPER | |
284 | + access_level: UsersProject::DEVELOPER | |
286 | 285 | }.not_to change { UsersProject.count }.by(1) |
287 | 286 | |
288 | 287 | response.status.should == 201 |
... | ... | @@ -413,8 +412,8 @@ describe API::API do |
413 | 412 | it "should add hook to project" do |
414 | 413 | expect { |
415 | 414 | post api("/projects/#{project.id}/hooks", user), |
416 | - url: "http://example.com" | |
417 | - }.to change { project.hooks.count }.by(1) | |
415 | + url: "http://example.com" | |
416 | + }.to change {project.hooks.count}.by(1) | |
418 | 417 | response.status.should == 201 |
419 | 418 | end |
420 | 419 | |
... | ... | @@ -432,7 +431,7 @@ describe API::API do |
432 | 431 | describe "PUT /projects/:id/hooks/:hook_id" do |
433 | 432 | it "should update an existing project hook" do |
434 | 433 | put api("/projects/#{project.id}/hooks/#{hook.id}", user), |
435 | - url: 'http://example.org' | |
434 | + url: 'http://example.org' | |
436 | 435 | response.status.should == 200 |
437 | 436 | json_response['url'].should == 'http://example.org' |
438 | 437 | end |
... | ... | @@ -457,7 +456,7 @@ describe API::API do |
457 | 456 | it "should delete hook from project" do |
458 | 457 | expect { |
459 | 458 | delete api("/projects/#{project.id}/hooks/#{hook.id}", user) |
460 | - }.to change { project.hooks.count }.by(-1) | |
459 | + }.to change {project.hooks.count}.by(-1) | |
461 | 460 | response.status.should == 200 |
462 | 461 | end |
463 | 462 | |
... | ... | @@ -477,7 +476,6 @@ describe API::API do |
477 | 476 | end |
478 | 477 | end |
479 | 478 | |
480 | - | |
481 | 479 | describe "GET /projects/:id/snippets" do |
482 | 480 | it "should return an array of project snippets" do |
483 | 481 | get api("/projects/#{project.id}/snippets", user) |
... | ... | @@ -503,26 +501,26 @@ describe API::API do |
503 | 501 | describe "POST /projects/:id/snippets" do |
504 | 502 | it "should create a new project snippet" do |
505 | 503 | post api("/projects/#{project.id}/snippets", user), |
506 | - title: 'api test', file_name: 'sample.rb', code: 'test' | |
504 | + title: 'api test', file_name: 'sample.rb', code: 'test' | |
507 | 505 | response.status.should == 201 |
508 | 506 | json_response['title'].should == 'api test' |
509 | 507 | end |
510 | 508 | |
511 | 509 | it "should return a 400 error if title is not given" do |
512 | 510 | post api("/projects/#{project.id}/snippets", user), |
513 | - file_name: 'sample.rb', code: 'test' | |
511 | + file_name: 'sample.rb', code: 'test' | |
514 | 512 | response.status.should == 400 |
515 | 513 | end |
516 | 514 | |
517 | 515 | it "should return a 400 error if file_name not given" do |
518 | 516 | post api("/projects/#{project.id}/snippets", user), |
519 | - title: 'api test', code: 'test' | |
517 | + title: 'api test', code: 'test' | |
520 | 518 | response.status.should == 400 |
521 | 519 | end |
522 | 520 | |
523 | 521 | it "should return a 400 error if code not given" do |
524 | 522 | post api("/projects/#{project.id}/snippets", user), |
525 | - title: 'api test', file_name: 'sample.rb' | |
523 | + title: 'api test', file_name: 'sample.rb' | |
526 | 524 | response.status.should == 400 |
527 | 525 | end |
528 | 526 | end |
... | ... | @@ -530,7 +528,7 @@ describe API::API do |
530 | 528 | describe "PUT /projects/:id/snippets/:shippet_id" do |
531 | 529 | it "should update an existing project snippet" do |
532 | 530 | put api("/projects/#{project.id}/snippets/#{snippet.id}", user), |
533 | - code: 'updated code' | |
531 | + code: 'updated code' | |
534 | 532 | response.status.should == 200 |
535 | 533 | json_response['title'].should == 'example' |
536 | 534 | snippet.reload.content.should == 'updated code' |
... | ... | @@ -538,7 +536,7 @@ describe API::API do |
538 | 536 | |
539 | 537 | it "should update an existing project snippet with new title" do |
540 | 538 | put api("/projects/#{project.id}/snippets/#{snippet.id}", user), |
541 | - title: 'other api test' | |
539 | + title: 'other api test' | |
542 | 540 | response.status.should == 200 |
543 | 541 | json_response['title'].should == 'other api test' |
544 | 542 | end |
... | ... | @@ -600,7 +598,7 @@ describe API::API do |
600 | 598 | |
601 | 599 | describe "POST /projects/:id/keys" do |
602 | 600 | it "should not create an invalid ssh key" do |
603 | - post api("/projects/#{project.id}/keys", user), {title: "invalid key"} | |
601 | + post api("/projects/#{project.id}/keys", user), { title: "invalid key" } | |
604 | 602 | response.status.should == 404 |
605 | 603 | end |
606 | 604 | |
... | ... | @@ -608,7 +606,7 @@ describe API::API do |
608 | 606 | key_attrs = attributes_for :key |
609 | 607 | expect { |
610 | 608 | post api("/projects/#{project.id}/keys", user), key_attrs |
611 | - }.to change { project.deploy_keys.count }.by(1) | |
609 | + }.to change{ project.deploy_keys.count }.by(1) | |
612 | 610 | end |
613 | 611 | end |
614 | 612 | |
... | ... | @@ -618,7 +616,7 @@ describe API::API do |
618 | 616 | it "should delete existing key" do |
619 | 617 | expect { |
620 | 618 | delete api("/projects/#{project.id}/keys/#{deploy_key.id}", user) |
621 | - }.to change { project.deploy_keys.count }.by(-1) | |
619 | + }.to change{ project.deploy_keys.count }.by(-1) | |
622 | 620 | end |
623 | 621 | |
624 | 622 | it "should return 404 Not Found with invalid ID" do | ... | ... |
spec/support/test_env.rb
... | ... | @@ -72,17 +72,17 @@ module TestEnv |
72 | 72 | ) |
73 | 73 | |
74 | 74 | Gitlab::Satellite::Satellite.any_instance.stub( |
75 | - exists?: true, | |
76 | - destroy: true, | |
77 | - create: true, | |
78 | - lock_files_dir: repos_path | |
75 | + exists?: true, | |
76 | + destroy: true, | |
77 | + create: true, | |
78 | + lock_files_dir: repos_path | |
79 | 79 | ) |
80 | 80 | |
81 | 81 | MergeRequest.any_instance.stub( |
82 | - check_if_can_be_merged: true | |
82 | + check_if_can_be_merged: true | |
83 | 83 | ) |
84 | 84 | Repository.any_instance.stub( |
85 | - size: 12.45 | |
85 | + size: 12.45 | |
86 | 86 | ) |
87 | 87 | end |
88 | 88 | |
... | ... | @@ -170,6 +170,4 @@ module TestEnv |
170 | 170 | command = "git init --quiet --bare #{path};" |
171 | 171 | system(command) |
172 | 172 | end |
173 | - | |
174 | - | |
175 | 173 | end | ... | ... |