Commit 54bcb6cc authored by Marin Jankovski's avatar Marin Jankovski

Merge branch 'master' into reference_relative_links

Conflicts:
	spec/models/project_spec.rb
parents d819d0d1 d1d13856
v 6.5.1
- Fix branch selectbox when create merge request from fork
v 6.5.0 v 6.5.0
- Dropdown menus on issue#show page for assignee and milestone (Jason Blanchard) - Dropdown menus on issue#show page for assignee and milestone (Jason Blanchard)
- Add color custimization and previewing to broadcast messages - Add color custimization and previewing to broadcast messages
......
...@@ -14,7 +14,6 @@ gem "protected_attributes" ...@@ -14,7 +14,6 @@ gem "protected_attributes"
gem 'rails-observers' gem 'rails-observers'
gem 'actionpack-page_caching' gem 'actionpack-page_caching'
gem 'actionpack-action_caching' gem 'actionpack-action_caching'
gem 'activerecord-deprecated_finders'
# Supported DBs # Supported DBs
gem "mysql2", group: :mysql gem "mysql2", group: :mysql
......
...@@ -551,7 +551,6 @@ PLATFORMS ...@@ -551,7 +551,6 @@ PLATFORMS
DEPENDENCIES DEPENDENCIES
actionpack-action_caching actionpack-action_caching
actionpack-page_caching actionpack-page_caching
activerecord-deprecated_finders
acts-as-taggable-on acts-as-taggable-on
annotate (~> 2.6.0.beta2) annotate (~> 2.6.0.beta2)
asciidoctor asciidoctor
......
...@@ -73,7 +73,7 @@ Thanks for the issue report. Please reformat your issue to conform to the issue ...@@ -73,7 +73,7 @@ Thanks for the issue report. Please reformat your issue to conform to the issue
### Feature requests ### Feature requests
Thanks for your interest in GitLab. We don't use the GitHub issue tracker for feature requests. Please use http://feedback.gitlab.com/ for this purpose or create a merge request implementing this feature. Have a look at the \[contribution guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) for more information. Thanks for your interest in GitLab. We don't use the issue tracker for feature requests. Please use http://feedback.gitlab.com/ for this purpose or create a merge request implementing this feature. Have a look at the \[contribution guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) for more information.
### Issue report for old version ### Issue report for old version
...@@ -81,7 +81,7 @@ Thanks for the issue report but we only support issues for the latest stable ver ...@@ -81,7 +81,7 @@ Thanks for the issue report but we only support issues for the latest stable ver
### Support requests and configuration questions ### Support requests and configuration questions
Thanks for your interest in GitLab. We don't use the GitHub issue tracker for support requests and configuration questions. Please use the \[support forum\]\(https://groups.google.com/forum/#!forum/gitlabhq), \[Stack Overflow\]\(http://stackoverflow.com/questions/tagged/gitlab), the unofficial #gitlab IRC channel on Freenode or the http://www.gitlab.com paid services for this purpose. Have a look at the \[contribution guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) for more information. Thanks for your interest in GitLab. We don't use the issue tracker for support requests and configuration questions. Please use the \[support forum\]\(https://groups.google.com/forum/#!forum/gitlabhq), \[Stack Overflow\]\(http://stackoverflow.com/questions/tagged/gitlab), the unofficial #gitlab IRC channel on Freenode or the http://www.gitlab.com paid services for this purpose. Have a look at the \[contribution guidelines\]\(https://gitlab.com/gitlab-org/gitlab-ce/blob/master/CONTRIBUTING.md) for more information.
### Code format ### Code format
......
...@@ -6,11 +6,10 @@ ...@@ -6,11 +6,10 @@
} }
.login-box{ .login-box{
width: 304px; max-width: 304px;
position: relative; position: relative;
@include border-radius(5px); @include border-radius(5px);
margin: auto; margin: auto;
padding: 20px;
background: white; background: white;
} }
...@@ -23,7 +22,7 @@ ...@@ -23,7 +22,7 @@
background-color: #f1f1f1; background-color: #f1f1f1;
font-size: 16px; font-size: 16px;
padding: 14px 10px; padding: 14px 10px;
width: 280px; width: 100%;
height: auto; height: auto;
&.top { &.top {
......
...@@ -89,16 +89,3 @@ ...@@ -89,16 +89,3 @@
.merge-request-form-info { .merge-request-form-info {
padding-top: 15px; padding-top: 15px;
} }
.merge-request-branches {
.commit-row-message {
font-weight: normal !important;
}
.select2-container .select2-single {
span {
font-weight: bold;
color: #555;
}
}
}
...@@ -52,6 +52,6 @@ class Admin::GroupsController < Admin::ApplicationController ...@@ -52,6 +52,6 @@ class Admin::GroupsController < Admin::ApplicationController
private private
def group def group
@group = Group.find_by_path(params[:id]) @group = Group.find_by(path: params[:id])
end end
end end
...@@ -5,7 +5,7 @@ class Admin::ProjectsController < Admin::ApplicationController ...@@ -5,7 +5,7 @@ class Admin::ProjectsController < Admin::ApplicationController
def index def index
owner_id = params[:owner_id] owner_id = params[:owner_id]
user = User.find_by_id(owner_id) user = User.find_by(id: owner_id)
@projects = user ? user.owned_projects : Project.all @projects = user ? user.owned_projects : Project.all
@projects = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present? @projects = @projects.where("visibility_level IN (?)", params[:visibility_levels]) if params[:visibility_levels].present?
......
...@@ -100,6 +100,6 @@ class Admin::UsersController < Admin::ApplicationController ...@@ -100,6 +100,6 @@ class Admin::UsersController < Admin::ApplicationController
protected protected
def user def user
@user ||= User.find_by_username!(params[:id]) @user ||= User.find_by!(username: params[:id])
end end
end end
...@@ -41,7 +41,7 @@ class DashboardController < ApplicationController ...@@ -41,7 +41,7 @@ class DashboardController < ApplicationController
current_user.authorized_projects current_user.authorized_projects
end end
@projects = @projects.where(namespace_id: Group.find_by_name(params[:group])) if params[:group].present? @projects = @projects.where(namespace_id: Group.find_by(name: params[:group])) if params[:group].present?
@projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present? @projects = @projects.where(visibility_level: params[:visibility_level]) if params[:visibility_level].present?
@projects = @projects.includes(:namespace) @projects = @projects.includes(:namespace)
@projects = @projects.tagged_with(params[:label]) if params[:label].present? @projects = @projects.tagged_with(params[:label]) if params[:label].present?
......
...@@ -87,7 +87,7 @@ class GroupsController < ApplicationController ...@@ -87,7 +87,7 @@ class GroupsController < ApplicationController
protected protected
def group def group
@group ||= Group.find_by_path(params[:id]) @group ||= Group.find_by(path: params[:id])
end end
def projects def projects
......
...@@ -19,6 +19,6 @@ class Profiles::GroupsController < ApplicationController ...@@ -19,6 +19,6 @@ class Profiles::GroupsController < ApplicationController
private private
def group def group
@group ||= Group.find_by_path(params[:id]) @group ||= Group.find_by(path: params[:id])
end end
end end
...@@ -97,7 +97,7 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -97,7 +97,7 @@ class Projects::IssuesController < Projects::ApplicationController
def issue def issue
@issue ||= begin @issue ||= begin
@project.issues.find_by_iid!(params[:id]) @project.issues.find_by!(iid: params[:id])
rescue ActiveRecord::RecordNotFound rescue ActiveRecord::RecordNotFound
redirect_old redirect_old
end end
...@@ -127,7 +127,7 @@ class Projects::IssuesController < Projects::ApplicationController ...@@ -127,7 +127,7 @@ class Projects::IssuesController < Projects::ApplicationController
# To prevent 404 errors we provide a redirect to correct iids until 7.0 release # To prevent 404 errors we provide a redirect to correct iids until 7.0 release
# #
def redirect_old def redirect_old
issue = @project.issues.find_by_id(params[:id]) issue = @project.issues.find_by(id: params[:id])
if issue if issue
redirect_to project_issue_path(@project, issue) redirect_to project_issue_path(@project, issue)
......
...@@ -76,7 +76,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -76,7 +76,6 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@merge_request.author = current_user @merge_request.author = current_user
@target_branches ||= [] @target_branches ||= []
if @merge_request.save if @merge_request.save
@merge_request.reload_code
redirect_to [@merge_request.target_project, @merge_request], notice: 'Merge request was successfully created.' redirect_to [@merge_request.target_project, @merge_request], notice: 'Merge request was successfully created.'
else else
@source_project = @merge_request.source_project @source_project = @merge_request.source_project
...@@ -152,6 +151,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -152,6 +151,10 @@ class Projects::MergeRequestsController < Projects::ApplicationController
@target_project = selected_target_project @target_project = selected_target_project
@target_branches = @target_project.repository.branch_names @target_branches = @target_project.repository.branch_names
@target_branches @target_branches
respond_to do |format|
format.js
end
end end
def ci_status def ci_status
...@@ -168,7 +171,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -168,7 +171,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
end end
def merge_request def merge_request
@merge_request ||= @project.merge_requests.find_by_iid!(params[:id]) @merge_request ||= @project.merge_requests.find_by!(iid: params[:id])
end end
def closes_issues def closes_issues
...@@ -213,6 +216,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController ...@@ -213,6 +216,7 @@ class Projects::MergeRequestsController < Projects::ApplicationController
# or from cache if already merged # or from cache if already merged
@commits = @merge_request.commits @commits = @merge_request.commits
@merge_request_diff = @merge_request.merge_request_diff
@allowed_to_merge = allowed_to_merge? @allowed_to_merge = allowed_to_merge?
@show_merge_controls = @merge_request.opened? && @commits.any? && @allowed_to_merge @show_merge_controls = @merge_request.opened? && @commits.any? && @allowed_to_merge
end end
......
...@@ -76,7 +76,7 @@ class Projects::MilestonesController < Projects::ApplicationController ...@@ -76,7 +76,7 @@ class Projects::MilestonesController < Projects::ApplicationController
protected protected
def milestone def milestone
@milestone ||= @project.milestones.find_by_iid!(params[:id]) @milestone ||= @project.milestones.find_by!(iid: params[:id])
end end
def authorize_admin_milestone! def authorize_admin_milestone!
......
...@@ -26,7 +26,7 @@ class Projects::TeamMembersController < Projects::ApplicationController ...@@ -26,7 +26,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
end end
def update def update
@user_project_relation = project.users_projects.find_by_user_id(member) @user_project_relation = project.users_projects.find_by(user_id: member)
@user_project_relation.update_attributes(params[:team_member]) @user_project_relation.update_attributes(params[:team_member])
unless @user_project_relation.valid? unless @user_project_relation.valid?
...@@ -36,7 +36,7 @@ class Projects::TeamMembersController < Projects::ApplicationController ...@@ -36,7 +36,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
end end
def destroy def destroy
@user_project_relation = project.users_projects.find_by_user_id(member) @user_project_relation = project.users_projects.find_by(user_id: member)
@user_project_relation.destroy @user_project_relation.destroy
respond_to do |format| respond_to do |format|
...@@ -46,7 +46,7 @@ class Projects::TeamMembersController < Projects::ApplicationController ...@@ -46,7 +46,7 @@ class Projects::TeamMembersController < Projects::ApplicationController
end end
def leave def leave
project.users_projects.find_by_user_id(current_user).destroy project.users_projects.find_by(user_id: current_user).destroy
respond_to do |format| respond_to do |format|
format.html { redirect_to :back } format.html { redirect_to :back }
...@@ -65,6 +65,6 @@ class Projects::TeamMembersController < Projects::ApplicationController ...@@ -65,6 +65,6 @@ class Projects::TeamMembersController < Projects::ApplicationController
protected protected
def member def member
@member ||= User.find_by_username(params[:id]) @member ||= User.find_by(username: params[:id])
end end
end end
...@@ -2,8 +2,8 @@ class SearchController < ApplicationController ...@@ -2,8 +2,8 @@ class SearchController < ApplicationController
include SearchHelper include SearchHelper
def show def show
@project = Project.find_by_id(params[:project_id]) if params[:project_id].present? @project = Project.find_by(id: params[:project_id]) if params[:project_id].present?
@group = Group.find_by_id(params[:group_id]) if params[:group_id].present? @group = Group.find_by(id: params[:group_id]) if params[:group_id].present?
if @project if @project
return access_denied! unless can?(current_user, :download_code, @project) return access_denied! unless can?(current_user, :download_code, @project)
......
...@@ -18,7 +18,7 @@ class SnippetsController < ApplicationController ...@@ -18,7 +18,7 @@ class SnippetsController < ApplicationController
end end
def user_index def user_index
@user = User.find_by_username(params[:username]) @user = User.find_by(username: params[:username])
@snippets = @user.snippets.fresh.non_expired @snippets = @user.snippets.fresh.non_expired
if @user == current_user if @user == current_user
......
...@@ -2,7 +2,7 @@ class UsersController < ApplicationController ...@@ -2,7 +2,7 @@ class UsersController < ApplicationController
layout 'navless' layout 'navless'
def show def show
@user = User.find_by_username!(params[:username]) @user = User.find_by!(username: params[:username])
@projects = @user.authorized_projects.where(id: current_user.authorized_projects.pluck(:id)).includes(:namespace) @projects = @user.authorized_projects.where(id: current_user.authorized_projects.pluck(:id)).includes(:namespace)
@events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20) @events = @user.recent_events.where(project_id: @projects.map(&:id)).limit(20)
......
...@@ -30,7 +30,7 @@ class UsersGroupsController < ApplicationController ...@@ -30,7 +30,7 @@ class UsersGroupsController < ApplicationController
protected protected
def group def group
@group ||= Group.find_by_path(params[:group_id]) @group ||= Group.find_by(path: params[:group_id])
end end
def authorize_admin_group! def authorize_admin_group!
......
...@@ -50,7 +50,7 @@ module ApplicationHelper ...@@ -50,7 +50,7 @@ module ApplicationHelper
end end
def avatar_icon(user_email = '', size = nil) def avatar_icon(user_email = '', size = nil)
user = User.find_by_email(user_email) user = User.find_by(email: user_email)
if user && user.avatar.present? if user && user.avatar.present?
user.avatar.url user.avatar.url
else else
......
...@@ -8,7 +8,7 @@ module Emails ...@@ -8,7 +8,7 @@ module Emails
def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id) def reassigned_issue_email(recipient_id, issue_id, previous_assignee_id)
@issue = Issue.find(issue_id) @issue = Issue.find(issue_id)
@previous_assignee = User.find_by_id(previous_assignee_id) if previous_assignee_id @previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id
@project = @issue.project @project = @issue.project
mail(to: recipient(recipient_id), subject: subject("Changed issue ##{@issue.iid}", @issue.title)) mail(to: recipient(recipient_id), subject: subject("Changed issue ##{@issue.iid}", @issue.title))
end end
......
...@@ -8,7 +8,7 @@ module Emails ...@@ -8,7 +8,7 @@ module Emails
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)
@merge_request = MergeRequest.find(merge_request_id) @merge_request = MergeRequest.find(merge_request_id)
@previous_assignee = User.find_by_id(previous_assignee_id) if previous_assignee_id @previous_assignee = User.find_by(id: previous_assignee_id) if previous_assignee_id
@project = @merge_request.project @project = @merge_request.project
mail(to: recipient(recipient_id), subject: subject("Changed merge request ##{@merge_request.iid}", @merge_request.title)) mail(to: recipient(recipient_id), subject: subject("Changed merge request ##{@merge_request.iid}", @merge_request.title))
end end
......
...@@ -31,6 +31,11 @@ class MergeRequest < ActiveRecord::Base ...@@ -31,6 +31,11 @@ class MergeRequest < ActiveRecord::Base
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"
has_one :merge_request_diff, dependent: :destroy
after_create :create_merge_request_diff
delegate :commits, :diffs, :last_commit, :last_commit_short_sha, to: :merge_request_diff, prefix: nil
attr_accessible :title, :assignee_id, :source_project_id, :source_branch, :target_project_id, :target_branch, :milestone_id, :author_id_of_changes, :state_event, :description attr_accessible :title, :assignee_id, :source_project_id, :source_branch, :target_project_id, :target_branch, :milestone_id, :author_id_of_changes, :state_event, :description
attr_accessor :should_remove_source_branch attr_accessor :should_remove_source_branch
...@@ -53,11 +58,8 @@ class MergeRequest < ActiveRecord::Base ...@@ -53,11 +58,8 @@ class MergeRequest < ActiveRecord::Base
end end
state :opened state :opened
state :reopened state :reopened
state :closed state :closed
state :merged state :merged
end end
...@@ -75,15 +77,10 @@ class MergeRequest < ActiveRecord::Base ...@@ -75,15 +77,10 @@ class MergeRequest < ActiveRecord::Base
end end
state :unchecked state :unchecked
state :can_be_merged state :can_be_merged
state :cannot_be_merged state :cannot_be_merged
end end
serialize :st_commits
serialize :st_diffs
validates :source_project, presence: true, unless: :allow_broken validates :source_project, presence: true, unless: :allow_broken
validates :source_branch, presence: true validates :source_branch, presence: true
validates :target_project, presence: true validates :target_project, presence: true
...@@ -105,7 +102,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -105,7 +102,7 @@ class MergeRequest < ActiveRecord::Base
scope :closed, -> { with_states(:closed, :merged) } scope :closed, -> { with_states(:closed, :merged) }
def validate_branches def validate_branches
if target_project==source_project && target_branch == source_branch if target_project == source_project && target_branch == source_branch
errors.add :branch_conflict, "You can not use same project/branch for source and target" errors.add :branch_conflict, "You can not use same project/branch for source and target"
end end
...@@ -120,8 +117,7 @@ class MergeRequest < ActiveRecord::Base ...@@ -120,8 +117,7 @@ class MergeRequest < ActiveRecord::Base
end end
def reload_code def reload_code
self.reloaded_commits merge_request_diff.reload_content if opened?
self.reloaded_diffs
end end
def check_if_can_be_merged def check_if_can_be_merged
...@@ -132,42 +128,6 @@ class MergeRequest < ActiveRecord::Base ...@@ -132,42 +128,6 @@ class MergeRequest < ActiveRecord::Base
end end
end end
def diffs
@diffs ||= (load_diffs(st_diffs) || [])
end
def reloaded_diffs
if opened? && unmerged_diffs.any?
self.st_diffs = dump_diffs(unmerged_diffs)
self.save
end
end
def broken_diffs?
diffs == broken_diffs
rescue
true
end
def valid_diffs?
!broken_diffs?
end
def unmerged_diffs
diffs = if for_fork?
Gitlab::Satellite::MergeAction.new(author, self).diffs_between_satellite
else
Gitlab::Git::Diff.between(target_project.repository, source_branch, target_branch)
end
diffs ||= []
diffs
end
def last_commit
commits.first
end
def merge_event def merge_event
self.target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::MERGED).last self.target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::MERGED).last
end end
...@@ -176,46 +136,13 @@ class MergeRequest < ActiveRecord::Base ...@@ -176,46 +136,13 @@ class MergeRequest < ActiveRecord::Base
self.target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::CLOSED).last self.target_project.events.where(target_id: self.id, target_type: "MergeRequest", action: Event::CLOSED).last
end end
def commits
load_commits(st_commits || [])
end
def probably_merged?
unmerged_commits.empty? &&
commits.any? && opened?
end
def reloaded_commits
if opened? && unmerged_commits.any?
self.st_commits = dump_commits(unmerged_commits)
save
end
commits
end
def unmerged_commits
if for_fork?
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?
commits = Commit.decorate(commits).
sort_by(&:created_at).
reverse
end
commits
end
def merge!(user_id) def merge!(user_id)
self.author_id_of_changes = user_id self.author_id_of_changes = user_id
self.merge self.merge
end end
def automerge!(current_user, commit_message = nil) def automerge!(current_user, commit_message = nil)
if Gitlab::Satellite::MergeAction.new(current_user, self).merge!(commit_message) && self.unmerged_commits.empty? if Gitlab::Satellite::MergeAction.new(current_user, self).merge!(commit_message)
self.merge!(current_user.id) self.merge!(current_user.id)
true true
end end
...@@ -225,7 +152,10 @@ class MergeRequest < ActiveRecord::Base ...@@ -225,7 +152,10 @@ class MergeRequest < ActiveRecord::Base
end end
def mr_and_commit_notes def mr_and_commit_notes
commit_ids = commits.map(&:id) # Fetch comments only from last 100 commits
commits_for_notes_limit = 100
commit_ids = commits.last(commits_for_notes_limit).map(&:id)
project.notes.where( project.notes.where(
"(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))", "(noteable_type = 'MergeRequest' AND noteable_id = :mr_id) OR (noteable_type = 'Commit' AND commit_id IN (:commit_ids))",
mr_id: id, mr_id: id,
...@@ -247,10 +177,6 @@ class MergeRequest < ActiveRecord::Base ...@@ -247,10 +177,6 @@ class MergeRequest < ActiveRecord::Base
Gitlab::Satellite::MergeAction.new(current_user, self).format_patch Gitlab::Satellite::MergeAction.new(current_user, self).format_patch
end end
def last_commit_short_sha
@last_commit_short_sha ||= last_commit.sha[0..10]
end
def for_fork? def for_fork?
target_project != source_project target_project != source_project
end end
...@@ -327,34 +253,4 @@ class MergeRequest < ActiveRecord::Base ...@@ -327,34 +253,4 @@ class MergeRequest < ActiveRecord::Base
message << description.to_s message << description.to_s
message message
end end
private
def dump_commits(commits)
commits.map(&:to_hash)
end
def load_commits(array)
array.map { |hash| Commit.new(Gitlab::Git::Commit.new(hash)) }
end
def dump_diffs(diffs)
if diffs == broken_diffs
broken_diffs
elsif diffs.respond_to?(:map)
diffs.map(&:to_hash)
end
end
def load_diffs(raw)
if raw == broken_diffs
broken_diffs
elsif raw.respond_to?(:map)
raw.map { |hash| Gitlab::Git::Diff.new(hash) }
end
end
def broken_diffs
[Gitlab::Git::Diff::BROKEN_DIFF]
end
end end
require Rails.root.join("app/models/commit")
class MergeRequestDiff < ActiveRecord::Base
# Prevent store of diff
# if commits amount more then 200
COMMITS_SAFE_SIZE = 200
attr_reader :commits, :diffs
belongs_to :merge_request
attr_accessible :state, :st_commits, :st_diffs
delegate :target_branch, :source_branch, to: :merge_request, prefix: nil
state_machine :state, initial: :empty do
state :collected
state :timeout
state :overflow_commits_safe_size
state :overflow_diff_files_limit
state :overflow_diff_lines_limit
end
serialize :st_commits
serialize :st_diffs
after_create :reload_content
def reload_content
reload_commits
reload_diffs
end
def diffs
@diffs ||= (load_diffs(st_diffs) || [])
end
def commits
@commits ||= load_commits(st_commits || [])
end
def last_commit
commits.first
end
def last_commit_short_sha
@last_commit_short_sha ||= last_commit.sha[0..10]
end
private
def dump_commits(commits)
commits.map(&:to_hash)
end
def load_commits(array)
array.map { |hash| Commit.new(Gitlab::Git::Commit.new(hash)) }
end
def dump_diffs(diffs)
if diffs.respond_to?(:map)
diffs.map(&:to_hash)
end
end
def load_diffs(raw)
if raw.respond_to?(:map)
raw.map { |hash| Gitlab::Git::Diff.new(hash) }
end
end
# When Git::Diff is not able to get diff
# because of git timeout it return this value
def broken_diffs
[Gitlab::Git::Diff::BROKEN_DIFF]
end
# Collect array of Git::Commit objects
# between target and source branches
def unmerged_commits
commits = if merge_request.for_fork?
Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).commits_between
else
repository.commits_between(target_branch, source_branch)
end
if commits.present?
commits = Commit.decorate(commits).
sort_by(&:created_at).
reverse
end
commits
end
# Reload all commits related to current merge request from repo
# and save it as array of hashes in st_commits db field
def reload_commits
commit_objects = unmerged_commits
if commit_objects.present?
self.st_commits = dump_commits(commit_objects)
end
save
end
# Reload diffs between branches related to current merge request from repo
# and save it as array of hashes in st_diffs db field
def reload_diffs
new_diffs = []
if commits.size.zero?
self.state = :empty
elsif commits.size > COMMITS_SAFE_SIZE
self.state = :overflow_commits_safe_size
else
new_diffs = unmerged_diffs
end
if new_diffs.any?
if new_diffs.size > Commit::DIFF_HARD_LIMIT_FILES
self.state = :overflow_diff_files_limit
new_diffs = []
end
if new_diffs.sum { |diff| diff.diff.lines.count } > Commit::DIFF_HARD_LIMIT_LINES
self.state = :overflow_diff_lines_limit
new_diffs = []
end
end
if new_diffs.present?
new_diffs = dump_commits(new_diffs)
self.state = :collected
end
self.st_diffs = new_diffs
self.save
end
# Collect array of Git::Diff objects
# between target and source branches
def unmerged_diffs
diffs = if merge_request.for_fork?
Gitlab::Satellite::MergeAction.new(merge_request.author, merge_request).diffs_between_satellite
else
Gitlab::Git::Diff.between(repository, source_branch, target_branch)
end
if diffs == broken_diffs
self.state = :timeout
diffs = []
end
diffs ||= []
diffs
end
def repository
merge_request.target_project.repository
end
end
...@@ -123,8 +123,8 @@ class Note < ActiveRecord::Base ...@@ -123,8 +123,8 @@ class Note < ActiveRecord::Base
def commit_author def commit_author
@commit_author ||= @commit_author ||=
project.users.find_by_email(noteable.author_email) || project.users.find_by(email: noteable.author_email) ||
project.users.find_by_name(noteable.author_name) project.users.find_by(name: noteable.author_name)
rescue rescue
nil nil
end end
......
...@@ -145,10 +145,10 @@ class Project < ActiveRecord::Base ...@@ -145,10 +145,10 @@ class Project < ActiveRecord::Base
def find_with_namespace(id) def find_with_namespace(id)
if id.include?("/") if id.include?("/")
id = id.split("/") id = id.split("/")
namespace = Namespace.find_by_path(id.first) namespace = Namespace.find_by(path: id.first)
return nil unless namespace return nil unless namespace
where(namespace_id: namespace.id).find_by_path(id.second) where(namespace_id: namespace.id).find_by(path: id.second)
else else
where(path: id, namespace_id: nil).last where(path: id, namespace_id: nil).last
end end
...@@ -296,7 +296,7 @@ class Project < ActiveRecord::Base ...@@ -296,7 +296,7 @@ class Project < ActiveRecord::Base
# Get Team Member record by user id # Get Team Member record by user id
def team_member_by_id(user_id) def team_member_by_id(user_id)
users_projects.find_by_user_id(user_id) users_projects.find_by(user_id: user_id)
end end
def name_with_namespace def name_with_namespace
......
...@@ -16,6 +16,8 @@ ...@@ -16,6 +16,8 @@
# #
class AssemblaService < Service class AssemblaService < Service
attr_accessible :subdomain
include HTTParty include HTTParty
validates :token, presence: true, if: :activated? validates :token, presence: true, if: :activated?
...@@ -34,12 +36,13 @@ class AssemblaService < Service ...@@ -34,12 +36,13 @@ class AssemblaService < Service
def fields def fields
[ [
{ type: 'text', name: 'token', placeholder: '' } { type: 'text', name: 'token', placeholder: '' },
{ type: 'text', name: 'subdomain', placeholder: '' }
] ]
end end
def execute(push) def execute(push)
url = "https://atlas.assembla.com/spaces/ouposp/github_tool?secret_key=#{token}" url = "https://atlas.assembla.com/spaces/#{subdomain}/github_tool?secret_key=#{token}"
AssemblaService.post(url, body: { payload: push }.to_json, headers: { 'Content-Type' => 'application/json' }) AssemblaService.post(url, body: { payload: push }.to_json, headers: { 'Content-Type' => 'application/json' })
end end
end end
...@@ -22,22 +22,22 @@ class ProjectTeam ...@@ -22,22 +22,22 @@ class ProjectTeam
end end
def find(user_id) def find(user_id)
user = project.users.find_by_id(user_id) user = project.users.find_by(id: user_id)
if group if group
user ||= group.users.find_by_id(user_id) user ||= group.users.find_by(id: user_id)
end end
user user
end end
def find_tm(user_id) def find_tm(user_id)
tm = project.users_projects.find_by_user_id(user_id) tm = project.users_projects.find_by(user_id: user_id)
# If user is not in project members # If user is not in project members
# we should check for group membership # we should check for group membership
if group && !tm if group && !tm
tm = group.users_groups.find_by_user_id(user_id) tm = group.users_groups.find_by(user_id: user_id)
end end
tm tm
......
...@@ -239,7 +239,7 @@ class User < ActiveRecord::Base ...@@ -239,7 +239,7 @@ class User < ActiveRecord::Base
def namespace_uniq def namespace_uniq
namespace_name = self.username namespace_name = self.username
if Namespace.find_by_path(namespace_name) if Namespace.find_by(path: namespace_name)
self.errors.add :username, "already exist" self.errors.add :username, "already exist"
end end
end end
...@@ -383,7 +383,7 @@ class User < ActiveRecord::Base ...@@ -383,7 +383,7 @@ class User < ActiveRecord::Base
end end
def created_by def created_by
User.find_by_id(created_by_id) if created_by_id User.find_by(id: created_by_id) if created_by_id
end end
def sanitize_attrs def sanitize_attrs
......
...@@ -195,10 +195,10 @@ class NotificationService ...@@ -195,10 +195,10 @@ class NotificationService
users.reject do |user| users.reject do |user|
next user.notification.disabled? unless project next user.notification.disabled? unless project
tm = project.users_projects.find_by_user_id(user.id) tm = project.users_projects.find_by(user_id: user.id)
if !tm && project.group if !tm && project.group
tm = project.group.users_groups.find_by_user_id(user.id) tm = project.group.users_groups.find_by(user_id: user.id)
end end
# reject users who globally disabled notification and has no membership # reject users who globally disabled notification and has no membership
......
...@@ -73,7 +73,7 @@ module Projects ...@@ -73,7 +73,7 @@ module Projects
end end
def allowed_namespace?(user, namespace_id) def allowed_namespace?(user, namespace_id)
namespace = Namespace.find_by_id(namespace_id) namespace = Namespace.find_by(id: namespace_id)
current_user.can?(:manage_namespace, namespace) current_user.can?(:manage_namespace, namespace)
end end
end end
......
...@@ -15,7 +15,7 @@ module Search ...@@ -15,7 +15,7 @@ module Search
authorized_projects_ids += current_user.authorized_projects.pluck(:id) if current_user authorized_projects_ids += current_user.authorized_projects.pluck(:id) if current_user
authorized_projects_ids += Project.public_or_internal_only(current_user).pluck(:id) authorized_projects_ids += Project.public_or_internal_only(current_user).pluck(:id)
group = Group.find_by_id(params[:group_id]) if params[:group_id].present? group = Group.find_by(id: params[:group_id]) if params[:group_id].present?
projects = Project.where(id: authorized_projects_ids) projects = Project.where(id: authorized_projects_ids)
projects = projects.where(namespace_id: group.id) if group projects = projects.where(namespace_id: group.id) if group
projects = projects.search(query) projects = projects.search(query)
......
.row .row
.col-md-3{:"data-spy" => 'affix'} .col-md-3
%h3.page-title Help %h3.page-title Help
%ul.nav.nav-pills.nav-stacked %ul.nav.nav-pills.nav-stacked
- links = {:"Workflow" => help_workflow_path, :"SSH Keys" => help_ssh_path, :"GitLab Markdown" => help_markdown_path, :"Permissions" => help_permissions_path, :"API" => help_api_path, :"Web Hooks" => help_web_hooks_path, :"Rake Tasks" => help_raketasks_path, :"System Hooks" => help_system_hooks_path, :"Public Access" => help_public_access_path, :"Security" => help_security_path} - links = {:"Workflow" => help_workflow_path, :"SSH Keys" => help_ssh_path, :"GitLab Markdown" => help_markdown_path, :"Permissions" => help_permissions_path, :"API" => help_api_path, :"Web Hooks" => help_web_hooks_path, :"Rake Tasks" => help_raketasks_path, :"System Hooks" => help_system_hooks_path, :"Public Access" => help_public_access_path, :"Security" => help_security_path}
...@@ -7,5 +7,5 @@ ...@@ -7,5 +7,5 @@
%li{class: current_page?(path) ? 'active' : nil} %li{class: current_page?(path) ? 'active' : nil}
= link_to title, path = link_to title, path
.col-md-9.pull-right .col-md-9
= yield = yield
...@@ -5,13 +5,24 @@ ...@@ -5,13 +5,24 @@
SSH key allows you to establish a secure connection between your computer and GitLab SSH key allows you to establish a secure connection between your computer and GitLab
%p.slead %p.slead
To generate a new SSH key just open your terminal and use code below. Press enter to accept the defaults when generating the key. Before generating an SSH key, check if your system already has one by running cat ~/.ssh/id_rsa.pub
If your see a long string starting with 'ssh-rsa' or 'ssh-dsa', you can skip the ssh-keygen step.
%p.slead
To generate a new SSH key just open your terminal and use code below. The ssh-keygen command prompts you for a location and filename to store the key pair and for a password.
When prompted for the location and filename you can press enter to use the default.
It is a best practice to use a password for an SSH key but it is not required and you can skip creating a password by pressing enter.
Note that the password you choose here can't be altered or retrieved.
%pre.dark %pre.dark
ssh-keygen -t rsa -C "#{current_user.email}" ssh-keygen -t rsa -C "#{current_user.email}"
%p.slead %p.slead
Next just use code below to dump your public key and add to GitLab SSH Keys Use code below to show your public key.
%pre.dark %pre.dark
cat ~/.ssh/id_rsa.pub cat ~/.ssh/id_rsa.pub
%p.slead
Copy-paste the key to the 'My SSH Keys' section under the 'SSH' tab in your user profile.
Please copy the complete key starting with 'ssh-' and ending with your username and host.
...@@ -2,5 +2,7 @@ ...@@ -2,5 +2,7 @@
.commit-row-title .commit-row-title
= link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id" = link_to commit.short_id(8), project_commit_path(project, commit), class: "commit_short_id"
&nbsp; &nbsp;
= link_to_gfm truncate(commit.title, length: 40), project_commit_path(project, commit.id), class: "commit-row-message" %span.str-truncated
#{time_ago_with_tooltip(commit.committed_date)} &nbsp; = link_to_gfm commit.title, project_commit_path(project, commit.id), class: "commit-row-message"
.pull-right
#{time_ago_with_tooltip(commit.committed_date)}
...@@ -12,9 +12,16 @@ ...@@ -12,9 +12,16 @@
8 of #{@commits.count} commits displayed. 8 of #{@commits.count} commits displayed.
%strong %strong
%a.show-all-commits Click here to show all %a.show-all-commits Click here to show all
- if @commits.size > MergeRequestDiff::COMMITS_SAFE_SIZE
%ul.all-commits.hide.well-list
- @commits.first(MergeRequestDiff::COMMITS_SAFE_SIZE).each do |commit|
= render "projects/commits/inline_commit", commit: commit, project: @merge_request.source_project
%li
other #{@commits.size - MergeRequestDiff::COMMITS_SAFE_SIZE} commits hidden top prevent performance issues.
- else
%ul.all-commits.hide.well-list %ul.all-commits.hide.well-list
- @commits.each do |commit| - @commits.each do |commit|
= render "projects/commits/commit", commit: commit, project: @merge_request.source_project = render "projects/commits/inline_commit", commit: commit, project: @merge_request.source_project
- else - else
%ul.well-list %ul.well-list
......
- if @merge_request.valid_diffs? - if @merge_request_diff.collected?
= render "projects/commits/diffs", diffs: @merge_request.diffs, project: @merge_request.source_project = render "projects/commits/diffs", diffs: @merge_request.diffs, project: @merge_request.source_project
- elsif @merge_request.broken_diffs? - elsif @merge_request_diff.empty?
%h4.nothing_here_message Nothing to merge from #{@merge_request.source_branch} into #{@merge_request.target_branch}
- else
%h4.nothing_here_message %h4.nothing_here_message
Can't load diff. Can't load diff.
You can You can
= link_to "download it", project_merge_request_path(@merge_request.source_project, @merge_request), format: :diff, class: "vlink" = link_to "download it", project_merge_request_path(@merge_request.source_project, @merge_request), format: :diff, class: "vlink"
instead. instead.
- else
%h4.nothing_here_message Nothing to merge
:plain :plain
$(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}"); $(".target_branch").html("#{escape_javascript(options_for_select(@target_branches))}");
$(".target_branch").trigger("select2:updated");
$('select.target_branch').select2({
width: 'resolve',
dropdownAutoWidth: true
});
$(".mr_target_commit").html(""); $(".mr_target_commit").html("");
$(".target_branch").trigger("change");
# This file is used by Rack-based servers to start the application. # This file is used by Rack-based servers to start the application.
unless defined?(PhusionPassenger) if defined?(Unicorn)
require 'unicorn' require 'unicorn'
# Unicorn self-process killer # Unicorn self-process killer
require 'unicorn/worker_killer' require 'unicorn/worker_killer'
......
...@@ -19,7 +19,7 @@ project_urls = [ ...@@ -19,7 +19,7 @@ project_urls = [
project_urls.each_with_index do |url, i| project_urls.each_with_index do |url, i|
group_path, project_path = url.split('/')[-2..-1] group_path, project_path = url.split('/')[-2..-1]
group = Group.find_by_path(group_path) group = Group.find_by(path: group_path)
unless group unless group
group = Group.new( group = Group.new(
...@@ -40,7 +40,7 @@ project_urls.each_with_index do |url, i| ...@@ -40,7 +40,7 @@ project_urls.each_with_index do |url, i|
description: Faker::Lorem.sentence description: Faker::Lorem.sentence
} }
project = Projects::CreateContext.new(User.first, params).execute project = Projects::CreateService.new(User.first, params).execute
if project.valid? if project.valid?
print '.' print '.'
......
...@@ -4,7 +4,7 @@ class RemoveProjectIdFromKey < ActiveRecord::Migration ...@@ -4,7 +4,7 @@ class RemoveProjectIdFromKey < ActiveRecord::Migration
Key.where('project_id IS NOT NULL').update_all(type: 'DeployKey') Key.where('project_id IS NOT NULL').update_all(type: 'DeployKey')
DeployKey.all.each do |key| DeployKey.all.each do |key|
project = Project.find_by_id(key.project_id) project = Project.find_by(id: key.project_id)
if project if project
project.deploy_keys << key project.deploy_keys << key
print '.' print '.'
......
class CreateMergeRequestDiffs < ActiveRecord::Migration
def change
create_table :merge_request_diffs do |t|
t.string :state, null: false, default: 'collected'
t.text :st_commits, null: true, limit: 2147483647
t.text :st_diffs, null: true, limit: 2147483647
t.integer :merge_request_id, null: false
t.timestamps
end
end
end
class MigrateMrDiffs < ActiveRecord::Migration
def self.up
execute "INSERT INTO merge_request_diffs ( merge_request_id ) SELECT id FROM merge_requests"
execute "UPDATE merge_requests mr, merge_request_diffs md SET md.st_commits = mr.st_commits WHERE md.merge_request_id = mr.id"
execute "UPDATE merge_requests mr, merge_request_diffs md SET md.st_diffs = mr.st_diffs WHERE md.merge_request_id = mr.id"
end
def self.down
MergeRequestDiff.delete_all
end
end
class RemoveMRdiffFields < ActiveRecord::Migration
def up
remove_column :merge_requests, :st_commits
remove_column :merge_requests, :st_diffs
end
def down
add_column :merge_requests, :st_commits, :text, null: true, limit: 2147483647
add_column :merge_requests, :st_diffs, :text, null: true, limit: 2147483647
execute "UPDATE merge_requests mr, merge_request_diffs md SET mr.st_commits = md.st_commits WHERE md.merge_request_id = mr.id"
execute "UPDATE merge_requests mr, merge_request_diffs md SET mr.st_diffs = md.st_diffs WHERE md.merge_request_id = mr.id"
end
end
...@@ -11,7 +11,7 @@ ...@@ -11,7 +11,7 @@
# #
# It's strongly recommended that you check this file into your version control system. # It's strongly recommended that you check this file into your version control system.
ActiveRecord::Schema.define(version: 20140116231608) do ActiveRecord::Schema.define(version: 20140122122549) do
create_table "broadcast_messages", force: true do |t| create_table "broadcast_messages", force: true do |t|
t.text "message", null: false t.text "message", null: false
...@@ -66,8 +66,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -66,8 +66,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do
t.integer "assignee_id" t.integer "assignee_id"
t.integer "author_id" t.integer "author_id"
t.integer "project_id" t.integer "project_id"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.integer "position", default: 0 t.integer "position", default: 0
t.string "branch_name" t.string "branch_name"
t.text "description" t.text "description"
...@@ -85,8 +85,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -85,8 +85,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do
create_table "keys", force: true do |t| create_table "keys", force: true do |t|
t.integer "user_id" t.integer "user_id"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.text "key" t.text "key"
t.string "title" t.string "title"
t.string "type" t.string "type"
...@@ -95,6 +95,15 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -95,6 +95,15 @@ ActiveRecord::Schema.define(version: 20140116231608) do
add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree add_index "keys", ["user_id"], name: "index_keys_on_user_id", using: :btree
create_table "merge_request_diffs", force: true do |t|
t.string "state", default: "collected", null: false
t.text "st_commits", limit: 2147483647
t.text "st_diffs", limit: 2147483647
t.integer "merge_request_id", null: false
t.datetime "created_at"
t.datetime "updated_at"
end
create_table "merge_requests", force: true do |t| create_table "merge_requests", force: true do |t|
t.string "target_branch", null: false t.string "target_branch", null: false
t.string "source_branch", null: false t.string "source_branch", null: false
...@@ -102,10 +111,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -102,10 +111,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do
t.integer "author_id" t.integer "author_id"
t.integer "assignee_id" t.integer "assignee_id"
t.string "title" t.string "title"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.text "st_commits", limit: 2147483647
t.text "st_diffs", limit: 2147483647
t.integer "milestone_id" t.integer "milestone_id"
t.string "state" t.string "state"
t.string "merge_status" t.string "merge_status"
...@@ -156,8 +163,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -156,8 +163,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do
t.text "note" t.text "note"
t.string "noteable_type" t.string "noteable_type"
t.integer "author_id" t.integer "author_id"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.integer "project_id" t.integer "project_id"
t.string "attachment" t.string "attachment"
t.string "line_code" t.string "line_code"
...@@ -179,8 +186,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -179,8 +186,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do
t.string "name" t.string "name"
t.string "path" t.string "path"
t.text "description" t.text "description"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.integer "creator_id" t.integer "creator_id"
t.boolean "issues_enabled", default: true, null: false t.boolean "issues_enabled", default: true, null: false
t.boolean "wall_enabled", default: true, null: false t.boolean "wall_enabled", default: true, null: false
...@@ -231,8 +238,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -231,8 +238,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do
t.text "content", limit: 2147483647 t.text "content", limit: 2147483647
t.integer "author_id", null: false t.integer "author_id", null: false
t.integer "project_id" t.integer "project_id"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.string "file_name" t.string "file_name"
t.datetime "expires_at" t.datetime "expires_at"
t.boolean "private", default: true, null: false t.boolean "private", default: true, null: false
...@@ -254,16 +261,13 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -254,16 +261,13 @@ ActiveRecord::Schema.define(version: 20140116231608) do
t.datetime "created_at" t.datetime "created_at"
end end
add_index "taggings", ["tag_id"], name: "index_taggings_on_tag_id", using: :btree
add_index "taggings", ["taggable_id", "taggable_type", "context"], name: "index_taggings_on_taggable_id_and_taggable_type_and_context", using: :btree
create_table "tags", force: true do |t| create_table "tags", force: true do |t|
t.string "name" t.string "name"
end end
create_table "users", force: true do |t| create_table "users", force: true do |t|
t.string "email", default: "", null: false t.string "email", default: "", null: false
t.string "encrypted_password", default: "", null: false t.string "encrypted_password", limit: 128, default: "", null: false
t.string "reset_password_token" t.string "reset_password_token"
t.datetime "reset_password_sent_at" t.datetime "reset_password_sent_at"
t.datetime "remember_created_at" t.datetime "remember_created_at"
...@@ -272,8 +276,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -272,8 +276,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do
t.datetime "last_sign_in_at" t.datetime "last_sign_in_at"
t.string "current_sign_in_ip" t.string "current_sign_in_ip"
t.string "last_sign_in_ip" t.string "last_sign_in_ip"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.string "name" t.string "name"
t.boolean "admin", default: false, null: false t.boolean "admin", default: false, null: false
t.integer "projects_limit", default: 10 t.integer "projects_limit", default: 10
...@@ -308,7 +312,6 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -308,7 +312,6 @@ ActiveRecord::Schema.define(version: 20140116231608) do
add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree add_index "users", ["authentication_token"], name: "index_users_on_authentication_token", unique: true, using: :btree
add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree add_index "users", ["confirmation_token"], name: "index_users_on_confirmation_token", unique: true, using: :btree
add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree add_index "users", ["email"], name: "index_users_on_email", unique: true, using: :btree
add_index "users", ["extern_uid", "provider"], name: "index_users_on_extern_uid_and_provider", unique: true, using: :btree
add_index "users", ["name"], name: "index_users_on_name", using: :btree add_index "users", ["name"], name: "index_users_on_name", using: :btree
add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree add_index "users", ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true, using: :btree
add_index "users", ["username"], name: "index_users_on_username", using: :btree add_index "users", ["username"], name: "index_users_on_username", using: :btree
...@@ -327,8 +330,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -327,8 +330,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do
create_table "users_projects", force: true do |t| create_table "users_projects", force: true do |t|
t.integer "user_id", null: false t.integer "user_id", null: false
t.integer "project_id", null: false t.integer "project_id", null: false
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.integer "project_access", default: 0, null: false t.integer "project_access", default: 0, null: false
t.integer "notification_level", default: 3, null: false t.integer "notification_level", default: 3, null: false
end end
...@@ -340,8 +343,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do ...@@ -340,8 +343,8 @@ ActiveRecord::Schema.define(version: 20140116231608) do
create_table "web_hooks", force: true do |t| create_table "web_hooks", force: true do |t|
t.string "url" t.string "url"
t.integer "project_id" t.integer "project_id"
t.datetime "created_at", null: false t.datetime "created_at"
t.datetime "updated_at", null: false t.datetime "updated_at"
t.string "type", default: "ProjectHook" t.string "type", default: "ProjectHook"
t.integer "service_id" t.integer "service_id"
t.boolean "push_events", default: true, null: false t.boolean "push_events", default: true, null: false
......
...@@ -10,7 +10,7 @@ If this is unclear check the [GitLab Blog](http://blog.gitlab.org/) for installa ...@@ -10,7 +10,7 @@ If this is unclear check the [GitLab Blog](http://blog.gitlab.org/) for installa
This guide is long because it covers many cases and includes all commands you need, this is [one of the few installation scripts that actually works out of the box](https://twitter.com/robinvdvleuten/status/424163226532986880). This guide is long because it covers many cases and includes all commands you need, this is [one of the few installation scripts that actually works out of the box](https://twitter.com/robinvdvleuten/status/424163226532986880).
This installation guide was created for and tested on **Debian/Ubuntu** operating systems. Please read [`doc/install/requirements.md`](./requirements.md) for hardware and operating system requirements. This installation guide was created for and tested on **Debian/Ubuntu** operating systems. Please read [doc/install/requirements.md](./requirements.md) for hardware and operating system requirements.
This is the official installation guide to set up a production server. To set up a **development installation** or for many other installation options please consult [the installation section in the readme](https://github.com/gitlabhq/gitlabhq#installation). This is the official installation guide to set up a production server. To set up a **development installation** or for many other installation options please consult [the installation section in the readme](https://github.com/gitlabhq/gitlabhq#installation).
...@@ -113,6 +113,8 @@ Then select 'Internet Site' and press enter to confirm the hostname. ...@@ -113,6 +113,8 @@ Then select 'Internet Site' and press enter to confirm the hostname.
# 2. Ruby # 2. Ruby
The use of ruby version managers such as [RVM](http://rvm.io/), [rbenv](https://github.com/sstephenson/rbenv) or [chruby](https://github.com/postmodern/chruby) with GitLab in production frequently leads to hard to diagnose problems. Version managers are not supported and we stronly advise everyone to follow the instructions below to use a system ruby.
Remove the old Ruby 1.8 if present Remove the old Ruby 1.8 if present
sudo apt-get remove ruby1.8 sudo apt-get remove ruby1.8
......
GitLab has a great issue tracker but you can also use an external issue tracker such as JIRA or Redmine. This is something that you can turn on per GitLab project. If for example you configure JIRA it provides the following functionality:
- the 'Issues' link on the GitLab project pages takes you to the appropriate JIRA issue index;
- clicking 'New issue' on the project dashboard creates a new JIRA issue;
- textual references to PROJECT-1234 in comments, commit messages get turned into HTML links to the corresponding JIRA issue.
![jira screenshot](jira-intergration-points.png)
...@@ -58,12 +58,13 @@ Check if changed since last release (~22nd of last month depending on when last ...@@ -58,12 +58,13 @@ Check if changed since last release (~22nd of last month depending on when last
After making the release branch new commits are cherry-picked from master. When the release gets closer we get more selective what is cherry-picked. The days of the month are approximately as follows: After making the release branch new commits are cherry-picked from master. When the release gets closer we get more selective what is cherry-picked. The days of the month are approximately as follows:
* 17th: feature freeze (branch and stop merging new features) * 17th: feature freeze (stop merging new features in master)
* 18th: UI freeze (stop cherry-picking changes to the user interface) * 18th: UI freeze (stop merging changes to the user interface)
* 19th: code freeze (stop cherry-picking non-essential code improvements) * 19th: code freeze (stop merging non-essential code improvements)
* 20th: release candidate 1 (tag and tweet about x.x.rc1) * 20th: release candidate 1 (VERSION x.x.0.pre, tag and tweet about x.x.0.rc1)
* 21st: release candidate 2 (optional, only if rc1 had problems) * 21st: optional release candidate 2 (x.x.0.rc2, only if rc1 had problems)
* 22nd: release (update VERSION and CHANGELOG, tag, blog and tweet) * 22nd: release (VERSION x.x.0, create x-x-stable branch, tag, blog and tweet)
* 23nd: optional patch releases (x.x.1, x.x.2, etc., only if there are serious problems)
# Write a blog post # Write a blog post
......
# From 6.0 to 6.4 # From 6.0 to 6.5
# In 6.1 we remove a lot of deprecated code. # In 6.1 we remove a lot of deprecated code.
# You should update to 6.0 before installing 6.1 or higher so all the necessary conversions are run. # You should update to 6.0 before installing 6.1 or higher so all the necessary conversions are run.
...@@ -28,8 +28,8 @@ sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production ...@@ -28,8 +28,8 @@ sudo -u git -H bundle exec rake gitlab:backup:create RAILS_ENV=production
```bash ```bash
cd /home/git/gitlab cd /home/git/gitlab
sudo -u git -H git fetch --all sudo -u git -H git fetch --all
sudo -u git -H git checkout 6-4-stable sudo -u git -H git checkout 6-5-stable
# For GitLab Enterprise Edition: sudo -u git -H git checkout 6-4-stable-ee # For GitLab Enterprise Edition: sudo -u git -H git checkout 6-5-stable-ee
``` ```
...@@ -72,11 +72,11 @@ sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production ...@@ -72,11 +72,11 @@ sudo -u git -H bundle exec rake cache:clear RAILS_ENV=production
TIP: to see what changed in gitlab.yml.example in this release use next command: TIP: to see what changed in gitlab.yml.example in this release use next command:
``` ```
git diff 6-0-stable:config/gitlab.yml.example 6-4-stable:config/gitlab.yml.example git diff 6-0-stable:config/gitlab.yml.example 6-5-stable:config/gitlab.yml.example
``` ```
* Make `/home/git/gitlab/config/gitlab.yml` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-4-stable/config/gitlab.yml.example but with your settings. * Make `/home/git/gitlab/config/gitlab.yml` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-5-stable/config/gitlab.yml.example but with your settings.
* Make `/home/git/gitlab/config/unicorn.rb` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-4-stable/config/unicorn.rb.example but with your settings. * Make `/home/git/gitlab/config/unicorn.rb` same as https://gitlab.com/gitlab-org/gitlab-ce/blob/6-5-stable/config/unicorn.rb.example but with your settings.
* Copy rack attack middleware config * Copy rack attack middleware config
```bash ```bash
......
...@@ -55,18 +55,18 @@ Feature: Project Merge Requests ...@@ -55,18 +55,18 @@ Feature: Project Merge Requests
Given project "Shop" have "Bug NS-05" open merge request with diffs inside Given project "Shop" have "Bug NS-05" open merge request with diffs inside
And I visit merge request page "Bug NS-05" And I visit merge request page "Bug NS-05"
And I click on the first commit in the merge request And I click on the first commit in the merge request
And I leave a comment like "Line is wrong" on line 185 of the first file And I leave a comment like "Line is wrong" on line 185 of the first file in commit
And I switch to the merge request's comments tab And I switch to the merge request's comments tab
Then I should see a discussion has started on commit bcf03b5de6c:L185 Then I should see a discussion has started on commit b1e6a9dbf1:L185
@javascript @javascript
Scenario: I comment on a commit in merge request Scenario: I comment on a commit in merge request
Given project "Shop" have "Bug NS-05" open merge request with diffs inside Given project "Shop" have "Bug NS-05" open merge request with diffs inside
And I visit merge request page "Bug NS-05" And I visit merge request page "Bug NS-05"
And I click on the first commit in the merge request And I click on the first commit in the merge request
And I leave a comment on the diff page And I leave a comment on the diff page in commit
And I switch to the merge request's comments tab And I switch to the merge request's comments tab
Then I should see a discussion has started on commit bcf03b5de6c Then I should see a discussion has started on commit b1e6a9dbf1
@javascript @javascript
Scenario: I accept merge request with custom commit message Scenario: I accept merge request with custom commit message
......
...@@ -40,7 +40,7 @@ class AdminGroups < Spinach::FeatureSteps ...@@ -40,7 +40,7 @@ class AdminGroups < Spinach::FeatureSteps
end end
When 'I select user "John" from user list as "Reporter"' do When 'I select user "John" from user list as "Reporter"' do
user = User.find_by_name("John") user = User.find_by(name: "John")
select2(user.id, from: "#user_ids", multiple: true) select2(user.id, from: "#user_ids", multiple: true)
within "#new_team_member" do within "#new_team_member" do
select "Reporter", from: "group_access" select "Reporter", from: "group_access"
......
...@@ -43,7 +43,7 @@ class Dashboard < Spinach::FeatureSteps ...@@ -43,7 +43,7 @@ class Dashboard < Spinach::FeatureSteps
end end
And 'user with name "John Doe" left project "Shop"' do And 'user with name "John Doe" left project "Shop"' do
user = User.find_by_name "John Doe" user = User.find_by(name: "John Doe")
Event.create( Event.create(
project: project, project: project,
author_id: user.id, author_id: user.id,
...@@ -85,6 +85,6 @@ class Dashboard < Spinach::FeatureSteps ...@@ -85,6 +85,6 @@ class Dashboard < Spinach::FeatureSteps
end end
def project def project
@project ||= Project.find_by_name "Shop" @project ||= Project.find_by(name: "Shop")
end end
end end
...@@ -66,7 +66,7 @@ class DashboardIssues < Spinach::FeatureSteps ...@@ -66,7 +66,7 @@ class DashboardIssues < Spinach::FeatureSteps
def project def project
@project ||= begin @project ||= begin
project =create :project_with_code project =create :project
project.team << [current_user, :master] project.team << [current_user, :master]
project project
end end
......
...@@ -66,7 +66,7 @@ class DashboardMergeRequests < Spinach::FeatureSteps ...@@ -66,7 +66,7 @@ class DashboardMergeRequests < Spinach::FeatureSteps
def project def project
@project ||= begin @project ||= begin
project =create :project_with_code project =create :project
project.team << [current_user, :master] project.team << [current_user, :master]
project project
end end
......
...@@ -4,7 +4,7 @@ class DashboardWithArchivedProjects < Spinach::FeatureSteps ...@@ -4,7 +4,7 @@ class DashboardWithArchivedProjects < Spinach::FeatureSteps
include SharedProject include SharedProject
When 'project "Forum" is archived' do When 'project "Forum" is archived' do
project = Project.find_by_name "Forum" project = Project.find_by(name: "Forum")
project.update_attribute(:archived, true) project.update_attribute(:archived, true)
end end
......
...@@ -39,7 +39,7 @@ class Groups < Spinach::FeatureSteps ...@@ -39,7 +39,7 @@ class Groups < Spinach::FeatureSteps
end end
And 'I select user "John" from list with role "Reporter"' do And 'I select user "John" from list with role "Reporter"' do
user = User.find_by_name("John") user = User.find_by(name: "John")
within ".users-group-form" do within ".users-group-form" do
select2(user.id, from: "#user_ids", multiple: true) select2(user.id, from: "#user_ids", multiple: true)
select "Reporter", from: "group_access" select "Reporter", from: "group_access"
......
...@@ -18,7 +18,7 @@ class ProfileSshKeys < Spinach::FeatureSteps ...@@ -18,7 +18,7 @@ class ProfileSshKeys < Spinach::FeatureSteps
end end
Then 'I should see new ssh key "Laptop"' do Then 'I should see new ssh key "Laptop"' do
key = Key.find_by_title("Laptop") key = Key.find_by(title: "Laptop")
page.should have_content(key.title) page.should have_content(key.title)
page.should have_content(key.key) page.should have_content(key.key)
current_path.should == profile_key_path(key) current_path.should == profile_key_path(key)
......
...@@ -34,7 +34,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps ...@@ -34,7 +34,7 @@ class Spinach::Features::ProjectDeployKeys < Spinach::FeatureSteps
end end
step 'other project has deploy key' do step 'other project has deploy key' do
@second_project = create :project, namespace: current_user.namespace @second_project = create :project, namespace: create(:group)
@second_project.team << [current_user, :master] @second_project.team << [current_user, :master]
create(:deploy_keys_project, project: @second_project) create(:deploy_keys_project, project: @second_project)
end end
......
...@@ -4,17 +4,17 @@ class ProjectArchived < Spinach::FeatureSteps ...@@ -4,17 +4,17 @@ class ProjectArchived < Spinach::FeatureSteps
include SharedPaths include SharedPaths
When 'project "Forum" is archived' do When 'project "Forum" is archived' do
project = Project.find_by_name "Forum" project = Project.find_by(name: "Forum")
project.update_attribute(:archived, true) project.update_attribute(:archived, true)
end end
When 'project "Shop" is archived' do When 'project "Shop" is archived' do
project = Project.find_by_name "Shop" project = Project.find_by(name: "Shop")
project.update_attribute(:archived, true) project.update_attribute(:archived, true)
end end
When 'I visit project "Forum" page' do When 'I visit project "Forum" page' do
project = Project.find_by_name "Forum" project = Project.find_by(name: "Forum")
visit project_path(project) visit project_path(project)
end end
......
...@@ -29,7 +29,7 @@ class ProjectBrowseBranches < Spinach::FeatureSteps ...@@ -29,7 +29,7 @@ class ProjectBrowseBranches < Spinach::FeatureSteps
end end
And 'project "Shop" has protected branches' do And 'project "Shop" has protected branches' do
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
project.protected_branches.create(name: "stable") project.protected_branches.create(name: "stable")
end end
end end
...@@ -11,22 +11,22 @@ class ForkProject < Spinach::FeatureSteps ...@@ -11,22 +11,22 @@ class ForkProject < Spinach::FeatureSteps
end end
step 'I am a member of project "Shop"' do step 'I am a member of project "Shop"' do
@project = Project.find_by_name "Shop" @project = Project.find_by(name: "Shop")
@project ||= create(:project_with_code, name: "Shop", group: create(:group)) @project ||= create(:project, name: "Shop", group: create(:group))
@project.team << [@user, :reporter] @project.team << [@user, :reporter]
end end
step 'I should see the forked project page' do step 'I should see the forked project page' do
page.should have_content "Project was successfully forked." page.should have_content "Project was successfully forked."
current_path.should include current_user.namespace.path current_path.should include current_user.namespace.path
@forked_project = Project.find_by_namespace_id(current_user.namespace.path) @forked_project = Project.find_by(namespace_id: current_user.namespace.path)
end end
step 'I already have a project named "Shop" in my namespace' do step 'I already have a project named "Shop" in my namespace' do
current_user.namespace ||= create(:namespace) current_user.namespace ||= create(:namespace)
current_user.namespace.should_not be_nil current_user.namespace.should_not be_nil
current_user.namespace.path.should_not be_nil current_user.namespace.path.should_not be_nil
@my_project = create(:project_with_code, name: "Shop", namespace: current_user.namespace) @my_project = create(:project, name: "Shop", namespace: current_user.namespace)
end end
step 'I should see a "Name has already been taken" warning' do step 'I should see a "Name has already been taken" warning' do
......
...@@ -6,16 +6,16 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -6,16 +6,16 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
include Select2Helper include Select2Helper
step 'I am a member of project "Shop"' do step 'I am a member of project "Shop"' do
@project = Project.find_by_name "Shop" @project = Project.find_by(name: "Shop")
@project ||= create(:project_with_code, name: "Shop") @project ||= create(:project, name: "Shop")
@project.team << [@user, :reporter] @project.team << [@user, :reporter]
end end
step 'I have a project forked off of "Shop" called "Forked Shop"' do step 'I have a project forked off of "Shop" called "Forked Shop"' do
@forking_user = @user @forking_user = @user
forked_project_link = build(:forked_project_link) forked_project_link = build(:forked_project_link)
@forked_project = Project.find_by_name "Forked Shop" @forked_project = Project.find_by(name: "Forked Shop")
@forked_project ||= create(:source_project_with_code, name: "Forked Shop", forked_project_link: forked_project_link, creator_id: @forking_user.id , namespace: @forking_user.namespace) @forked_project ||= create(:project, name: "Forked Shop", forked_project_link: forked_project_link, creator_id: @forking_user.id , namespace: @forking_user.namespace)
forked_project_link.forked_from_project = @project forked_project_link.forked_from_project = @project
forked_project_link.forked_to_project = @forked_project forked_project_link.forked_to_project = @forked_project
...@@ -114,7 +114,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -114,7 +114,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
end end
step 'project "Forked Shop" has push event' do step 'project "Forked Shop" has push event' do
@forked_project = Project.find_by_name("Forked Shop") @forked_project = Project.find_by(name: "Forked Shop")
data = { data = {
before: "0000000000000000000000000000000000000000", before: "0000000000000000000000000000000000000000",
...@@ -172,7 +172,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps ...@@ -172,7 +172,7 @@ class ProjectForkedMergeRequests < Spinach::FeatureSteps
end end
def project def project
@project ||= Project.find_by_name!("Shop") @project ||= Project.find_by!(name: "Shop")
end end
# Verify a link is generated against the correct project # Verify a link is generated against the correct project
......
...@@ -7,7 +7,7 @@ class ProjectGraph < Spinach::FeatureSteps ...@@ -7,7 +7,7 @@ class ProjectGraph < Spinach::FeatureSteps
end end
When 'I visit project "Shop" graph page' do When 'I visit project "Shop" graph page' do
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
visit project_graph_path(project, "master") visit project_graph_path(project, "master")
end end
end end
...@@ -4,8 +4,8 @@ class ProjectIssueTracker < Spinach::FeatureSteps ...@@ -4,8 +4,8 @@ class ProjectIssueTracker < Spinach::FeatureSteps
include SharedPaths include SharedPaths
step 'project "Shop" has issues enabled' do step 'project "Shop" has issues enabled' do
@project = Project.find_by_name "Shop" @project = Project.find_by(name: "Shop")
@project ||= create(:project_with_code, name: "Shop", namespace: @user.namespace) @project ||= create(:project, name: "Shop", namespace: @user.namespace)
@project.issues_enabled = true @project.issues_enabled = true
end end
......
...@@ -54,7 +54,7 @@ class ProjectIssues < Spinach::FeatureSteps ...@@ -54,7 +54,7 @@ class ProjectIssues < Spinach::FeatureSteps
end end
Then 'I should see issue "500 error on profile"' do Then 'I should see issue "500 error on profile"' do
issue = Issue.find_by_title("500 error on profile") issue = Issue.find_by(title: "500 error on profile")
page.should have_content issue.title page.should have_content issue.title
page.should have_content issue.author_name page.should have_content issue.author_name
page.should have_content issue.project.name page.should have_content issue.project.name
...@@ -81,14 +81,14 @@ class ProjectIssues < Spinach::FeatureSteps ...@@ -81,14 +81,14 @@ class ProjectIssues < Spinach::FeatureSteps
end end
Given 'project "Shop" has milestone "v2.2"' do Given 'project "Shop" has milestone "v2.2"' do
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
milestone = create(:milestone, title: "v2.2", project: project) milestone = create(:milestone, title: "v2.2", project: project)
3.times { create(:issue, project: project, milestone: milestone) } 3.times { create(:issue, project: project, milestone: milestone) }
end end
And 'project "Shop" has milestone "v3.0"' do And 'project "Shop" has milestone "v3.0"' do
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
milestone = create(:milestone, title: "v3.0", project: project) milestone = create(:milestone, title: "v3.0", project: project)
3.times { create(:issue, project: project, milestone: milestone) } 3.times { create(:issue, project: project, milestone: milestone) }
...@@ -104,20 +104,20 @@ class ProjectIssues < Spinach::FeatureSteps ...@@ -104,20 +104,20 @@ class ProjectIssues < Spinach::FeatureSteps
end end
When 'I select first assignee from "Shop" project' do When 'I select first assignee from "Shop" project' do
project = Project.find_by_name "Shop" project = Project.find_by(name: "Shop")
first_assignee = project.users.first first_assignee = project.users.first
select first_assignee.name, from: "assignee_id" select first_assignee.name, from: "assignee_id"
end end
Then 'I should see first assignee from "Shop" as selected assignee' do Then 'I should see first assignee from "Shop" as selected assignee' do
issues_assignee_selector = "#issue_assignee_id_chzn > a" issues_assignee_selector = "#issue_assignee_id_chzn > a"
project = Project.find_by_name "Shop" project = Project.find_by(name: "Shop")
assignee_name = project.users.first.name assignee_name = project.users.first.name
page.find(issues_assignee_selector).should have_content(assignee_name) page.find(issues_assignee_selector).should have_content(assignee_name)
end end
And 'project "Shop" have "Release 0.4" open issue' do And 'project "Shop" have "Release 0.4" open issue' do
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
create(:issue, create(:issue,
title: "Release 0.4", title: "Release 0.4",
project: project, project: project,
...@@ -125,7 +125,7 @@ class ProjectIssues < Spinach::FeatureSteps ...@@ -125,7 +125,7 @@ class ProjectIssues < Spinach::FeatureSteps
end end
And 'project "Shop" have "Tweet control" open issue' do And 'project "Shop" have "Tweet control" open issue' do
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
create(:issue, create(:issue,
title: "Tweet control", title: "Tweet control",
project: project, project: project,
...@@ -133,7 +133,7 @@ class ProjectIssues < Spinach::FeatureSteps ...@@ -133,7 +133,7 @@ class ProjectIssues < Spinach::FeatureSteps
end end
And 'project "Shop" have "Release 0.3" closed issue' do And 'project "Shop" have "Release 0.3" closed issue' do
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
create(:closed_issue, create(:closed_issue,
title: "Release 0.3", title: "Release 0.3",
project: project, project: project,
......
...@@ -16,7 +16,7 @@ class ProjectLabels < Spinach::FeatureSteps ...@@ -16,7 +16,7 @@ class ProjectLabels < Spinach::FeatureSteps
end end
And 'project "Shop" have issues tags: "bug", "feature"' do And 'project "Shop" have issues tags: "bug", "feature"' do
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
['bug', 'feature'].each do |label| ['bug', 'feature'].each do |label|
create(:issue, project: project, label_list: label) create(:issue, project: project, label_list: label)
end end
......
...@@ -3,8 +3,8 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps ...@@ -3,8 +3,8 @@ class Spinach::Features::ProjectMarkdownRender < Spinach::FeatureSteps
include SharedPaths include SharedPaths
And 'I own project "Delta"' do And 'I own project "Delta"' do
@project = Project.find_by_name "Delta" @project = Project.find_by(name: "Delta")
@project ||= create(:project_with_code, name: "Delta", namespace: @user.namespace) @project ||= create(:project, name: "Delta", namespace: @user.namespace)
@project.team << [@user, :master] @project.team << [@user, :master]
end end
......
...@@ -27,7 +27,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -27,7 +27,7 @@ class ProjectMergeRequests < Spinach::FeatureSteps
end end
step 'I should see closed merge request "Bug NS-04"' do step 'I should see closed merge request "Bug NS-04"' do
merge_request = MergeRequest.find_by_title!("Bug NS-04") merge_request = MergeRequest.find_by!(title: "Bug NS-04")
merge_request.closed?.should be_true merge_request.closed?.should be_true
page.should have_content "Closed by" page.should have_content "Closed by"
end end
...@@ -81,6 +81,8 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -81,6 +81,8 @@ class ProjectMergeRequests < Spinach::FeatureSteps
title: "Bug NS-04", title: "Bug NS-04",
source_project: project, source_project: project,
target_project: project, target_project: project,
source_branch: 'stable',
target_branch: 'master',
author: project.users.first) author: project.users.first)
end end
...@@ -109,33 +111,29 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -109,33 +111,29 @@ class ProjectMergeRequests < Spinach::FeatureSteps
end end
step 'I click on the first commit in the merge request' do step 'I click on the first commit in the merge request' do
within '.first-commits' do
click_link merge_request.commits.first.short_id(8) click_link merge_request.commits.first.short_id(8)
end end
end
step 'I leave a comment on the diff page' do step 'I leave a comment on the diff page' do
init_diff_note init_diff_note
leave_comment "One comment to rule them all"
within('.js-discussion-note-form') do
fill_in "note_note", with: "One comment to rule them all"
click_button "Add Comment"
end end
within ".note-text" do step 'I leave a comment on the diff page in commit' do
page.should have_content "One comment to rule them all" find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
end leave_comment "One comment to rule them all"
end end
step 'I leave a comment like "Line is wrong" on line 185 of the first file' do step 'I leave a comment like "Line is wrong" on line 185 of the first file' do
init_diff_note init_diff_note
leave_comment "Line is wrong"
within(".js-discussion-note-form") do
fill_in "note_note", with: "Line is wrong"
click_button "Add Comment"
end end
within ".note-text" do step 'I leave a comment like "Line is wrong" on line 185 of the first file in commit' do
page.should have_content "Line is wrong" find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click
end leave_comment "Line is wrong"
end end
step 'I should see a discussion has started on line 185' do step 'I should see a discussion has started on line 185' do
...@@ -144,14 +142,14 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -144,14 +142,14 @@ class ProjectMergeRequests < Spinach::FeatureSteps
page.should have_content "Line is wrong" page.should have_content "Line is wrong"
end end
step 'I should see a discussion has started on commit bcf03b5de6c:L185' do step 'I should see a discussion has started on commit b1e6a9dbf1:L185' do
page.should have_content "#{current_user.name} started a discussion on commit" page.should have_content "#{current_user.name} started a discussion on commit"
page.should have_content "app/assets/stylesheets/tree.scss:L185" page.should have_content "app/assets/stylesheets/tree.scss:L185"
page.should have_content "Line is wrong" page.should have_content "Line is wrong"
end end
step 'I should see a discussion has started on commit bcf03b5de6c' do step 'I should see a discussion has started on commit b1e6a9dbf1' do
page.should have_content "#{current_user.name} started a discussion on commit bcf03b5de6c" page.should have_content "#{current_user.name} started a discussion on commit"
page.should have_content "One comment to rule them all" page.should have_content "One comment to rule them all"
page.should have_content "app/assets/stylesheets/tree.scss:L185" page.should have_content "app/assets/stylesheets/tree.scss:L185"
end end
...@@ -180,14 +178,25 @@ class ProjectMergeRequests < Spinach::FeatureSteps ...@@ -180,14 +178,25 @@ class ProjectMergeRequests < Spinach::FeatureSteps
end end
def project def project
@project ||= Project.find_by_name!("Shop") @project ||= Project.find_by!(name: "Shop")
end end
def merge_request def merge_request
@merge_request ||= MergeRequest.find_by_title!("Bug NS-05") @merge_request ||= MergeRequest.find_by!(title: "Bug NS-05")
end end
def init_diff_note def init_diff_note
find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click
end
def leave_comment(message)
within(".js-discussion-note-form") do
fill_in "note_note", with: message
click_button "Add Comment"
end
within ".note-text" do
page.should have_content message
end
end end
end end
...@@ -4,7 +4,7 @@ class ProjectMilestones < Spinach::FeatureSteps ...@@ -4,7 +4,7 @@ class ProjectMilestones < Spinach::FeatureSteps
include SharedPaths include SharedPaths
Then 'I should see milestone "v2.2"' do Then 'I should see milestone "v2.2"' do
milestone = @project.milestones.find_by_title("v2.2") milestone = @project.milestones.find_by(title: "v2.2")
page.should have_content(milestone.title[0..10]) page.should have_content(milestone.title[0..10])
page.should have_content(milestone.expires_at) page.should have_content(milestone.expires_at)
page.should have_content("Browse Issues") page.should have_content("Browse Issues")
...@@ -24,22 +24,22 @@ class ProjectMilestones < Spinach::FeatureSteps ...@@ -24,22 +24,22 @@ class ProjectMilestones < Spinach::FeatureSteps
end end
Then 'I should see milestone "v2.3"' do Then 'I should see milestone "v2.3"' do
milestone = @project.milestones.find_by_title("v2.3") milestone = @project.milestones.find_by(title: "v2.3")
page.should have_content(milestone.title[0..10]) page.should have_content(milestone.title[0..10])
page.should have_content(milestone.expires_at) page.should have_content(milestone.expires_at)
page.should have_content("Browse Issues") page.should have_content("Browse Issues")
end end
And 'project "Shop" has milestone "v2.2"' do And 'project "Shop" has milestone "v2.2"' do
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
milestone = create(:milestone, title: "v2.2", project: project) milestone = create(:milestone, title: "v2.2", project: project)
3.times { create(:issue, project: project, milestone: milestone) } 3.times { create(:issue, project: project, milestone: milestone) }
end end
Given 'the milestone has open and closed issues' do Given 'the milestone has open and closed issues' do
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
milestone = project.milestones.find_by_title('v2.2') milestone = project.milestones.find_by(title: 'v2.2')
# 3 Open issues created above; create one closed issue # 3 Open issues created above; create one closed issue
create(:closed_issue, project: project, milestone: milestone) create(:closed_issue, project: project, milestone: milestone)
......
...@@ -10,7 +10,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps ...@@ -10,7 +10,7 @@ class ProjectNetworkGraph < Spinach::FeatureSteps
# Stub Graph max_size to speed up test (10 commits vs. 650) # Stub Graph max_size to speed up test (10 commits vs. 650)
Network::Graph.stub(max_count: 10) Network::Graph.stub(max_count: 10)
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
visit project_network_path(project, "master") visit project_network_path(project, "master")
end end
......
...@@ -90,10 +90,10 @@ class ProjectSnippets < Spinach::FeatureSteps ...@@ -90,10 +90,10 @@ class ProjectSnippets < Spinach::FeatureSteps
end end
def project def project
@project ||= Project.find_by_name!("Shop") @project ||= Project.find_by!(name: "Shop")
end end
def project_snippet def project_snippet
@project_snippet ||= ProjectSnippet.find_by_title!("Snippet One") @project_snippet ||= ProjectSnippet.find_by!(title: "Snippet one")
end end
end end
...@@ -10,7 +10,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps ...@@ -10,7 +10,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps
end end
And 'I should see "Sam" in team list' do And 'I should see "Sam" in team list' do
user = User.find_by_name("Sam") user = User.find_by(name: "Sam")
page.should have_content(user.name) page.should have_content(user.name)
page.should have_content(user.username) page.should have_content(user.username)
end end
...@@ -20,7 +20,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps ...@@ -20,7 +20,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps
end end
And 'I select "Mike" as "Reporter"' do And 'I select "Mike" as "Reporter"' do
user = User.find_by_name("Mike") user = User.find_by(name: "Mike")
select2(user.id, from: "#user_ids", multiple: true) select2(user.id, from: "#user_ids", multiple: true)
within "#new_team_member" do within "#new_team_member" do
...@@ -42,7 +42,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps ...@@ -42,7 +42,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps
end end
And 'I change "Sam" role to "Reporter"' do And 'I change "Sam" role to "Reporter"' do
user = User.find_by_name("Sam") user = User.find_by(name: "Sam")
within "#user_#{user.id}" do within "#user_#{user.id}" do
select "Reporter", from: "team_member_project_access" select "Reporter", from: "team_member_project_access"
end end
...@@ -59,7 +59,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps ...@@ -59,7 +59,7 @@ class ProjectTeamManagement < Spinach::FeatureSteps
end end
And 'I should not see "Sam" in team list' do And 'I should not see "Sam" in team list' do
user = User.find_by_name("Sam") user = User.find_by(name: "Sam")
page.should_not have_content(user.name) page.should_not have_content(user.name)
page.should_not have_content(user.username) page.should_not have_content(user.username)
end end
...@@ -73,19 +73,19 @@ class ProjectTeamManagement < Spinach::FeatureSteps ...@@ -73,19 +73,19 @@ class ProjectTeamManagement < Spinach::FeatureSteps
end end
And '"Sam" is "Shop" developer' do And '"Sam" is "Shop" developer' do
user = User.find_by_name("Sam") user = User.find_by(name: "Sam")
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
project.team << [user, :developer] project.team << [user, :developer]
end end
Given 'I own project "Website"' do Given 'I own project "Website"' do
@project = create(:project, name: "Website", namespace: @user.namespace) @project = create(:empty_project, name: "Website", namespace: @user.namespace)
@project.team << [@user, :master] @project.team << [@user, :master]
end end
And '"Mike" is "Website" reporter' do And '"Mike" is "Website" reporter' do
user = User.find_by_name("Mike") user = User.find_by(name: "Mike")
project = Project.find_by_name("Website") project = Project.find_by(name: "Website")
project.team << [user, :reporter] project.team << [user, :reporter]
end end
...@@ -94,13 +94,13 @@ class ProjectTeamManagement < Spinach::FeatureSteps ...@@ -94,13 +94,13 @@ class ProjectTeamManagement < Spinach::FeatureSteps
end end
When 'I submit "Website" project for import team' do When 'I submit "Website" project for import team' do
project = Project.find_by_name("Website") project = Project.find_by(name: "Website")
select project.name_with_namespace, from: 'source_project_id' select project.name_with_namespace, from: 'source_project_id'
click_button 'Import' click_button 'Import'
end end
step 'I click cancel link for "Sam"' do step 'I click cancel link for "Sam"' do
within "#user_#{User.find_by_name('Sam').id}" do within "#user_#{User.find_by(name: 'Sam').id}" do
click_link('Remove user from team') click_link('Remove user from team')
end end
end end
......
...@@ -4,7 +4,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps ...@@ -4,7 +4,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
include SharedProject include SharedProject
step 'public project "Community"' do step 'public project "Community"' do
create :project_with_code, name: 'Community', visibility_level: Gitlab::VisibilityLevel::PUBLIC create :project, name: 'Community', visibility_level: Gitlab::VisibilityLevel::PUBLIC
end end
step 'private project "Enterprise"' do step 'private project "Enterprise"' do
...@@ -12,7 +12,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps ...@@ -12,7 +12,7 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
end end
step 'I visit project "Community" page' do step 'I visit project "Community" page' do
project = Project.find_by_name('Community') project = Project.find_by(name: 'Community')
visit project_path(project) visit project_path(project)
end end
...@@ -23,12 +23,12 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps ...@@ -23,12 +23,12 @@ class Spinach::Features::ProjectRedirects < Spinach::FeatureSteps
end end
step 'I visit project "Enterprise" page' do step 'I visit project "Enterprise" page' do
project = Project.find_by_name('Enterprise') project = Project.find_by(name: 'Enterprise')
visit project_path(project) visit project_path(project)
end end
step 'I visit project "CommunityDoesNotExist" page' do step 'I visit project "CommunityDoesNotExist" page' do
project = Project.find_by_name('Community') project = Project.find_by(name: 'Community')
visit project_path(project) + 'DoesNotExist' visit project_path(project) + 'DoesNotExist'
end end
end end
......
...@@ -25,20 +25,20 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps ...@@ -25,20 +25,20 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
end end
step 'public project "Community"' do step 'public project "Community"' do
create :project_with_code, name: 'Community', visibility_level: Gitlab::VisibilityLevel::PUBLIC create :project, name: 'Community', visibility_level: Gitlab::VisibilityLevel::PUBLIC
end end
step 'public empty project "Empty Public Project"' do step 'public empty project "Empty Public Project"' do
create :project, name: 'Empty Public Project', visibility_level: Gitlab::VisibilityLevel::PUBLIC create :empty_project, name: 'Empty Public Project', visibility_level: Gitlab::VisibilityLevel::PUBLIC
end end
step 'I visit empty project page' do step 'I visit empty project page' do
project = Project.find_by_name('Empty Public Project') project = Project.find_by(name: 'Empty Public Project')
visit project_path(project) visit project_path(project)
end end
step 'I visit project "Community" page' do step 'I visit project "Community" page' do
project = Project.find_by_name('Community') project = Project.find_by(name: 'Community')
visit project_path(project) visit project_path(project)
end end
...@@ -47,14 +47,14 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps ...@@ -47,14 +47,14 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
end end
step 'I should see empty public project details with http clone info' do step 'I should see empty public project details with http clone info' do
project = Project.find_by_name('Empty Public Project') project = Project.find_by(name: 'Empty Public Project')
page.all(:css, '.git-empty .clone').each do |element| page.all(:css, '.git-empty .clone').each do |element|
element.text.should include(project.http_url_to_repo) element.text.should include(project.http_url_to_repo)
end end
end end
step 'I should see empty public project details with ssh clone info' do step 'I should see empty public project details with ssh clone info' do
project = Project.find_by_name('Empty Public Project') project = Project.find_by(name: 'Empty Public Project')
page.all(:css, '.git-empty .clone').each do |element| page.all(:css, '.git-empty .clone').each do |element|
element.text.should include(project.url_to_repo) element.text.should include(project.url_to_repo)
end end
...@@ -65,7 +65,7 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps ...@@ -65,7 +65,7 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
end end
step 'I visit project "Enterprise" page' do step 'I visit project "Enterprise" page' do
project = Project.find_by_name('Enterprise') project = Project.find_by(name: 'Enterprise')
visit project_path(project) visit project_path(project)
end end
...@@ -76,7 +76,7 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps ...@@ -76,7 +76,7 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
end end
step 'internal project "Internal"' do step 'internal project "Internal"' do
create :project_with_code, name: 'Internal', visibility_level: Gitlab::VisibilityLevel::INTERNAL create :project, name: 'Internal', visibility_level: Gitlab::VisibilityLevel::INTERNAL
end end
step 'I should see project "Internal"' do step 'I should see project "Internal"' do
...@@ -88,7 +88,7 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps ...@@ -88,7 +88,7 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
end end
step 'I visit project "Internal" page' do step 'I visit project "Internal" page' do
project = Project.find_by_name('Internal') project = Project.find_by(name: 'Internal')
visit project_path(project) visit project_path(project)
end end
...@@ -99,12 +99,12 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps ...@@ -99,12 +99,12 @@ class Spinach::Features::PublicProjectsFeature < Spinach::FeatureSteps
end end
step 'I should see an http link to the repository' do step 'I should see an http link to the repository' do
project = Project.find_by_name 'Community' project = Project.find_by(name: 'Community')
page.should have_field('project_clone', with: project.http_url_to_repo) page.should have_field('project_clone', with: project.http_url_to_repo)
end end
step 'I should see an ssh link to the repository' do step 'I should see an ssh link to the repository' do
project = Project.find_by_name 'Community' project = Project.find_by(name: 'Community')
page.should have_field('project_clone', with: project.url_to_repo) page.should have_field('project_clone', with: project.url_to_repo)
end end
end end
......
...@@ -241,7 +241,7 @@ module SharedPaths ...@@ -241,7 +241,7 @@ module SharedPaths
end end
step 'I visit issue page "Release 0.4"' do step 'I visit issue page "Release 0.4"' do
issue = Issue.find_by_title("Release 0.4") issue = Issue.find_by(title: "Release 0.4")
visit project_issue_path(issue.project, issue) visit project_issue_path(issue.project, issue)
end end
...@@ -250,12 +250,12 @@ module SharedPaths ...@@ -250,12 +250,12 @@ module SharedPaths
end end
step 'I visit merge request page "Bug NS-04"' do step 'I visit merge request page "Bug NS-04"' do
mr = MergeRequest.find_by_title("Bug NS-04") mr = MergeRequest.find_by(title: "Bug NS-04")
visit project_merge_request_path(mr.target_project, mr) visit project_merge_request_path(mr.target_project, mr)
end end
step 'I visit merge request page "Bug NS-05"' do step 'I visit merge request page "Bug NS-05"' do
mr = MergeRequest.find_by_title("Bug NS-05") mr = MergeRequest.find_by(title: "Bug NS-05")
visit project_merge_request_path(mr.target_project, mr) visit project_merge_request_path(mr.target_project, mr)
end end
...@@ -292,7 +292,7 @@ module SharedPaths ...@@ -292,7 +292,7 @@ module SharedPaths
end end
step 'I visit public page for "Community" project' do step 'I visit public page for "Community" project' do
visit public_project_path(Project.find_by_name("Community")) visit public_project_path(Project.find_by(name: "Community"))
end end
# ---------------------------------------- # ----------------------------------------
...@@ -316,6 +316,6 @@ module SharedPaths ...@@ -316,6 +316,6 @@ module SharedPaths
end end
def project def project
project = Project.find_by_name!("Shop") project = Project.find_by!(name: "Shop")
end end
end end
...@@ -3,26 +3,26 @@ module SharedProject ...@@ -3,26 +3,26 @@ module SharedProject
# Create a project without caring about what it's called # Create a project without caring about what it's called
And "I own a project" do And "I own a project" do
@project = create(:project_with_code, namespace: @user.namespace) @project = create(:project, namespace: @user.namespace)
@project.team << [@user, :master] @project.team << [@user, :master]
end end
# Create a specific project called "Shop" # Create a specific project called "Shop"
And 'I own project "Shop"' do And 'I own project "Shop"' do
@project = Project.find_by_name "Shop" @project = Project.find_by(name: "Shop")
@project ||= create(:project_with_code, name: "Shop", namespace: @user.namespace) @project ||= create(:project, name: "Shop", namespace: @user.namespace)
@project.team << [@user, :master] @project.team << [@user, :master]
end end
# Create another specific project called "Forum" # Create another specific project called "Forum"
And 'I own project "Forum"' do And 'I own project "Forum"' do
@project = Project.find_by_name "Forum" @project = Project.find_by(name: "Forum")
@project ||= create(:project_with_code, name: "Forum", namespace: @user.namespace, path: 'forum_project') @project ||= create(:project, name: "Forum", namespace: @user.namespace, path: 'forum_project')
@project.team << [@user, :master] @project.team << [@user, :master]
end end
And 'project "Shop" has push event' do And 'project "Shop" has push event' do
@project = Project.find_by_name("Shop") @project = Project.find_by(name: "Shop")
data = { data = {
before: "0000000000000000000000000000000000000000", before: "0000000000000000000000000000000000000000",
...@@ -48,7 +48,7 @@ module SharedProject ...@@ -48,7 +48,7 @@ module SharedProject
end end
Then 'I should see project "Shop" activity feed' do Then 'I should see project "Shop" activity feed' do
project = Project.find_by_name("Shop") project = Project.find_by(name: "Shop")
page.should have_content "#{@user.name} pushed new branch new_design at #{project.name_with_namespace}" page.should have_content "#{@user.name} pushed new branch new_design at #{project.name_with_namespace}"
end end
......
...@@ -12,6 +12,6 @@ class DiscoverSnippets < Spinach::FeatureSteps ...@@ -12,6 +12,6 @@ class DiscoverSnippets < Spinach::FeatureSteps
end end
def snippet def snippet
@snippet ||= PersonalSnippet.find_by_title!("Personal snippet one") @snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one")
end end
end end
...@@ -59,6 +59,6 @@ class SnippetsFeature < Spinach::FeatureSteps ...@@ -59,6 +59,6 @@ class SnippetsFeature < Spinach::FeatureSteps
end end
def snippet def snippet
@snippet ||= PersonalSnippet.find_by_title!("Personal snippet one") @snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one")
end end
end end
...@@ -36,6 +36,6 @@ class UserSnippets < Spinach::FeatureSteps ...@@ -36,6 +36,6 @@ class UserSnippets < Spinach::FeatureSteps
end end
def snippet def snippet
@snippet ||= PersonalSnippet.find_by_title!("Personal snippet one") @snippet ||= PersonalSnippet.find_by!(title: "Personal snippet one")
end end
end end
...@@ -38,14 +38,14 @@ module API ...@@ -38,14 +38,14 @@ module API
attrs[:key].strip! attrs[:key].strip!
# check if key already exist in project # check if key already exist in project
key = user_project.deploy_keys.find_by_key(attrs[:key]) key = user_project.deploy_keys.find_by(key: attrs[:key])
if key if key
present key, with: Entities::SSHKey present key, with: Entities::SSHKey
return return
end end
# Check for available deploy keys in other projects # Check for available deploy keys in other projects
key = current_user.accessible_deploy_keys.find_by_key(attrs[:key]) key = current_user.accessible_deploy_keys.find_by(key: attrs[:key])
if key if key
user_project.deploy_keys << key user_project.deploy_keys << key
present key, with: Entities::SSHKey present key, with: Entities::SSHKey
......
...@@ -48,19 +48,19 @@ module API ...@@ -48,19 +48,19 @@ module API
class ProjectMember < UserBasic class ProjectMember < UserBasic
expose :project_access, as: :access_level do |user, options| expose :project_access, as: :access_level do |user, options|
options[:project].users_projects.find_by_user_id(user.id).project_access options[:project].users_projects.find_by(user_id: user.id).project_access
end end
end end
class TeamMember < UserBasic class TeamMember < UserBasic
expose :permission, as: :access_level do |user, options| expose :permission, as: :access_level do |user, options|
options[:user_team].user_team_user_relationships.find_by_user_id(user.id).permission options[:user_team].user_team_user_relationships.find_by(user_id: user.id).permission
end end
end end
class TeamProject < Project class TeamProject < Project
expose :greatest_access, as: :greatest_access_level do |project, options| expose :greatest_access, as: :greatest_access_level do |project, options|
options[:user_team].user_team_project_relationships.find_by_project_id(project.id).greatest_access options[:user_team].user_team_project_relationships.find_by(project_id: project.id).greatest_access
end end
end end
...@@ -74,7 +74,7 @@ module API ...@@ -74,7 +74,7 @@ module API
class GroupMember < UserBasic class GroupMember < UserBasic
expose :group_access, as: :access_level do |user, options| expose :group_access, as: :access_level do |user, options|
options[:group].users_groups.find_by_user_id(user.id).group_access options[:group].users_groups.find_by(user_id: user.id).group_access
end end
end end
......
...@@ -121,11 +121,11 @@ module API ...@@ -121,11 +121,11 @@ module API
render_api_error!("Wrong access level", 422) render_api_error!("Wrong access level", 422)
end end
group = find_group(params[:id]) group = find_group(params[:id])
if group.users_groups.find_by_user_id(params[:user_id]) if group.users_groups.find_by(user_id: params[:user_id])
render_api_error!("Already exists", 409) render_api_error!("Already exists", 409)
end end
group.add_users([params[:user_id]], params[:access_level]) group.add_users([params[:user_id]], params[:access_level])
member = group.users_groups.find_by_user_id(params[:user_id]) member = group.users_groups.find_by(user_id: params[:user_id])
present member.user, with: Entities::GroupMember, group: group present member.user, with: Entities::GroupMember, group: group
end end
...@@ -139,7 +139,7 @@ module API ...@@ -139,7 +139,7 @@ module API
# DELETE /groups/:id/members/:user_id # DELETE /groups/:id/members/:user_id
delete ":id/members/:user_id" do delete ":id/members/:user_id" do
group = find_group(params[:id]) group = find_group(params[:id])
member = group.users_groups.find_by_user_id(params[:user_id]) member = group.users_groups.find_by(user_id: params[:user_id])
if member.nil? if member.nil?
render_api_error!("404 Not Found - user_id:#{params[:user_id]} not a member of group #{group.name}",404) render_api_error!("404 Not Found - user_id:#{params[:user_id]} not a member of group #{group.name}",404)
else else
......
...@@ -7,7 +7,7 @@ module API ...@@ -7,7 +7,7 @@ module API
def current_user def current_user
private_token = (params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]).to_s private_token = (params[PRIVATE_TOKEN_PARAM] || env[PRIVATE_TOKEN_HEADER]).to_s
@current_user ||= User.find_by_authentication_token(private_token) @current_user ||= User.find_by(authentication_token: private_token)
identifier = sudo_identifier() identifier = sudo_identifier()
# If the sudo is the current user do nothing # If the sudo is the current user do nothing
...@@ -47,7 +47,7 @@ module API ...@@ -47,7 +47,7 @@ module API
end end
def find_project(id) def find_project(id)
project = Project.find_by_id(id) || Project.find_with_namespace(id) project = Project.find_by(id: id) || Project.find_with_namespace(id)
if project && can?(current_user, :read_project, project) if project && can?(current_user, :read_project, project)
project project
......
...@@ -81,14 +81,13 @@ module API ...@@ -81,14 +81,13 @@ module API
merge_request.target_project = user_project merge_request.target_project = user_project
else else
if target_matches_fork(target_project_id,user_project) if target_matches_fork(target_project_id,user_project)
merge_request.target_project = Project.find_by_id(attrs[:target_project_id]) merge_request.target_project = Project.find_by(id: attrs[:target_project_id])
else else
render_api_error!('(Bad Request) Specified target project that is not the source project, or the source fork of the project.', 400) render_api_error!('(Bad Request) Specified target project that is not the source project, or the source fork of the project.', 400)
end end
end end
if merge_request.save if merge_request.save
merge_request.reload_code
present merge_request, with: Entities::MergeRequest present merge_request, with: Entities::MergeRequest
else else
handle_merge_request_errors! merge_request.errors handle_merge_request_errors! merge_request.errors
......
...@@ -266,7 +266,7 @@ module API ...@@ -266,7 +266,7 @@ module API
authorize! :admin_project, user_project authorize! :admin_project, user_project
required_attributes! [:access_level] required_attributes! [:access_level]
team_member = user_project.users_projects.find_by_user_id(params[:user_id]) team_member = user_project.users_projects.find_by(user_id: params[:user_id])
not_found!("User can not be found") if team_member.nil? not_found!("User can not be found") if team_member.nil?
if team_member.update_attributes(project_access: params[:access_level]) if team_member.update_attributes(project_access: params[:access_level])
...@@ -286,7 +286,7 @@ module API ...@@ -286,7 +286,7 @@ module API
# DELETE /projects/:id/members/:user_id # DELETE /projects/:id/members/:user_id
delete ":id/members/:user_id" do delete ":id/members/:user_id" do
authorize! :admin_project, user_project authorize! :admin_project, user_project
team_member = user_project.users_projects.find_by_user_id(params[:user_id]) team_member = user_project.users_projects.find_by(user_id: params[:user_id])
unless team_member.nil? unless team_member.nil?
team_member.destroy team_member.destroy
else else
......
...@@ -51,7 +51,7 @@ module API ...@@ -51,7 +51,7 @@ module API
@branch = user_project.repository.find_branch(params[:branch]) @branch = user_project.repository.find_branch(params[:branch])
not_found! unless @branch not_found! unless @branch
protected_branch = user_project.protected_branches.find_by_name(@branch.name) protected_branch = user_project.protected_branches.find_by(name: @branch.name)
user_project.protected_branches.create(name: @branch.name) unless protected_branch user_project.protected_branches.create(name: @branch.name) unless protected_branch
present @branch, with: Entities::RepoObject, project: user_project present @branch, with: Entities::RepoObject, project: user_project
...@@ -69,7 +69,7 @@ module API ...@@ -69,7 +69,7 @@ module API
@branch = user_project.repository.find_branch(params[:branch]) @branch = user_project.repository.find_branch(params[:branch])
not_found! unless @branch not_found! unless @branch
protected_branch = user_project.protected_branches.find_by_name(@branch.name) protected_branch = user_project.protected_branches.find_by(name: @branch.name)
protected_branch.destroy if protected_branch protected_branch.destroy if protected_branch
present @branch, with: Entities::RepoObject, project: user_project present @branch, with: Entities::RepoObject, project: user_project
......
...@@ -119,7 +119,7 @@ module API ...@@ -119,7 +119,7 @@ module API
# DELETE /users/:id # DELETE /users/:id
delete ":id" do delete ":id" do
authenticated_as_admin! authenticated_as_admin!
user = User.find_by_id(params[:id]) user = User.find_by(id: params[:id])
if user if user
user.destroy user.destroy
......
...@@ -11,23 +11,29 @@ module Backup ...@@ -11,23 +11,29 @@ module Backup
end end
def dump def dump
case config["adapter"] success = case config["adapter"]
when /^mysql/ then when /^mysql/ then
print "Dumping MySQL database #{config['database']} ... "
system('mysqldump', *mysql_args, config['database'], out: db_file_name) system('mysqldump', *mysql_args, config['database'], out: db_file_name)
when "postgresql" then when "postgresql" then
print "Dumping PostgreSQL database #{config['database']} ... "
pg_env pg_env
system('pg_dump', config['database'], out: db_file_name) system('pg_dump', config['database'], out: db_file_name)
end end
report_success(success)
end end
def restore def restore
case config["adapter"] success = case config["adapter"]
when /^mysql/ then when /^mysql/ then
print "Restoring MySQL database #{config['database']} ... "
system('mysql', *mysql_args, config['database'], in: db_file_name) system('mysql', *mysql_args, config['database'], in: db_file_name)
when "postgresql" then when "postgresql" then
print "Restoring PostgreSQL database #{config['database']} ... "
pg_env pg_env
system('psql', config['database'], '-f', db_file_name) system('psql', config['database'], '-f', db_file_name)
end end
report_success(success)
end end
protected protected
...@@ -54,5 +60,13 @@ module Backup ...@@ -54,5 +60,13 @@ module Backup
ENV['PGPORT'] = config["port"].to_s if config["port"] ENV['PGPORT'] = config["port"].to_s if config["port"]
ENV['PGPASSWORD'] = config["password"].to_s if config["password"] ENV['PGPASSWORD'] = config["password"].to_s if config["password"]
end end
def report_success(success)
if success
puts '[DONE]'.green
else
puts '[FAILED]'.red
end
end
end end
end end
module Gitlab module Gitlab
class Auth class Auth
def find(login, password) def find(login, password)
user = User.find_by_email(login) || User.find_by_username(login) user = User.find_by(email: login) || User.find_by(username: login)
if user.nil? || user.ldap_user? if user.nil? || user.ldap_user?
# Second chance - try LDAP authentication # Second chance - try LDAP authentication
......
...@@ -6,17 +6,17 @@ module Gitlab ...@@ -6,17 +6,17 @@ module Gitlab
if identifier.blank? if identifier.blank?
# Local push from gitlab # Local push from gitlab
email = project.repository.commit(newrev).author_email rescue nil email = project.repository.commit(newrev).author_email rescue nil
User.find_by_email(email) if email User.find_by(email: email) if email
elsif identifier =~ /\Auser-\d+\Z/ elsif identifier =~ /\Auser-\d+\Z/
# git push over http # git push over http
user_id = identifier.gsub("user-", "") user_id = identifier.gsub("user-", "")
User.find_by_id(user_id) User.find_by(id: user_id)
elsif identifier =~ /\Akey-\d+\Z/ elsif identifier =~ /\Akey-\d+\Z/
# git push over ssh # git push over ssh
key_id = identifier.gsub("key-", "") key_id = identifier.gsub("key-", "")
Key.find_by_id(key_id).try(:user) Key.find_by(id: key_id).try(:user)
end end
end end
end end
......
...@@ -44,13 +44,13 @@ module Gitlab ...@@ -44,13 +44,13 @@ module Gitlab
end end
def find_user(email) def find_user(email)
user = model.find_by_email(email) user = model.find_by(email: email)
# If no user found and allow_username_or_email_login is true # If no user found and allow_username_or_email_login is true
# we look for user by extracting part of their email # we look for user by extracting part of their email
if !user && email && ldap_conf['allow_username_or_email_login'] if !user && email && ldap_conf['allow_username_or_email_login']
uname = email.partition('@').first uname = email.partition('@').first
user = model.find_by_username(uname) user = model.find_by(username: uname)
end end
user user
......
...@@ -3,7 +3,6 @@ ...@@ -3,7 +3,6 @@
# GITLAB # GITLAB
# Maintainer: @randx # Maintainer: @randx
# Authors: rovanion.luckey@gmail.com, @randx # Authors: rovanion.luckey@gmail.com, @randx
# App Version: 6.0
### BEGIN INIT INFO ### BEGIN INIT INFO
# Provides: gitlab # Provides: gitlab
......
# GITLAB # GITLAB
# Maintainer: @randx # Maintainer: @randx
# App Version: 5.0
upstream gitlab { upstream gitlab {
server unix:/home/git/gitlab/tmp/sockets/gitlab.socket; server unix:/home/git/gitlab/tmp/sockets/gitlab.socket;
......
...@@ -15,7 +15,7 @@ namespace :gitlab do ...@@ -15,7 +15,7 @@ namespace :gitlab do
desc "GITLAB | Add a specific user to all projects (as a developer)" desc "GITLAB | Add a specific user to all projects (as a developer)"
task :user_to_projects, [:email] => :environment do |t, args| task :user_to_projects, [:email] => :environment do |t, args|
user = User.find_by_email args.email user = User.find_by(email: args.email)
project_ids = Project.pluck(:id) project_ids = Project.pluck(:id)
puts "Importing #{user.email} users into #{project_ids.size} projects" puts "Importing #{user.email} users into #{project_ids.size} projects"
UsersProject.add_users_into_projects(project_ids, Array.wrap(user.id), UsersProject::DEVELOPER) UsersProject.add_users_into_projects(project_ids, Array.wrap(user.id), UsersProject::DEVELOPER)
......
...@@ -43,13 +43,13 @@ namespace :gitlab do ...@@ -43,13 +43,13 @@ namespace :gitlab do
username.gsub!("+", ".") username.gsub!("+", ".")
# return username if no matches # return username if no matches
return username unless User.find_by_username(username) return username unless User.find_by(username: username)
# look for same username # look for same username
(1..10).each do |i| (1..10).each do |i|
suffixed_username = "#{username}#{i}" suffixed_username = "#{username}#{i}"
return suffixed_username unless User.find_by_username(suffixed_username) return suffixed_username unless User.find_by(username: suffixed_username)
end end
end end
......
...@@ -50,7 +50,7 @@ namespace :gitlab do ...@@ -50,7 +50,7 @@ namespace :gitlab do
# find group namespace # find group namespace
if group_name if group_name
group = Group.find_by_path(group_name) group = Group.find_by(path: group_name)
# create group namespace # create group namespace
if !group if !group
group = Group.new(:name => group_name) group = Group.new(:name => group_name)
......
require 'spec_helper' require 'spec_helper'
describe Projects::BlobController do describe Projects::BlobController do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Projects::CommitController do describe Projects::CommitController do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:commit) { project.repository.commit("master") } let(:commit) { project.repository.commit("master") }
......
require 'spec_helper' require 'spec_helper'
describe Projects::CommitsController do describe Projects::CommitsController do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
require 'spec_helper' require 'spec_helper'
describe Projects::MergeRequestsController do describe Projects::MergeRequestsController do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project, target_branch: "stable", source_branch: "master") } let(:merge_request) { create(:merge_request_with_diffs, target_project: project, source_project: project, target_branch: "stable", source_branch: "master") }
......
require 'spec_helper' require 'spec_helper'
describe Projects::TreeController do describe Projects::TreeController do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:user) { create(:user) } let(:user) { create(:user) }
before do before do
......
...@@ -27,43 +27,16 @@ FactoryGirl.define do ...@@ -27,43 +27,16 @@ FactoryGirl.define do
factory :admin, traits: [:admin] factory :admin, traits: [:admin]
end end
factory :project do factory :empty_project, class: 'Project' do
sequence(:name) { |n| "project#{n}" } sequence(:name) { |n| "project#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
namespace namespace
creator creator
trait :source do
sequence(:name) { |n| "source project#{n}" }
end
trait :target do
sequence(:name) { |n| "target project#{n}" }
end
factory :source_project, traits: [:source]
factory :target_project, traits: [:target]
end
factory :redmine_project, parent: :project do
issues_tracker { "redmine" }
issues_tracker_id { "project_name_in_redmine" }
end end
factory :project_with_code, parent: :project do factory :project, parent: :empty_project do
path { 'gitlabhq' } path { 'gitlabhq' }
trait :source_path do
path { 'source_gitlabhq' }
end
trait :target_path do
path { 'target_gitlabhq' }
end
factory :source_project_with_code, traits: [:source, :source_path]
factory :target_project_with_code, traits: [:target, :target_path]
after :create do |project| after :create do |project|
TestEnv.clear_repo_dir(project.namespace, project.path) TestEnv.clear_repo_dir(project.namespace, project.path)
TestEnv.reset_satellite_dir TestEnv.reset_satellite_dir
...@@ -71,6 +44,11 @@ FactoryGirl.define do ...@@ -71,6 +44,11 @@ FactoryGirl.define do
end end
end end
factory :redmine_project, parent: :project do
issues_tracker { "redmine" }
issues_tracker_id { "project_name_in_redmine" }
end
factory :group do factory :group do
sequence(:name) { |n| "group#{n}" } sequence(:name) { |n| "group#{n}" }
path { name.downcase.gsub(/\s/, '_') } path { name.downcase.gsub(/\s/, '_') }
...@@ -109,25 +87,45 @@ FactoryGirl.define do ...@@ -109,25 +87,45 @@ FactoryGirl.define do
factory :merge_request do factory :merge_request do
title title
author author
source_project factory: :source_project_with_code source_project factory: :project
target_project factory: :target_project_with_code target_project { source_project }
# → git log stable..master --pretty=oneline
# b1e6a9dbf1c85e6616497a5e7bad9143a4bd0828 tree css fixes
# 8716fc78f3c65bbf7bcf7b574febd583bc5d2812 Added loading animation for notes
# cd5c4bac5042c5469dcdf7e7b2f768d3c6fd7088 notes count for wall
# 8470d70da67355c9c009e4401746b1d5410af2e3 notes controller refactored
# 1e689bfba39525ead225eaf611948cfbe8ac34cf fixed notes logic
# f0f14c8eaba69ebddd766498a9d0b0e79becd633 finished scss refactoring
# 3a4b4fb4cde7809f033822a171b9feae19d41fff Moving ui styles to one scss file, Added ui class to body
# 065c200c33f68c2bb781e35a43f9dc8138a893b5 removed unnecessary hr tags & titles
# 1e8b111be85df0db6c8000ef9a710bc0221eae83 Merge branch 'master' of github.com:gitlabhq/gitlabhq
# f403da73f5e62794a0447aca879360494b08f678 Fixed ajax loading image. Fixed wrong wording
# e6ea73c77600d413d370249b8e392734f7d1dbee Merge pull request #468 from bencevans/patch-1
# 4a3c05b69355deee25767a74d0512ec4b510d4ef Merge pull request #470 from bgondy/patch-1
# 0347fe2412eb51d3efeccc35210e9268bc765ac5 Update app/views/projects/team.html.haml
# 2b5c61bdece1f7eb2b901ceea7d364065cdf76ac Title for a link fixed
# 460eeb13b7560b40104044973ff933b1a6dbbcaa Increased count of notes loaded when visit wall page
# 21c141afb1c53a9180a99d2cca29ffa613eb7e3a Merge branch 'notes_refactoring'
# 292a41cbe295f16f7148913b31eb0fb91f3251c3 Fixed comments for snippets. Tests fixed
# d41d8ffb02fa74fd4571603548bd7e401ec99e0c Reply button, Comments for Merge Request diff
# b1a36b552be2a7a6bc57fbed6c52dc6ed82111f8 Merge pull request #466 from skroutz/no-rbenv
# db75dae913e8365453ca231f101b067314a7ea71 Merge pull request #465 from skroutz/branches_commit_link
# 75f040fbfe4b5af23ff004ad3207c3976df097a8 Don't enforce rbenv version
# e42fb4fda475370dcb0d8f8f1268bfdc7a0cc437 Fix broken commit link in branches page
# 215a01f63ccdc085f75a48f6f7ab6f2b15b5852c move notes login to one controller
# 81092c01984a481e312de10a28e3f1a6dda182a3 Status codes for errors, New error pages
# 7d279f9302151e3c8f4c5df9c5200a72799409b9 better error handling for not found resource, gitolite error
# 9e6d0710e927aa8ea834b8a9ae9f277be617ac7d Merge pull request #443 from CedricGatay/fix/incorrectLineNumberingInDiff
# 6ea87c47f0f8a24ae031c3fff17bc913889ecd00 Incorrect line numbering in diff
#
# → git log master..stable --pretty=oneline
# empty
source_branch "master" source_branch "master"
target_branch "stable" target_branch "stable"
# pick 3 commits "at random" (from bcf03b5d~3 to bcf03b5d)
trait :with_diffs do trait :with_diffs do
target_branch "master" # pretend bcf03b5d~3
source_branch "stable" # pretend bcf03b5d
st_commits do
[
source_project.repository.commit('bcf03b5d').to_hash,
source_project.repository.commit('bcf03b5d~1').to_hash,
source_project.repository.commit('bcf03b5d~2').to_hash
]
end
st_diffs do
source_project.repo.diff("bcf03b5d~3", "bcf03b5d")
end
end end
trait :closed do trait :closed do
...@@ -156,7 +154,7 @@ FactoryGirl.define do ...@@ -156,7 +154,7 @@ FactoryGirl.define do
factory :note_on_merge_request_with_attachment, traits: [:on_merge_request, :with_attachment] factory :note_on_merge_request_with_attachment, traits: [:on_merge_request, :with_attachment]
trait :on_commit do trait :on_commit do
project factory: :project_with_code project factory: :project
commit_id "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a" commit_id "bcf03b5de6c33f3869ef70d68cf06e679d1d7f9a"
noteable_type "Commit" noteable_type "Commit"
end end
...@@ -166,7 +164,7 @@ FactoryGirl.define do ...@@ -166,7 +164,7 @@ FactoryGirl.define do
end end
trait :on_merge_request do trait :on_merge_request do
project factory: :project_with_code project factory: :project
noteable_id 1 noteable_id 1
noteable_type "MergeRequest" noteable_type "MergeRequest"
end end
......
require 'spec_helper' require 'spec_helper'
describe "GitLab Flavored Markdown" do describe "GitLab Flavored Markdown" do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:fred) do let(:fred) do
......
require 'spec_helper' require 'spec_helper'
describe "On a merge request", js: true do describe "On a merge request", js: true do
let!(:project) { create(:project_with_code) } let!(:project) { create(:project) }
let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let!(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let!(:note) { create(:note_on_merge_request_with_attachment, project: project) } let!(:note) { create(:note_on_merge_request_with_attachment, project: project) }
...@@ -135,7 +135,7 @@ describe "On a merge request", js: true do ...@@ -135,7 +135,7 @@ describe "On a merge request", js: true do
end end
describe "On a merge request diff", js: true, focus: true do describe "On a merge request diff", js: true, focus: true do
let!(:project) { create(:source_project_with_code) } let!(:project) { create(:project) }
let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) } let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) }
before do before do
...@@ -149,7 +149,7 @@ describe "On a merge request diff", js: true, focus: true do ...@@ -149,7 +149,7 @@ describe "On a merge request diff", js: true, focus: true do
describe "when adding a note" do describe "when adding a note" do
before do before do
find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click
end end
describe "the notes holder" do describe "the notes holder" do
...@@ -159,23 +159,14 @@ describe "On a merge request diff", js: true, focus: true do ...@@ -159,23 +159,14 @@ describe "On a merge request diff", js: true, focus: true do
end end
describe "the note form" do describe "the note form" do
# FIXME
#it 'should be valid' do
#within(".js-temp-notes-holder") { find("#note_noteable_type").value.should == "MergeRequest" }
#within(".js-temp-notes-holder") { find("#note_noteable_id").value.should == merge_request.id.to_s }
#within(".js-temp-notes-holder") { find("#note_commit_id").value.should == "" }
#within(".js-temp-notes-holder") { find("#note_line_code").value.should == "4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185" }
#should have_css(".js-close-discussion-note-form", text: "Cancel")
#end
it "shouldn't add a second form for same row" do it "shouldn't add a second form for same row" do
find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click
should have_css("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185'] + .js-temp-notes-holder form", count: 1) should have_css("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185'] + .js-temp-notes-holder form", count: 1)
end end
it "should be removed when canceled" do it "should be removed when canceled" do
within(".file form[rel$='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185']") do within(".file form[rel$='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185']") do
find(".js-close-discussion-note-form").trigger("click") find(".js-close-discussion-note-form").trigger("click")
end end
...@@ -185,11 +176,11 @@ describe "On a merge request diff", js: true, focus: true do ...@@ -185,11 +176,11 @@ describe "On a merge request diff", js: true, focus: true do
end end
describe "with muliple note forms" do describe "with muliple note forms" do
let!(:project) { create(:source_project_with_code) } let!(:project) { create(:project) }
let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) } let!(:merge_request) { create(:merge_request_with_diffs, source_project: project, target_project: project) }
before do before do
find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185"]').click find('a[data-line-code="4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185"]').click
find('a[data-line-code="342e16cbbd482ac2047dc679b2749d248cc1428f_18_17"]').click find('a[data-line-code="342e16cbbd482ac2047dc679b2749d248cc1428f_18_17"]').click
end end
...@@ -198,7 +189,7 @@ describe "On a merge request diff", js: true, focus: true do ...@@ -198,7 +189,7 @@ describe "On a merge request diff", js: true, focus: true do
describe "previewing them separately" do describe "previewing them separately" do
before do before do
# add two separate texts and trigger previews on both # add two separate texts and trigger previews on both
within("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_185_185'] + .js-temp-notes-holder") do within("tr[id='4735dfc552ad7bf15ca468adc3cad9d05b624490_172_185'] + .js-temp-notes-holder") do
fill_in "note[note]", with: "One comment on line 185" fill_in "note[note]", with: "One comment on line 185"
find(".js-note-preview-button").trigger("click") find(".js-note-preview-button").trigger("click")
end end
......
require 'spec_helper' require 'spec_helper'
describe "Internal Project Access" do describe "Internal Project Access" do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:master) { create(:user) } let(:master) { create(:user) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
......
require 'spec_helper' require 'spec_helper'
describe "Private Project Access" do describe "Private Project Access" do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:master) { create(:user) } let(:master) { create(:user) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
......
require 'spec_helper' require 'spec_helper'
describe "Public Project Access" do describe "Public Project Access" do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:master) { create(:user) } let(:master) { create(:user) }
let(:guest) { create(:user) } let(:guest) { create(:user) }
......
...@@ -4,7 +4,7 @@ describe GitlabMarkdownHelper do ...@@ -4,7 +4,7 @@ describe GitlabMarkdownHelper do
include ApplicationHelper include ApplicationHelper
include IssuesHelper include IssuesHelper
let!(:project) { create(:project_with_code) } let!(:project) { create(:project) }
let(:user) { create(:user, username: 'gfm') } let(:user) { create(:user, username: 'gfm') }
let(:commit) { project.repository.commit } let(:commit) { project.repository.commit }
......
...@@ -43,7 +43,7 @@ describe SearchHelper do ...@@ -43,7 +43,7 @@ describe SearchHelper do
end end
context "with a current project" do context "with a current project" do
before { @project = create(:project_with_code) } before { @project = create(:project) }
it "includes project-specific sections" do it "includes project-specific sections" do
search_autocomplete_opts("Files").size.should == 1 search_autocomplete_opts("Files").size.should == 1
......
...@@ -25,7 +25,7 @@ describe Gitlab::LDAP do ...@@ -25,7 +25,7 @@ describe Gitlab::LDAP do
it "should update credentials by email if missing uid" do it "should update credentials by email if missing uid" do
user = double('User') user = double('User')
User.stub find_by_extern_uid_and_provider: nil User.stub find_by_extern_uid_and_provider: nil
User.stub find_by_email: user User.stub(:find_by).with(hash_including(email: anything())) { user }
user.should_receive :update_attributes user.should_receive :update_attributes
gl_auth.find_or_create(@auth) gl_auth.find_or_create(@auth)
end end
...@@ -35,8 +35,8 @@ describe Gitlab::LDAP do ...@@ -35,8 +35,8 @@ describe Gitlab::LDAP do
value = Gitlab.config.ldap.allow_username_or_email_login value = Gitlab.config.ldap.allow_username_or_email_login
Gitlab.config.ldap['allow_username_or_email_login'] = true Gitlab.config.ldap['allow_username_or_email_login'] = true
User.stub find_by_extern_uid_and_provider: nil User.stub find_by_extern_uid_and_provider: nil
User.stub find_by_email: nil User.stub(:find_by).with(hash_including(email: anything())) { nil }
User.stub find_by_username: user User.stub(:find_by).with(hash_including(username: anything())) { user }
user.should_receive :update_attributes user.should_receive :update_attributes
gl_auth.find_or_create(@auth) gl_auth.find_or_create(@auth)
Gitlab.config.ldap['allow_username_or_email_login'] = value Gitlab.config.ldap['allow_username_or_email_login'] = value
...@@ -47,8 +47,8 @@ describe Gitlab::LDAP do ...@@ -47,8 +47,8 @@ describe Gitlab::LDAP do
value = Gitlab.config.ldap.allow_username_or_email_login value = Gitlab.config.ldap.allow_username_or_email_login
Gitlab.config.ldap['allow_username_or_email_login'] = false Gitlab.config.ldap['allow_username_or_email_login'] = false
User.stub find_by_extern_uid_and_provider: nil User.stub find_by_extern_uid_and_provider: nil
User.stub find_by_email: nil User.stub(:find_by).with(hash_including(email: anything())) { nil }
User.stub find_by_username: user User.stub(:find_by).with(hash_including(username: anything())) { user }
user.should_not_receive :update_attributes user.should_not_receive :update_attributes
gl_auth.find_or_create(@auth) gl_auth.find_or_create(@auth)
Gitlab.config.ldap['allow_username_or_email_login'] = value Gitlab.config.ldap['allow_username_or_email_login'] = value
......
...@@ -43,7 +43,7 @@ describe Gitlab::ReferenceExtractor do ...@@ -43,7 +43,7 @@ describe Gitlab::ReferenceExtractor do
end end
context 'with a project' do context 'with a project' do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
it 'accesses valid user objects on the project team' do it 'accesses valid user objects on the project team' do
@u_foo = create(:user, username: 'foo') @u_foo = create(:user, username: 'foo')
......
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) }
let(:user) { create(:user) } let(:user) { create(:user) }
describe '#prepare_satellite!' do describe '#prepare_satellite!' do
......
...@@ -12,9 +12,10 @@ describe 'Gitlab::Satellite::MergeAction' do ...@@ -12,9 +12,10 @@ describe 'Gitlab::Satellite::MergeAction' do
@close_commit2 = ['scss_refactoring', 'f0f14c8eaba69ebddd766498a9d0b0e79becd633'] @close_commit2 = ['scss_refactoring', 'f0f14c8eaba69ebddd766498a9d0b0e79becd633']
end end
let(:project) { create(:project_with_code) } let(:project) { create(:project, namespace: create(:group)) }
let(:fork_project) { create(:project, namespace: create(:group)) }
let(:merge_request) { create(:merge_request, source_project: project, target_project: project) } let(:merge_request) { create(:merge_request, source_project: project, target_project: project) }
let(:merge_request_fork) { create(:merge_request) } let(:merge_request_fork) { create(:merge_request, source_project: fork_project, target_project: project) }
describe '#commits_between' do describe '#commits_between' do
def verify_commits(commits, first_commit_sha, last_commit_sha) def verify_commits(commits, first_commit_sha, last_commit_sha)
......
...@@ -5,7 +5,7 @@ describe Notify do ...@@ -5,7 +5,7 @@ describe Notify do
include EmailSpec::Matchers include EmailSpec::Matchers
let(:recipient) { create(:user, email: 'recipient@example.com') } let(:recipient) { create(:user, email: 'recipient@example.com') }
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
shared_examples 'a multiple recipients email' do shared_examples 'a multiple recipients email' do
it 'is sent to the given recipient' do it 'is sent to the given recipient' do
......
...@@ -25,7 +25,7 @@ describe AssemblaService do ...@@ -25,7 +25,7 @@ describe AssemblaService do
describe "Execute" do describe "Execute" do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
before do before do
@assembla_service = AssemblaService.new @assembla_service = AssemblaService.new
...@@ -33,14 +33,15 @@ describe AssemblaService do ...@@ -33,14 +33,15 @@ describe AssemblaService do
project_id: project.id, project_id: project.id,
project: project, project: project,
service_hook: true, service_hook: true,
token: 'verySecret' token: 'verySecret',
subdomain: 'project_name'
) )
@sample_data = GitPushService.new.sample_data(project, user) @sample_data = GitPushService.new.sample_data(project, user)
@api_url = 'https://atlas.assembla.com/spaces/ouposp/github_tool?secret_key=verySecret' @api_url = 'https://atlas.assembla.com/spaces/project_name/github_tool?secret_key=verySecret'
WebMock.stub_request(:post, @api_url) WebMock.stub_request(:post, @api_url)
end end
it "should call FlowDock API" do it "should call Assembla API" do
@assembla_service.execute(@sample_data) @assembla_service.execute(@sample_data)
WebMock.should have_requested(:post, @api_url).with( WebMock.should have_requested(:post, @api_url).with(
body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/ body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/
......
require 'spec_helper' require 'spec_helper'
describe Commit do describe Commit do
let(:project) { create :project_with_code } let(:project) { create :project }
let(:commit) { project.repository.commit } let(:commit) { project.repository.commit }
describe '#title' do describe '#title' do
......
...@@ -25,7 +25,7 @@ describe FlowdockService do ...@@ -25,7 +25,7 @@ describe FlowdockService do
describe "Execute" do describe "Execute" do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
before do before do
@flowdock_service = FlowdockService.new @flowdock_service = FlowdockService.new
......
...@@ -73,14 +73,13 @@ describe MergeRequest do ...@@ -73,14 +73,13 @@ describe MergeRequest do
describe '#for_fork?' do describe '#for_fork?' do
it 'returns true if the merge request is for a fork' do it 'returns true if the merge request is for a fork' do
subject.source_project = create(:source_project) subject.source_project = create(:project, namespace: create(:group))
subject.target_project = create(:target_project) subject.target_project = create(:project, namespace: create(:group))
subject.for_fork?.should be_true subject.for_fork?.should be_true
end end
it 'returns false if is not for a fork' do it 'returns false if is not for a fork' do
subject.source_project = create(:source_project)
subject.target_project = subject.source_project
subject.for_fork?.should be_false subject.for_fork?.should be_false
end end
end end
......
...@@ -206,7 +206,7 @@ describe Note do ...@@ -206,7 +206,7 @@ describe Note do
end end
describe '#create_cross_reference_note' do describe '#create_cross_reference_note' do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:author) { create(:user) } let(:author) { create(:user) }
let(:issue) { create(:issue, project: project) } let(:issue) { create(:issue, project: project) }
let(:mergereq) { create(:merge_request, target_project: project) } let(:mergereq) { create(:merge_request, target_project: project) }
......
...@@ -128,7 +128,7 @@ describe Project do ...@@ -128,7 +128,7 @@ describe Project do
end end
describe :update_merge_requests do describe :update_merge_requests do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
before do before do
@merge_request = create(:merge_request, source_project: project, target_project: project) @merge_request = create(:merge_request, source_project: project, target_project: project)
...@@ -136,7 +136,7 @@ describe Project do ...@@ -136,7 +136,7 @@ describe Project do
end end
it "should close merge request if last commit from source branch was pushed to target branch" do it "should close merge request if last commit from source branch was pushed to target branch" do
@merge_request.reloaded_commits @merge_request.reload_code
@merge_request.last_commit.id.should == "69b34b7e9ad9f496f0ad10250be37d6265a03bba" @merge_request.last_commit.id.should == "69b34b7e9ad9f496f0ad10250be37d6265a03bba"
project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "69b34b7e9ad9f496f0ad10250be37d6265a03bba", "refs/heads/stable", @key.user) project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "69b34b7e9ad9f496f0ad10250be37d6265a03bba", "refs/heads/stable", @key.user)
@merge_request.reload @merge_request.reload
...@@ -144,7 +144,6 @@ describe Project do ...@@ -144,7 +144,6 @@ describe Project do
end end
it "should update merge request commits with new one if pushed to source branch" do it "should update merge request commits with new one if pushed to source branch" do
@merge_request.last_commit.should == nil
project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "69b34b7e9ad9f496f0ad10250be37d6265a03bba", "refs/heads/master", @key.user) project.update_merge_requests("8716fc78f3c65bbf7bcf7b574febd583bc5d2812", "69b34b7e9ad9f496f0ad10250be37d6265a03bba", "refs/heads/master", @key.user)
@merge_request.reload @merge_request.reload
@merge_request.last_commit.id.should == "69b34b7e9ad9f496f0ad10250be37d6265a03bba" @merge_request.last_commit.id.should == "69b34b7e9ad9f496f0ad10250be37d6265a03bba"
...@@ -156,10 +155,10 @@ describe Project do ...@@ -156,10 +155,10 @@ describe Project do
context 'with namespace' do context 'with namespace' do
before do before do
@group = create :group, name: 'gitlab' @group = create :group, name: 'gitlab'
@project = create(:project, name: 'gitlab-ci', namespace: @group) @project = create(:project, name: 'gitlabhq', namespace: @group)
end end
it { Project.find_with_namespace('gitlab/gitlab-ci').should == @project } it { Project.find_with_namespace('gitlab/gitlabhq').should == @project }
it { Project.find_with_namespace('gitlab-ci').should be_nil } it { Project.find_with_namespace('gitlab-ci').should be_nil }
end end
end end
...@@ -168,10 +167,10 @@ describe Project do ...@@ -168,10 +167,10 @@ describe Project do
context 'with namespace' do context 'with namespace' do
before do before do
@group = create :group, name: 'gitlab' @group = create :group, name: 'gitlab'
@project = create(:project, name: 'gitlab-ci', namespace: @group) @project = create(:project, name: 'gitlabhq', namespace: @group)
end end
it { @project.to_param.should == "gitlab/gitlab-ci" } it { @project.to_param.should == "gitlab/gitlabhq" }
end end
end end
...@@ -237,7 +236,7 @@ describe Project do ...@@ -237,7 +236,7 @@ describe Project do
end end
describe :open_branches do describe :open_branches do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
before do before do
project.protected_branches.create(name: 'master') project.protected_branches.create(name: 'master')
......
...@@ -44,12 +44,12 @@ describe Service do ...@@ -44,12 +44,12 @@ describe Service do
end end
describe :can_test do describe :can_test do
it { @testable.should == false } it { @testable.should == true }
end end
end end
describe "With commits" do describe "With commits" do
let (:project) { create :project_with_code } let (:project) { create :project }
before do before do
@service.stub( @service.stub(
......
...@@ -4,16 +4,17 @@ describe MergeRequestObserver do ...@@ -4,16 +4,17 @@ describe MergeRequestObserver do
let(:some_user) { create :user } let(:some_user) { create :user }
let(:assignee) { create :user } let(:assignee) { create :user }
let(:author) { create :user } let(:author) { create :user }
let(:project) { create :project }
let(:mr_mock) { double(:merge_request, id: 42, assignee: assignee, author: author).as_null_object } let(:mr_mock) { double(:merge_request, id: 42, assignee: assignee, author: author).as_null_object }
let(:assigned_mr) { create(:merge_request, assignee: assignee, author: author, target_project: create(:project)) } let(:assigned_mr) { create(:merge_request, assignee: assignee, author: author, source_project: project) }
let(:unassigned_mr) { create(:merge_request, author: author, target_project: create(:project)) } let(:unassigned_mr) { create(:merge_request, author: author, source_project: project) }
let(:closed_assigned_mr) { create(:closed_merge_request, assignee: assignee, author: author, target_project: create(:project)) } let(:closed_assigned_mr) { create(:closed_merge_request, assignee: assignee, author: author, source_project: project) }
let(:closed_unassigned_mr) { create(:closed_merge_request, author: author, target_project: create(:project)) } let(:closed_unassigned_mr) { create(:closed_merge_request, author: author, source_project: project) }
before { subject.stub(:current_user).and_return(some_user) } before { subject.stub(:current_user).and_return(some_user) }
before { subject.stub(notification: double('NotificationService').as_null_object) } before { subject.stub(notification: double('NotificationService').as_null_object) }
before { mr_mock.stub(:author_id) } before { mr_mock.stub(:author_id) }
before { mr_mock.stub(:target_project) } before { mr_mock.stub(:source_project) }
before { mr_mock.stub(:source_project) } before { mr_mock.stub(:source_project) }
before { mr_mock.stub(:project) } before { mr_mock.stub(:project) }
before { mr_mock.stub(:create_cross_references!).and_return(true) } before { mr_mock.stub(:create_cross_references!).and_return(true) }
...@@ -46,7 +47,7 @@ describe MergeRequestObserver do ...@@ -46,7 +47,7 @@ describe MergeRequestObserver do
end end
it 'is called when a merge request is changed' do it 'is called when a merge request is changed' do
changed = create(:merge_request, source_project: create(:project)) changed = create(:merge_request, source_project: project)
subject.should_receive(:after_update) subject.should_receive(:after_update)
MergeRequest.observers.enable :merge_request_observer do MergeRequest.observers.enable :merge_request_observer do
...@@ -81,13 +82,13 @@ describe MergeRequestObserver do ...@@ -81,13 +82,13 @@ describe MergeRequestObserver do
context '#after_close' do context '#after_close' do
context 'a status "closed"' do context 'a status "closed"' do
it 'note is created if the merge request is being closed' do it 'note is created if the merge request is being closed' do
Note.should_receive(:create_status_change_note).with(assigned_mr, assigned_mr.target_project, some_user, 'closed', nil) Note.should_receive(:create_status_change_note).with(assigned_mr, assigned_mr.source_project, some_user, 'closed', nil)
assigned_mr.close assigned_mr.close
end end
it 'notification is delivered only to author if the merge request is being closed' do it 'notification is delivered only to author if the merge request is being closed' do
Note.should_receive(:create_status_change_note).with(unassigned_mr, unassigned_mr.target_project, some_user, 'closed', nil) Note.should_receive(:create_status_change_note).with(unassigned_mr, unassigned_mr.source_project, some_user, 'closed', nil)
unassigned_mr.close unassigned_mr.close
end end
...@@ -97,13 +98,13 @@ describe MergeRequestObserver do ...@@ -97,13 +98,13 @@ describe MergeRequestObserver do
context '#after_reopen' do context '#after_reopen' do
context 'a status "reopened"' do context 'a status "reopened"' do
it 'note is created if the merge request is being reopened' do it 'note is created if the merge request is being reopened' do
Note.should_receive(:create_status_change_note).with(closed_assigned_mr, closed_assigned_mr.target_project, some_user, 'reopened', nil) Note.should_receive(:create_status_change_note).with(closed_assigned_mr, closed_assigned_mr.source_project, some_user, 'reopened', nil)
closed_assigned_mr.reopen closed_assigned_mr.reopen
end end
it 'notification is delivered only to author if the merge request is being reopened' do it 'notification is delivered only to author if the merge request is being reopened' do
Note.should_receive(:create_status_change_note).with(closed_unassigned_mr, closed_unassigned_mr.target_project, some_user, 'reopened', nil) Note.should_receive(:create_status_change_note).with(closed_unassigned_mr, closed_unassigned_mr.source_project, some_user, 'reopened', nil)
closed_unassigned_mr.reopen closed_unassigned_mr.reopen
end end
...@@ -118,20 +119,13 @@ describe MergeRequestObserver do ...@@ -118,20 +119,13 @@ describe MergeRequestObserver do
it { @event.project.should == project } it { @event.project.should == project }
end end
let(:project) { create(:project) }
before do before do
TestEnv.enable_observers @merge_request = create(:merge_request, source_project: project, source_project: project)
@merge_request = create(:merge_request, source_project: project, target_project: project)
@event = Event.last @event = Event.last
end end
after do
TestEnv.disable_observers
end
it_should_be_valid_event it_should_be_valid_event
it { @event.action.should == Event::CREATED } it { @event.action.should == Event::CREATED }
it { @event.target.should == @merge_request } it { @event.target.should == @merge_request }
end end
end end
...@@ -6,7 +6,7 @@ describe API::API do ...@@ -6,7 +6,7 @@ describe API::API do
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) { create(:project_with_code, namespace: user.namespace ) } let!(:project) { create(:project, namespace: user.namespace ) }
before { project.team << [user, :developer] } before { project.team << [user, :developer] }
describe "POST /projects/:id/repository/files" do describe "POST /projects/:id/repository/files" do
......
...@@ -5,7 +5,7 @@ describe API::API do ...@@ -5,7 +5,7 @@ describe API::API do
before(:each) { ActiveRecord::Base.observers.enable(:user_observer) } before(:each) { ActiveRecord::Base.observers.enable(:user_observer) }
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
let(:user) { create(:user) } let(:user) { create(:user) }
let!(:project) {create(:project_with_code, creator_id: user.id, namespace: user.namespace) } let!(:project) {create(:project, creator_id: user.id, namespace: user.namespace) }
let!(:merge_request) { create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, title: "Test") } let!(:merge_request) { create(:merge_request, author: user, assignee: user, source_project: project, target_project: project, title: "Test") }
before { before {
project.team << [user, :reporters] project.team << [user, :reporters]
...@@ -80,8 +80,8 @@ describe API::API do ...@@ -80,8 +80,8 @@ describe API::API do
context 'forked projects' do context 'forked projects' do
let!(:user2) {create(:user)} let!(:user2) {create(:user)}
let!(:forked_project_link) { build(:forked_project_link) } let!(:forked_project_link) { build(:forked_project_link) }
let!(:fork_project) { create(:source_project_with_code, forked_project_link: forked_project_link, namespace: user2.namespace, creator_id: user2.id) } let!(:fork_project) { create(:project, forked_project_link: forked_project_link, namespace: user2.namespace, creator_id: user2.id) }
let!(:unrelated_project) { create(:target_project_with_code, namespace: user2.namespace, creator_id: user2.id) } let!(:unrelated_project) { create(:project, namespace: create(:user).namespace, creator_id: user2.id) }
before :each do |each| before :each do |each|
fork_project.team << [user2, :reporters] fork_project.team << [user2, :reporters]
...@@ -198,5 +198,4 @@ describe API::API do ...@@ -198,5 +198,4 @@ describe API::API do
response.status.should == 404 response.status.should == 404
end end
end end
end end
...@@ -7,7 +7,7 @@ describe API::API, 'ProjectHooks' do ...@@ -7,7 +7,7 @@ describe API::API, 'ProjectHooks' do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user3) { create(:user) } let(:user3) { create(:user) }
let!(:project) { create(:project_with_code, creator_id: user.id, namespace: user.namespace) } let!(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
let!(:hook) { create(:project_hook, project: project, url: "http://example.com") } let!(:hook) { create(:project_hook, project: project, url: "http://example.com") }
before do before do
......
...@@ -9,14 +9,14 @@ describe API::API do ...@@ -9,14 +9,14 @@ describe API::API do
let(:user2) { create(:user) } let(:user2) { create(:user) }
let(:user3) { create(:user) } let(:user3) { create(:user) }
let(:admin) { create(:admin) } let(:admin) { create(:admin) }
let!(:project) { create(:project_with_code, creator_id: user.id, namespace: user.namespace) } let(:project) { create(:project, creator_id: user.id, namespace: user.namespace) }
let!(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') } let(:snippet) { create(:project_snippet, author: user, project: project, title: 'example') }
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 { project.team << [user, :reporter] }
describe "GET /projects" do describe "GET /projects" do
before { project }
context "when unauthenticated" do context "when unauthenticated" do
it "should return authentication error" do it "should return authentication error" do
get api("/projects") get api("/projects")
...@@ -36,6 +36,8 @@ describe API::API do ...@@ -36,6 +36,8 @@ describe API::API do
end end
describe "GET /projects/all" do describe "GET /projects/all" do
before { project }
context "when unauthenticated" do context "when unauthenticated" do
it "should return authentication error" do it "should return authentication error" do
get api("/projects/all") get api("/projects/all")
...@@ -174,6 +176,7 @@ describe API::API do ...@@ -174,6 +176,7 @@ describe API::API do
end end
describe "POST /projects/user/:id" do describe "POST /projects/user/:id" do
before { project }
before { admin } before { admin }
it "should create new project without path" do it "should create new project without path" do
...@@ -255,6 +258,8 @@ describe API::API do ...@@ -255,6 +258,8 @@ describe API::API do
end end
describe "GET /projects/:id" do describe "GET /projects/:id" do
before { project }
it "should return a project by id" do it "should return a project by id" do
get api("/projects/#{project.id}", user) get api("/projects/#{project.id}", user)
response.status.should == 200 response.status.should == 200
...@@ -282,6 +287,8 @@ describe API::API do ...@@ -282,6 +287,8 @@ describe API::API do
end end
describe "GET /projects/:id/events" do describe "GET /projects/:id/events" do
before { users_project }
it "should return a project events" do it "should return a project events" do
get api("/projects/#{project.id}/events", user) get api("/projects/#{project.id}/events", user)
response.status.should == 200 response.status.should == 200
...@@ -305,6 +312,9 @@ describe API::API do ...@@ -305,6 +312,9 @@ describe API::API do
end end
describe "GET /projects/:id/members" do describe "GET /projects/:id/members" do
before { users_project }
before { users_project2 }
it "should return project team members" do it "should return project team members" do
get api("/projects/#{project.id}/members", user) get api("/projects/#{project.id}/members", user)
response.status.should == 200 response.status.should == 200
...@@ -328,6 +338,8 @@ describe API::API do ...@@ -328,6 +338,8 @@ describe API::API do
end end
describe "GET /projects/:id/members/:user_id" do describe "GET /projects/:id/members/:user_id" do
before { users_project }
it "should return project team member" do it "should return project team member" do
get api("/projects/#{project.id}/members/#{user.id}", user) get api("/projects/#{project.id}/members/#{user.id}", user)
response.status.should == 200 response.status.should == 200
...@@ -383,6 +395,8 @@ describe API::API do ...@@ -383,6 +395,8 @@ describe API::API do
end end
describe "PUT /projects/:id/members/:user_id" do describe "PUT /projects/:id/members/:user_id" do
before { users_project2 }
it "should update project team member" do it "should update project team member" do
put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: UsersProject::MASTER put api("/projects/#{project.id}/members/#{user3.id}", user), access_level: UsersProject::MASTER
response.status.should == 200 response.status.should == 200
...@@ -407,6 +421,9 @@ describe API::API do ...@@ -407,6 +421,9 @@ describe API::API do
end end
describe "DELETE /projects/:id/members/:user_id" do describe "DELETE /projects/:id/members/:user_id" do
before { users_project }
before { users_project2 }
it "should remove user from project team" do it "should remove user from project team" do
expect { expect {
delete api("/projects/#{project.id}/members/#{user3.id}", user) delete api("/projects/#{project.id}/members/#{user3.id}", user)
...@@ -425,9 +442,7 @@ describe API::API do ...@@ -425,9 +442,7 @@ describe API::API do
delete api("/projects/#{project.id}/members/#{user3.id}", user) delete api("/projects/#{project.id}/members/#{user3.id}", user)
response.status.should == 200 response.status.should == 200
end end
end
describe "DELETE /projects/:id/members/:user_id" do
it "should return 200 OK when the user was not member" do it "should return 200 OK when the user was not member" do
expect { expect {
delete api("/projects/#{project.id}/members/1000000", user) delete api("/projects/#{project.id}/members/1000000", user)
...@@ -439,6 +454,8 @@ describe API::API do ...@@ -439,6 +454,8 @@ describe API::API do
end end
describe "GET /projects/:id/snippets" do describe "GET /projects/:id/snippets" do
before { snippet }
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)
response.status.should == 200 response.status.should == 200
...@@ -505,6 +522,8 @@ describe API::API do ...@@ -505,6 +522,8 @@ describe API::API do
end end
describe "DELETE /projects/:id/snippets/:snippet_id" do describe "DELETE /projects/:id/snippets/:snippet_id" do
before { snippet }
it "should delete existing project snippet" do it "should delete existing project snippet" do
expect { expect {
delete api("/projects/#{project.id}/snippets/#{snippet.id}", user) delete api("/projects/#{project.id}/snippets/#{snippet.id}", user)
...@@ -657,15 +676,15 @@ describe API::API do ...@@ -657,15 +676,15 @@ describe API::API do
describe "GET /projects/search/:query" do describe "GET /projects/search/:query" do
let!(:query) { 'query'} let!(:query) { 'query'}
let!(:search) { create(:project, name: query, creator_id: user.id, namespace: user.namespace) } let!(:search) { create(:empty_project, name: query, creator_id: user.id, namespace: user.namespace) }
let!(:pre) { create(:project, name: "pre_#{query}", creator_id: user.id, namespace: user.namespace) } let!(:pre) { create(:empty_project, name: "pre_#{query}", creator_id: user.id, namespace: user.namespace) }
let!(:post) { create(:project, name: "#{query}_post", creator_id: user.id, namespace: user.namespace) } let!(:post) { create(:empty_project, name: "#{query}_post", creator_id: user.id, namespace: user.namespace) }
let!(:pre_post) { create(:project, name: "pre_#{query}_post", creator_id: user.id, namespace: user.namespace) } let!(:pre_post) { create(:empty_project, name: "pre_#{query}_post", creator_id: user.id, namespace: user.namespace) }
let!(:unfound) { create(:project, name: 'unfound', creator_id: user.id, namespace: user.namespace) } let!(:unfound) { create(:empty_project, name: 'unfound', creator_id: user.id, namespace: user.namespace) }
let!(:internal) { create(:project, name: "internal #{query}", visibility_level: Gitlab::VisibilityLevel::INTERNAL) } let!(:internal) { create(:empty_project, name: "internal #{query}", visibility_level: Gitlab::VisibilityLevel::INTERNAL) }
let!(:unfound_internal) { create(:project, name: 'unfound internal', visibility_level: Gitlab::VisibilityLevel::INTERNAL) } let!(:unfound_internal) { create(:empty_project, name: 'unfound internal', visibility_level: Gitlab::VisibilityLevel::INTERNAL) }
let!(:public) { create(:project, name: "public #{query}", visibility_level: Gitlab::VisibilityLevel::PUBLIC) } let!(:public) { create(:empty_project, name: "public #{query}", visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
let!(:unfound_public) { create(:project, name: 'unfound public', visibility_level: Gitlab::VisibilityLevel::PUBLIC) } let!(:unfound_public) { create(:empty_project, name: 'unfound public', visibility_level: Gitlab::VisibilityLevel::PUBLIC) }
context "when unauthenticated" do context "when unauthenticated" do
it "should return authentication error" do it "should return authentication error" do
......
...@@ -8,7 +8,7 @@ describe API::API do ...@@ -8,7 +8,7 @@ describe API::API do
let(:user) { create(:user) } let(:user) { create(:user) }
let(:user2) { create(:user) } let(:user2) { create(:user) }
let!(:project) { create(:project_with_code, creator_id: user.id) } let!(:project) { create(:project, creator_id: user.id) }
let!(:master) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) } let!(:master) { create(:users_project, user: user, project: project, project_access: UsersProject::MASTER) }
let!(:guest) { create(:users_project, user: user2, project: project, project_access: UsersProject::GUEST) } let!(:guest) { create(:users_project, user: user2, project: project, project_access: UsersProject::GUEST) }
......
...@@ -6,7 +6,7 @@ describe API::API do ...@@ -6,7 +6,7 @@ describe API::API do
after(:each) { ActiveRecord::Base.observers.disable(:user_observer) } after(:each) { ActiveRecord::Base.observers.disable(:user_observer) }
let(:user) { create(:user) } let(:user) { create(:user) }
let(:project) {create(:project_with_code, creator_id: user.id, namespace: user.namespace) } let(:project) {create(:project, creator_id: user.id, namespace: user.namespace) }
describe "POST /projects/:id/services/gitlab-ci" do describe "POST /projects/:id/services/gitlab-ci" do
it "should update gitlab-ci settings" do it "should update gitlab-ci settings" do
......
...@@ -93,7 +93,7 @@ describe API::API do ...@@ -93,7 +93,7 @@ describe API::API do
expect { expect {
post api("/users", admin), attr post api("/users", admin), attr
}.to change { User.count }.by(1) }.to change { User.count }.by(1)
user = User.find_by_username(attr[:username]) user = User.find_by(username: attr[:username])
user.projects_limit.should == limit user.projects_limit.should == limit
user.theme_id.should == Gitlab::Theme::MARS user.theme_id.should == Gitlab::Theme::MARS
Gitlab.config.gitlab.unstub(:default_projects_limit) Gitlab.config.gitlab.unstub(:default_projects_limit)
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe GitPushService do describe GitPushService do
let (:user) { create :user } let (:user) { create :user }
let (:project) { create :project_with_code } let (:project) { create :project }
let (:service) { GitPushService.new } let (:service) { GitPushService.new }
before do before do
......
...@@ -2,7 +2,7 @@ require 'spec_helper' ...@@ -2,7 +2,7 @@ require 'spec_helper'
describe TestHookService do describe TestHookService do
let (:user) { create :user } let (:user) { create :user }
let (:project) { create :project_with_code } let (:project) { create :project }
let (:hook) { create :project_hook, project: project } let (:hook) { create :project_hook, project: project }
describe :execute do describe :execute do
......
...@@ -11,7 +11,7 @@ def common_mentionable_setup ...@@ -11,7 +11,7 @@ def common_mentionable_setup
let(:mentioned_issue) { create :issue, project: mproject } let(:mentioned_issue) { create :issue, project: mproject }
let(:other_issue) { create :issue, project: mproject } let(:other_issue) { create :issue, project: mproject }
let(:mentioned_mr) { create :merge_request, target_project: mproject, source_branch: 'different' } let(:mentioned_mr) { create :merge_request, source_project: mproject, source_branch: 'different' }
let(:mentioned_commit) { double('commit', sha: '1234567890abcdef').as_null_object } let(:mentioned_commit) { double('commit', sha: '1234567890abcdef').as_null_object }
# Override to add known commits to the repository stub. # Override to add known commits to the repository stub.
......
...@@ -73,6 +73,10 @@ module TestEnv ...@@ -73,6 +73,10 @@ module TestEnv
version: '6.3.0' version: '6.3.0'
) )
Gitlab::Satellite::MergeAction.any_instance.stub(
merge!: true,
)
Gitlab::Satellite::Satellite.any_instance.stub( Gitlab::Satellite::Satellite.any_instance.stub(
exists?: true, exists?: true,
destroy: true, destroy: true,
......
...@@ -9,7 +9,7 @@ describe PostReceive do ...@@ -9,7 +9,7 @@ describe PostReceive do
end end
context "web hook" do context "web hook" do
let(:project) { create(:project_with_code) } let(:project) { create(:project) }
let(:key) { create(:key, user: project.owner) } let(:key) { create(:key, user: project.owner) }
let(:key_id) { key.shell_id } let(:key_id) { key.shell_id }
...@@ -19,7 +19,7 @@ describe PostReceive do ...@@ -19,7 +19,7 @@ describe PostReceive do
end end
it "does not run if the author is not in the project" do it "does not run if the author is not in the project" do
Key.stub(find_by_id: nil) Key.stub(:find_by).with(hash_including(id: anything())) { nil }
project.should_not_receive(:execute_hooks) project.should_not_receive(:execute_hooks)
......
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