Commit d9959427 authored by Izaak Alpert's avatar Izaak Alpert

Style changes from review with @randx

-Some changes around calling origional methods for !for_fork? merge requests. Other changes to follow

Change-Id: I009c716ce2475b9efa3fd07aee9215fca7a1c150
parent 128f2845
...@@ -124,7 +124,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -124,7 +124,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@target_branches @target_branches
end end
def ci_status def ci_status
status = project.gitlab_ci_service.commit_status(merge_request.last_commit.sha) status = project.gitlab_ci_service.commit_status(merge_request.last_commit.sha)
response = {status: status} response = {status: status}
...@@ -134,12 +133,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -134,12 +133,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
protected protected
def selected_target_project def selected_target_project
((@project.id.to_s == params[:target_project_id]) || @project.forked_project_link.nil?) ? @project : @project.forked_project_link.forked_from_project ((@project.id.to_s == params[:target_project_id]) || @project.forked_project_link.nil?) ? @project : @project.forked_project_link.forked_from_project
end end
def merge_request def merge_request
@merge_request ||= MergeRequest.find_by_id(params[:id]) @merge_request ||= MergeRequest.find_by_id(params[:id])
end end
......
...@@ -13,7 +13,6 @@ module MergeRequestsHelper ...@@ -13,7 +13,6 @@ module MergeRequestsHelper
) )
end end
def new_mr_from_push_event(event, target_project) def new_mr_from_push_event(event, target_project)
return :merge_request => { return :merge_request => {
source_project_id: event.project.id, source_project_id: event.project.id,
......
...@@ -2,7 +2,7 @@ module Emails ...@@ -2,7 +2,7 @@ module Emails
module MergeRequests module MergeRequests
def new_merge_request_email(recipient_id, merge_request_id) def new_merge_request_email(recipient_id, merge_request_id)
@merge_request = MergeRequest.find(merge_request_id) @merge_request = MergeRequest.find(merge_request_id)
mail(to: @merge_request.assignee_email, subject: subject("new merge request !#{@merge_request.id}", @merge_request.title)) mail(to: recipient(recipient_id), subject: subject("new merge request !#{@merge_request.id}", @merge_request.title))
end end
def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id) def reassigned_merge_request_email(recipient_id, merge_request_id, previous_assignee_id)
......
...@@ -26,8 +26,8 @@ class MergeRequest < ActiveRecord::Base ...@@ -26,8 +26,8 @@ class MergeRequest < ActiveRecord::Base
include Issuable include Issuable
belongs_to :target_project, :foreign_key => :target_project_id, class_name: "Project" belongs_to :target_project, foreign_key: :target_project_id, class_name: "Project"
belongs_to :source_project, :foreign_key => :source_project_id, class_name: "Project" belongs_to :source_project, foreign_key: :source_project_id, class_name: "Project"
attr_accessible :title, :assignee_id, :source_project_id, :source_branch, :target_project_id, :target_branch, :milestone_id, :author_id_of_changes, :state_event attr_accessible :title, :assignee_id, :source_project_id, :source_branch, :target_project_id, :target_branch, :milestone_id, :author_id_of_changes, :state_event
...@@ -149,7 +149,11 @@ class MergeRequest < ActiveRecord::Base ...@@ -149,7 +149,11 @@ class MergeRequest < ActiveRecord::Base
end end
def unmerged_diffs def unmerged_diffs
if for_fork?
diffs = Gitlab::Satellite::MergeAction.new(author, self).diffs_between_satellite diffs = Gitlab::Satellite::MergeAction.new(author, self).diffs_between_satellite
else
diffs = target_project.repository.diffs_between(source_branch, target_branch)
end
diffs ||= [] diffs ||= []
diffs diffs
end end
...@@ -185,7 +189,11 @@ class MergeRequest < ActiveRecord::Base ...@@ -185,7 +189,11 @@ class MergeRequest < ActiveRecord::Base
end end
def unmerged_commits def unmerged_commits
if for_fork?
commits = Gitlab::Satellite::MergeAction.new(self.author, self).commits_between commits = Gitlab::Satellite::MergeAction.new(self.author, self).commits_between
else
commits = target_project.repository.commits_between(self.target_branch, self.source_branch)
end
if commits.present? if commits.present?
commits = Commit.decorate(commits). commits = Commit.decorate(commits).
sort_by(&:created_at). sort_by(&:created_at).
......
...@@ -32,8 +32,8 @@ class Note < ActiveRecord::Base ...@@ -32,8 +32,8 @@ class Note < ActiveRecord::Base
delegate :name, :email, to: :author, prefix: true delegate :name, :email, to: :author, prefix: true
validates :note, :project, presence: true validates :note, :project, presence: true
validates :line_code, format: {with: /\A[a-z0-9]+_\d+_\d+\Z/}, allow_blank: true validates :line_code, format: { with: /\A[a-z0-9]+_\d+_\d+\Z/ }, allow_blank: true
validates :attachment, file_size: {maximum: 10.megabytes.to_i} validates :attachment, file_size: { maximum: 10.megabytes.to_i }
validates :noteable_id, presence: true, if: ->(n) { n.noteable_type.present? && n.noteable_type != 'Commit' } validates :noteable_id, presence: true, if: ->(n) { n.noteable_type.present? && n.noteable_type != 'Commit' }
validates :commit_id, presence: true, if: ->(n) { n.noteable_type == 'Commit' } validates :commit_id, presence: true, if: ->(n) { n.noteable_type == 'Commit' }
...@@ -42,13 +42,13 @@ class Note < ActiveRecord::Base ...@@ -42,13 +42,13 @@ class Note < ActiveRecord::Base
# Scopes # Scopes
scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) } scope :for_commit_id, ->(commit_id) { where(noteable_type: "Commit", commit_id: commit_id) }
scope :inline, -> { where("line_code IS NOT NULL") } scope :inline, ->{ where("line_code IS NOT NULL") }
scope :not_inline, -> { where(line_code: [nil, '']) } scope :not_inline, ->{ where(line_code: [nil, '']) }
scope :common, -> { where(noteable_type: ["", nil]) } scope :common, ->{ where(noteable_type: ["", nil]) }
scope :fresh, -> { order("created_at ASC, id ASC") } scope :fresh, ->{ order("created_at ASC, id ASC") }
scope :inc_author_project, -> { includes(:project, :author) } scope :inc_author_project, ->{ includes(:project, :author) }
scope :inc_author, -> { includes(:author) } scope :inc_author, ->{ includes(:author) }
def self.create_status_change_note(noteable, project, author, status) def self.create_status_change_note(noteable, project, author, status)
create({ create({
......
...@@ -2,8 +2,7 @@ class MergeRequestObserver < ActivityObserver ...@@ -2,8 +2,7 @@ class MergeRequestObserver < ActivityObserver
observe :merge_request observe :merge_request
def after_create(merge_request) def after_create(merge_request)
event_author_id = merge_request.author_id if merge_request.author_id
if event_author_id
create_event(merge_request, Event.determine_action(merge_request)) create_event(merge_request, Event.determine_action(merge_request))
end end
...@@ -41,7 +40,6 @@ class MergeRequestObserver < ActivityObserver ...@@ -41,7 +40,6 @@ class MergeRequestObserver < ActivityObserver
notification.reassigned_merge_request(merge_request, current_user) if merge_request.is_being_reassigned? notification.reassigned_merge_request(merge_request, current_user) if merge_request.is_being_reassigned?
end end
def create_event(record, status) def create_event(record, status)
Event.create( Event.create(
project: record.target_project, project: record.target_project,
......
...@@ -80,9 +80,7 @@ class NotificationService ...@@ -80,9 +80,7 @@ class NotificationService
# * project team members with notification level higher then Participating # * project team members with notification level higher then Participating
# #
def merge_mr(merge_request) def merge_mr(merge_request)
recipients = reject_muted_users([merge_request.author, merge_request.assignee], merge_request.source_project) recipients = reject_muted_users([merge_request.author, merge_request.assignee], merge_request.target_project)
recipients = recipients.concat(reject_muted_users([merge_request.author, merge_request.assignee], merge_request.target_project))
recipients = recipients.concat(project_watchers(merge_request.source_project))
recipients = recipients.concat(project_watchers(merge_request.target_project)).uniq recipients = recipients.concat(project_watchers(merge_request.target_project)).uniq
recipients.each do |recipient| recipients.each do |recipient|
...@@ -104,7 +102,7 @@ class NotificationService ...@@ -104,7 +102,7 @@ class NotificationService
# ignore wall messages # ignore wall messages
return true unless note.noteable_type.present? return true unless note.noteable_type.present?
opts = {noteable_type: note.noteable_type, project_id: note.project_id} opts = { noteable_type: note.noteable_type, project_id: note.project_id }
if note.commit_id.present? if note.commit_id.present?
opts.merge!(commit_id: note.commit_id) opts.merge!(commit_id: note.commit_id)
......
...@@ -5,4 +5,4 @@ ...@@ -5,4 +5,4 @@
%span= day.stamp("28 Aug, 2010") %span= day.stamp("28 Aug, 2010")
.pull-right .pull-right
%small= pluralize(commits.count, 'commit') %small= pluralize(commits.count, 'commit')
%ul.well-list= render commits, :project => @project %ul.well-list= render commits, project: @project
= form_for [@source_project, @merge_request], html: { class: "#{controller.action_name}-merge-request form-horizontal" } do |form_helper| = form_for [@source_project, @merge_request], html: { class: "#{controller.action_name}-merge-request form-horizontal" } do |f|
-if @merge_request.errors.any? -if @merge_request.errors.any?
.alert.alert-error .alert.alert-error
%ul %ul
...@@ -51,9 +51,9 @@ ...@@ -51,9 +51,9 @@
.form-actions .form-actions
- if @merge_request.new_record? - if @merge_request.new_record?
= form_helper.submit 'Submit merge request', class: "btn btn-create" = f.submit 'Submit merge request', class: "btn btn-create"
-else -else
= form_helper.submit 'Save changes', class: "btn btn-save" = f.submit 'Save changes', class: "btn btn-save"
- if @merge_request.new_record? - if @merge_request.new_record?
= link_to project_merge_requests_path(@source_project), class: "btn btn-cancel" do = link_to project_merge_requests_path(@source_project), class: "btn btn-cancel" do
Cancel Cancel
......
...@@ -8,9 +8,14 @@ ...@@ -8,9 +8,14 @@
= "MERGED" = "MERGED"
- else - else
%span.pull-right %span.pull-right
- if merge_request.for_fork?
= "#{merge_request.source_project.path_with_namespace}/#{merge_request.source_branch}" = "#{merge_request.source_project.path_with_namespace}/#{merge_request.source_branch}"
%i.icon-angle-right %i.icon-angle-right
= "#{merge_request.target_project.path_with_namespace}/#{merge_request.target_branch}" = "#{merge_request.target_project.path_with_namespace}/#{merge_request.target_branch}"
- else
= "#{merge_request.source_branch}"
%i.icon-angle-right
= "#{merge_request.target_branch}"
.merge-request-info .merge-request-info
- if merge_request.author - if merge_request.author
authored by #{link_to_member(merge_request.source_project, merge_request.author)} authored by #{link_to_member(merge_request.source_project, merge_request.author)}
......
%h3.page-title %h3.page-title
= "Merge Request ##{@merge_request.id}:" = "Merge Request ##{@merge_request.id}:"
&nbsp; &nbsp;
-if @merge_request.for_fork?
%span.label-project= @merge_request.source_project.path_with_namespace %span.label-project= @merge_request.source_project.path_with_namespace
%span.label-branch= @merge_request.source_branch %span.label-branch= @merge_request.source_branch
&rarr; &rarr;
%span.label-project= @merge_request.target_project.path_with_namespace %span.label-project= @merge_request.target_project.path_with_namespace
%span.label-branch= @merge_request.target_branch %span.label-branch= @merge_request.target_branch
- else
%span.label-branch= @merge_request.source_branch
&rarr;
%span.label-branch= @merge_request.target_branch
%span.pull-right %span.pull-right
- if can?(current_user, :modify_merge_request, @merge_request) - if can?(current_user, :modify_merge_request, @merge_request)
......
...@@ -26,7 +26,10 @@ ...@@ -26,7 +26,10 @@
%span ##{merge_request.id} %span ##{merge_request.id}
%strong.term %strong.term
= truncate merge_request.title, length: 50 = truncate merge_request.title, length: 50
- if merge_request.for_fork?
%span.light (#{merge_request.source_project.name_with_namespace}:#{merge_request.source_branch} &rarr; #{merge_request.target_project.name_with_namespace}:#{merge_request.target_branch}) %span.light (#{merge_request.source_project.name_with_namespace}:#{merge_request.source_branch} &rarr; #{merge_request.target_project.name_with_namespace}:#{merge_request.target_branch})
- else
%span.light (#{merge_request.source_branch} &rarr; #{merge_request.target_branch})
- @issues.each do |issue| - @issues.each do |issue|
%li %li
issue: issue:
......
...@@ -2,7 +2,7 @@ class AllowMergesForForks < ActiveRecord::Migration ...@@ -2,7 +2,7 @@ class AllowMergesForForks < ActiveRecord::Migration
def self.up def self.up
add_column :merge_requests, :target_project_id, :integer, :null => false add_column :merge_requests, :target_project_id, :integer, :null => false
MergeRequest.connection.execute("update merge_requests set target_project_id=project_id") MergeRequest.update_all("target_project_id = project_id")
rename_column :merge_requests, :project_id, :source_project_id rename_column :merge_requests, :project_id, :source_project_id
end end
......
...@@ -20,7 +20,6 @@ Feature: Project Forked Merge Requests ...@@ -20,7 +20,6 @@ Feature: Project Forked Merge Requests
And I submit the merge request And I submit the merge request
Then I should see merge request "Merge Request On Forked Project" Then I should see merge request "Merge Request On Forked Project"
@javascript @javascript
Scenario: I should see a push widget for forked merge requests Scenario: I should see a push widget for forked merge requests
Given project "Forked Shop" has push event Given project "Forked Shop" has push event
...@@ -39,7 +38,6 @@ Feature: Project Forked Merge Requests ...@@ -39,7 +38,6 @@ Feature: Project Forked Merge Requests
And I click link edit "Merge Request On Forked Project" And I click link edit "Merge Request On Forked Project"
Then I see the edit page prefilled for "Merge Request On Forked Project" Then I see the edit page prefilled for "Merge Request On Forked Project"
@javascript @javascript
Scenario: I cannot submit an invalid merge request Scenario: I cannot submit an invalid merge request
Given I visit project "Forked Shop" merge requests page Given I visit project "Forked Shop" merge requests page
......
module Gitlab module Gitlab
module Satellite module Satellite
class Action class Action
DEFAULT_OPTIONS = {git_timeout: 30.seconds} DEFAULT_OPTIONS = { git_timeout: 30.seconds }
attr_accessor :options, :project, :user attr_accessor :options, :project, :user
...@@ -39,8 +39,8 @@ module Gitlab ...@@ -39,8 +39,8 @@ module Gitlab
def prepare_satellite!(repo) def prepare_satellite!(repo)
project.satellite.clear_and_update! project.satellite.clear_and_update!
repo.config['user.name']=user.name repo.config['user.name'] = user.name
repo.config['user.email']=user.email repo.config['user.email'] = user.email
end end
def default_options(options = {}) def default_options(options = {})
......
module Gitlab module Gitlab
class SatelliteNotExistError < StandardError; class SatelliteNotExistError < StandardError; end
end
module Satellite module Satellite
class Satellite class Satellite
...@@ -22,9 +21,9 @@ module Gitlab ...@@ -22,9 +21,9 @@ module Gitlab
raise SatelliteNotExistError.new("Satellite doesn't exist") raise SatelliteNotExistError.new("Satellite doesn't exist")
end end
def clear_and_update! def clear_and_update!
raise_no_satellite unless exists? raise_no_satellite unless exists?
File.exists? path File.exists? path
@repo = nil @repo = nil
clear_working_dir! clear_working_dir!
...@@ -68,7 +67,6 @@ module Gitlab ...@@ -68,7 +67,6 @@ module Gitlab
end end
end end
def lock_file def lock_file
create_locks_dir unless File.exists?(lock_files_dir) create_locks_dir unless File.exists?(lock_files_dir)
File.join(lock_files_dir, "satellite_#{project.id}.lock") File.join(lock_files_dir, "satellite_#{project.id}.lock")
......
...@@ -7,7 +7,6 @@ INVALID_FACTORIES = [ ...@@ -7,7 +7,6 @@ INVALID_FACTORIES = [
FactoryGirl.factories.map(&:name).each do |factory_name| FactoryGirl.factories.map(&:name).each do |factory_name|
next if INVALID_FACTORIES.include?(factory_name) next if INVALID_FACTORIES.include?(factory_name)
describe "#{factory_name} factory" do describe "#{factory_name} factory" do
it 'should be valid' do it 'should be valid' do
build(factory_name).should be_valid build(factory_name).should be_valid
......
...@@ -21,7 +21,6 @@ describe "Application access" do ...@@ -21,7 +21,6 @@ describe "Application access" do
let(:reporter) { create(:user) } let(:reporter) { create(:user) }
before do before do
# full access # full access
project.team << [master, :master] project.team << [master, :master]
......
require 'spec_helper' require 'spec_helper'
describe 'Gitlab::Satellite::Action' do describe 'Gitlab::Satellite::Action' do
let(:project) { create(:project_with_code) } let(:project) { create(:project_with_code) }
let(:user) { create(:user) } let(:user) { create(:user) }
describe '#prepare_satellite!' do describe '#prepare_satellite!' do
it 'create a repository with a parking branch and one remote: origin' do it 'create a repository with a parking branch and one remote: origin' do
...@@ -50,11 +47,8 @@ describe 'Gitlab::Satellite::Action' do ...@@ -50,11 +47,8 @@ describe 'Gitlab::Satellite::Action' do
repo.config['user.name'].should ==user.name repo.config['user.name'].should ==user.name
repo.config['user.email'].should ==user.email repo.config['user.email'].should ==user.email
end end
end end
describe '#in_locked_and_timed_satellite' do describe '#in_locked_and_timed_satellite' do
it 'should make use of a lockfile' do it 'should make use of a lockfile' do
......
...@@ -11,7 +11,6 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -11,7 +11,6 @@ describe 'Gitlab::Satellite::MergeAction' do
#these commits are quite close together, itended to make string diffs/format patches small #these commits are quite close together, itended to make string diffs/format patches small
@close_commit1 = ['2_3_notes_fix', '8470d70da67355c9c009e4401746b1d5410af2e3'] @close_commit1 = ['2_3_notes_fix', '8470d70da67355c9c009e4401746b1d5410af2e3']
@close_commit2 = ['scss_refactoring', 'f0f14c8eaba69ebddd766498a9d0b0e79becd633'] @close_commit2 = ['scss_refactoring', 'f0f14c8eaba69ebddd766498a9d0b0e79becd633']
end end
let(:project) { create(:project_with_code) } let(:project) { create(:project_with_code) }
...@@ -53,7 +52,6 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -53,7 +52,6 @@ describe 'Gitlab::Satellite::MergeAction' do
end end
end end
describe '#format_patch' do describe '#format_patch' do
context 'on fork' do context 'on fork' do
it 'should build a format patch' do it 'should build a format patch' do
...@@ -76,7 +74,6 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -76,7 +74,6 @@ describe 'Gitlab::Satellite::MergeAction' do
end end
end end
describe '#diffs_between_satellite tested against diff_in_satellite' do describe '#diffs_between_satellite tested against diff_in_satellite' do
def is_a_matching_diff(diff, diffs) def is_a_matching_diff(diff, diffs)
...@@ -109,7 +106,6 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -109,7 +106,6 @@ describe 'Gitlab::Satellite::MergeAction' do
merge_request.source_branch = @master[0] merge_request.source_branch = @master[0]
diffs = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diffs_between_satellite diffs = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diffs_between_satellite
merge_request.target_branch = @close_commit1[0] merge_request.target_branch = @close_commit1[0]
merge_request.source_branch = @master[0] merge_request.source_branch = @master[0]
diff = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diff_in_satellite diff = Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diff_in_satellite
...@@ -119,7 +115,6 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -119,7 +115,6 @@ describe 'Gitlab::Satellite::MergeAction' do
end end
end end
describe '#can_be_merged?' do describe '#can_be_merged?' do
context 'on fork' do context 'on fork' do
it 'return true or false depending on if something is mergable' do it 'return true or false depending on if something is mergable' do
...@@ -145,5 +140,4 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -145,5 +140,4 @@ describe 'Gitlab::Satellite::MergeAction' do
end end
end end
end end
end end
\ No newline at end of file
...@@ -90,7 +90,6 @@ describe MergeRequestObserver do ...@@ -90,7 +90,6 @@ describe MergeRequestObserver do
end end
end end
describe "Merge Request created" do describe "Merge Request created" do
def self.it_should_be_valid_event def self.it_should_be_valid_event
it { @event.should_not be_nil } it { @event.should_not be_nil }
......
...@@ -15,8 +15,7 @@ describe API::API do ...@@ -15,8 +15,7 @@ describe API::API do
let!(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } let!(:users_project) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) }
let!(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) } let!(:users_project2) { create(:users_project, user: user3, project: project, project_access: UsersProject::DEVELOPER) }
before { before { project.team << [user, :reporter] }
project.team << [user, :reporter] }
describe "GET /projects" do describe "GET /projects" do
context "when unauthenticated" do context "when unauthenticated" do
...@@ -48,16 +47,16 @@ describe API::API do ...@@ -48,16 +47,16 @@ describe API::API do
it "should not create new project" do it "should not create new project" do
expect { expect {
post api("/projects", user2), name: 'foo' post api("/projects", user2), name: 'foo'
}.to change { Project.count }.by(0) }.to change {Project.count}.by(0)
end end
end end
it "should create new project without path" do it "should create new project without path" do
expect { post api("/projects", user), name: 'foo' }.to change { Project.count }.by(1) expect { post api("/projects", user), name: 'foo' }.to change {Project.count}.by(1)
end end
it "should not create new project without name" do it "should not create new project without name" do
expect { post api("/projects", user) }.to_not change { Project.count } expect { post api("/projects", user) }.to_not change {Project.count}
end end
it "should return a 400 error if name not given" do it "should return a 400 error if name not given" do
...@@ -101,7 +100,7 @@ describe API::API do ...@@ -101,7 +100,7 @@ describe API::API do
post api("/projects", user), project post api("/projects", user), project
project.each_pair do |k, v| project.each_pair do |k,v|
next if k == :path next if k == :path
json_response[k.to_s].should == v json_response[k.to_s].should == v
end end
...@@ -127,11 +126,11 @@ describe API::API do ...@@ -127,11 +126,11 @@ describe API::API do
before { admin } before { admin }
it "should create new project without path" do it "should create new project without path" do
expect { post api("/projects/user/#{user.id}", admin), name: 'foo' }.to change { Project.count }.by(1) expect { post api("/projects/user/#{user.id}", admin), name: 'foo' }.to change {Project.count}.by(1)
end end
it "should not create new project without name" do it "should not create new project without name" do
expect { post api("/projects/user/#{user.id}", admin) }.to_not change { Project.count } expect { post api("/projects/user/#{user.id}", admin) }.to_not change {Project.count}
end end
it "should respond with 201 on success" do it "should respond with 201 on success" do
...@@ -156,7 +155,7 @@ describe API::API do ...@@ -156,7 +155,7 @@ describe API::API do
post api("/projects/user/#{user.id}", admin), project post api("/projects/user/#{user.id}", admin), project
project.each_pair do |k, v| project.each_pair do |k,v|
next if k == :path next if k == :path
json_response[k.to_s].should == v json_response[k.to_s].should == v
end end
...@@ -414,7 +413,7 @@ describe API::API do ...@@ -414,7 +413,7 @@ describe API::API do
expect { expect {
post api("/projects/#{project.id}/hooks", user), post api("/projects/#{project.id}/hooks", user),
url: "http://example.com" url: "http://example.com"
}.to change { project.hooks.count }.by(1) }.to change {project.hooks.count}.by(1)
response.status.should == 201 response.status.should == 201
end end
...@@ -457,7 +456,7 @@ describe API::API do ...@@ -457,7 +456,7 @@ describe API::API do
it "should delete hook from project" do it "should delete hook from project" do
expect { expect {
delete api("/projects/#{project.id}/hooks/#{hook.id}", user) delete api("/projects/#{project.id}/hooks/#{hook.id}", user)
}.to change { project.hooks.count }.by(-1) }.to change {project.hooks.count}.by(-1)
response.status.should == 200 response.status.should == 200
end end
...@@ -477,7 +476,6 @@ describe API::API do ...@@ -477,7 +476,6 @@ describe API::API do
end end
end end
describe "GET /projects/:id/snippets" do describe "GET /projects/:id/snippets" do
it "should return an array of project snippets" do it "should return an array of project snippets" do
get api("/projects/#{project.id}/snippets", user) get api("/projects/#{project.id}/snippets", user)
...@@ -600,7 +598,7 @@ describe API::API do ...@@ -600,7 +598,7 @@ describe API::API do
describe "POST /projects/:id/keys" do describe "POST /projects/:id/keys" do
it "should not create an invalid ssh key" do it "should not create an invalid ssh key" do
post api("/projects/#{project.id}/keys", user), {title: "invalid key"} post api("/projects/#{project.id}/keys", user), { title: "invalid key" }
response.status.should == 404 response.status.should == 404
end end
...@@ -608,7 +606,7 @@ describe API::API do ...@@ -608,7 +606,7 @@ describe API::API do
key_attrs = attributes_for :key key_attrs = attributes_for :key
expect { expect {
post api("/projects/#{project.id}/keys", user), key_attrs post api("/projects/#{project.id}/keys", user), key_attrs
}.to change { project.deploy_keys.count }.by(1) }.to change{ project.deploy_keys.count }.by(1)
end end
end end
...@@ -618,7 +616,7 @@ describe API::API do ...@@ -618,7 +616,7 @@ describe API::API do
it "should delete existing key" do it "should delete existing key" do
expect { expect {
delete api("/projects/#{project.id}/keys/#{deploy_key.id}", user) delete api("/projects/#{project.id}/keys/#{deploy_key.id}", user)
}.to change { project.deploy_keys.count }.by(-1) }.to change{ project.deploy_keys.count }.by(-1)
end end
it "should return 404 Not Found with invalid ID" do it "should return 404 Not Found with invalid ID" do
......
...@@ -170,6 +170,4 @@ module TestEnv ...@@ -170,6 +170,4 @@ module TestEnv
command = "git init --quiet --bare #{path};" command = "git init --quiet --bare #{path};"
system(command) system(command)
end end
end end
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment