Skip to content
Snippets Groups Projects
Commit 70c44a0d authored by Hannes Rosenögger's avatar Hannes Rosenögger
Browse files

Fix tests, merge conflicts, some minor issues and make the project avatar feature mergable

parent 42bac7f9
No related branches found
No related tags found
1 merge request!8686add "Uplaod" and "Replace" functionality
Showing
with 369 additions and 360 deletions
Loading
Loading
@@ -34,7 +34,7 @@ v 7.8.0
-
-
-
-
- Add Project Avatars (Steven Thonus and Hannes Rosenögger)
-
-
- Password reset token validity increased from 2 hours to 2 days since it is also send on account creation.
Loading
Loading
Loading
Loading
@@ -96,6 +96,7 @@ class Dispatcher
new Profile()
when 'projects'
new Project()
new ProjectAvatar()
switch path[1]
when 'edit'
shortcut_handler = new ShortcutsNavigation()
Loading
Loading
Loading
Loading
@@ -18,13 +18,3 @@ class @Project
$.cookie('hide_no_ssh_message', 'false', { path: path })
$(@).parents('.no-ssh-key-message').hide()
e.preventDefault()
# avatar
$('.js-choose-project-avatar-button').bind "click", ->
form = $(this).closest("form")
form.find(".js-project-avatar-input").click()
$('.js-project-avatar-input').bind "change", ->
form = $(this).closest("form")
filename = $(this).val().replace(/^.*[\\\/]/, '')
form.find(".js-avatar-filename").text(filename)
class @ProjectAvatar
constructor: ->
$('.js-choose-project-avatar-button').bind 'click', ->
form = $(this).closest('form')
form.find('.js-project-avatar-input').click()
$('.js-project-avatar-input').bind 'change', ->
form = $(this).closest('form')
filename = $(this).val().replace(/^.*[\\\/]/, '')
form.find('.js-avatar-filename').text(filename)
Loading
Loading
@@ -14,7 +14,7 @@ class ProjectsController < ApplicationController
end
 
def edit
render 'edit', layout: "project_settings"
render 'edit', layout: 'project_settings'
end
 
def create
Loading
Loading
@@ -36,7 +36,7 @@ class ProjectsController < ApplicationController
format.html { redirect_to edit_project_path(@project), notice: 'Project was successfully updated.' }
format.js
else
format.html { render "edit", layout: "project_settings" }
format.html { render 'edit', layout: 'project_settings' }
format.js
end
end
Loading
Loading
@@ -66,17 +66,17 @@ class ProjectsController < ApplicationController
format.html do
if @project.repository_exists?
if @project.empty_repo?
render "projects/empty", layout: user_layout
render 'projects/empty', layout: user_layout
else
@last_push = current_user.recent_push(@project.id) if current_user
render :show, layout: user_layout
end
else
render "projects/no_repo", layout: user_layout
render 'projects/no_repo', layout: user_layout
end
end
 
format.json { pager_json("events/_events", @events.count) }
format.json { pager_json('events/_events', @events.count) }
end
end
 
Loading
Loading
@@ -87,9 +87,9 @@ class ProjectsController < ApplicationController
 
respond_to do |format|
format.html do
flash[:alert] = "Project deleted."
flash[:alert] = 'Project deleted.'
 
if request.referer.include?("/admin")
if request.referer.include?('/admin')
redirect_to admin_projects_path
else
redirect_to projects_dashboard_path
Loading
Loading
@@ -141,7 +141,7 @@ class ProjectsController < ApplicationController
if link_to_image
format.json { render json: { link: link_to_image } }
else
format.json { render json: "Invalid file.", status: :unprocessable_entity }
format.json { render json: 'Invalid file.', status: :unprocessable_entity }
end
end
end
Loading
Loading
@@ -172,14 +172,14 @@ class ProjectsController < ApplicationController
end
 
def user_layout
current_user ? "projects" : "public_projects"
current_user ? 'projects' : 'public_projects'
end
 
def project_params
params.require(:project).permit(
:name, :path, :description, :issues_tracker, :tag_list,
:issues_enabled, :merge_requests_enabled, :snippets_enabled, :issues_tracker_id, :default_branch,
:wiki_enabled, :visibility_level, :import_url, :last_activity_at, :namespace_id
:wiki_enabled, :visibility_level, :import_url, :last_activity_at, :namespace_id, :avatar
)
end
 
Loading
Loading
Loading
Loading
@@ -54,10 +54,10 @@ module ApplicationHelper
project = Project.find_with_namespace(project_id)
if project.avatar.present?
image_tag project.avatar.url, options
elsif options[:only_uploaded]
image_tag '/assets/no_project_icon.png', options
elsif project.avatar_in_git
image_tag project_avatar_path(project), options
elsif options[:only_uploaded]
image_tag '/assets/no_project_icon.png', options
else # generated icon
project_identicon(project, options)
end
Loading
Loading
@@ -107,24 +107,24 @@ module ApplicationHelper
if project.repo_exists?
time_ago_with_tooltip(project.repository.commit.committed_date)
else
"Never"
'Never'
end
rescue
"Never"
'Never'
end
 
def grouped_options_refs
repository = @project.repository
 
options = [
["Branches", repository.branch_names],
["Tags", VersionSorter.rsort(repository.tag_names)]
['Branches', repository.branch_names],
['Tags', VersionSorter.rsort(repository.tag_names)]
]
 
# If reference is commit id - we should add it to branch/tag selectbox
if(@ref && !options.flatten.include?(@ref) &&
@ref =~ /^[0-9a-zA-Z]{6,52}$/)
options << ["Commit", [@ref]]
options << ['Commit', [@ref]]
end
 
grouped_options_for_select(options, @ref || @project.default_branch)
Loading
Loading
@@ -186,7 +186,7 @@ module ApplicationHelper
path = controller.controller_path.split('/')
namespace = path.first if path.second
 
[namespace, controller.controller_name, controller.action_name].compact.join(":")
[namespace, controller.controller_name, controller.action_name].compact.join(':')
end
 
# shortcut for gitlab config
Loading
Loading
@@ -201,13 +201,13 @@ module ApplicationHelper
 
def search_placeholder
if @project && @project.persisted?
"Search in this project"
'Search in this project'
elsif @snippet || @snippets || @show_snippets
'Search snippets'
elsif @group && @group.persisted?
"Search in this group"
'Search in this group'
else
"Search"
'Search'
end
end
 
Loading
Loading
@@ -218,7 +218,7 @@ module ApplicationHelper
def time_ago_with_tooltip(date, placement = 'top', html_class = 'time_ago')
capture_haml do
haml_tag :time, date.to_s,
class: html_class, datetime: date.getutc.iso8601, title: date.stamp("Aug 21, 2011 9:23pm"),
class: html_class, datetime: date.getutc.iso8601, title: date.stamp('Aug 21, 2011 9:23pm'),
data: { toggle: 'tooltip', placement: placement }
 
haml_tag :script, "$('." + html_class + "').timeago().tooltip()"
Loading
Loading
@@ -241,8 +241,8 @@ module ApplicationHelper
end
 
def spinner(text = nil, visible = false)
css_class = "loading"
css_class << " hide" unless visible
css_class = 'loading'
css_class << ' hide' unless visible
 
content_tag :div, class: css_class do
content_tag(:i, nil, class: 'fa fa-spinner fa-spin') + text
Loading
Loading
@@ -259,17 +259,17 @@ module ApplicationHelper
absolute_uri = nil
end
 
# Add "nofollow" only to external links
# Add 'nofollow' only to external links
if host && host != Gitlab.config.gitlab.host && absolute_uri
if html_options
if html_options[:rel]
html_options[:rel] << " nofollow"
html_options[:rel] << ' nofollow'
else
html_options.merge!(rel: "nofollow")
html_options.merge!(rel: 'nofollow')
end
else
html_options = Hash.new
html_options[:rel] = "nofollow"
html_options[:rel] = 'nofollow'
end
end
 
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@
# merge_requests_enabled :boolean default(TRUE), not null
# wiki_enabled :boolean default(TRUE), not null
# namespace_id :integer
# issues_tracker :string(255) default("gitlab"), not null
# issues_tracker :string(255) default('gitlab'), not null
# issues_tracker_id :string(255)
# snippets_enabled :boolean default(TRUE), not null
# last_activity_at :datetime
Loading
Loading
@@ -29,6 +29,9 @@
# avatar :string(255)
#
 
require 'carrierwave/orm/activerecord'
require 'file_size_validator'
class Project < ActiveRecord::Base
include Gitlab::ShellAdapter
include Gitlab::VisibilityLevel
Loading
Loading
@@ -50,8 +53,8 @@ class Project < ActiveRecord::Base
attr_accessor :new_default_branch
 
# Relations
belongs_to :creator, foreign_key: "creator_id", class_name: "User"
belongs_to :group, -> { where(type: Group) }, foreign_key: "namespace_id"
belongs_to :creator, foreign_key: 'creator_id', class_name: 'User'
belongs_to :group, -> { where(type: Group) }, foreign_key: 'namespace_id'
belongs_to :namespace
 
has_one :last_event, -> {order 'events.created_at DESC'}, class_name: 'Event', foreign_key: 'project_id'
Loading
Loading
@@ -71,20 +74,20 @@ class Project < ActiveRecord::Base
has_one :bamboo_service, dependent: :destroy
has_one :teamcity_service, dependent: :destroy
has_one :pushover_service, dependent: :destroy
has_one :forked_project_link, dependent: :destroy, foreign_key: "forked_to_project_id"
has_one :forked_project_link, dependent: :destroy, foreign_key: 'forked_to_project_id'
has_one :forked_from_project, through: :forked_project_link
# Merge Requests for target project should be removed with it
has_many :merge_requests, dependent: :destroy, foreign_key: "target_project_id"
has_many :merge_requests, dependent: :destroy, foreign_key: 'target_project_id'
# Merge requests from source project should be kept when source project was removed
has_many :fork_merge_requests, foreign_key: "source_project_id", class_name: MergeRequest
has_many :fork_merge_requests, foreign_key: 'source_project_id', class_name: MergeRequest
has_many :issues, -> { order 'issues.state DESC, issues.created_at DESC' }, dependent: :destroy
has_many :labels, dependent: :destroy
has_many :services, dependent: :destroy
has_many :events, dependent: :destroy
has_many :milestones, dependent: :destroy
has_many :notes, dependent: :destroy
has_many :snippets, dependent: :destroy, class_name: "ProjectSnippet"
has_many :hooks, dependent: :destroy, class_name: "ProjectHook"
has_many :snippets, dependent: :destroy, class_name: 'ProjectSnippet'
has_many :hooks, dependent: :destroy, class_name: 'ProjectHook'
has_many :protected_branches, dependent: :destroy
has_many :project_members, dependent: :destroy, as: :source, class_name: 'ProjectMember'
has_many :users, through: :project_members
Loading
Loading
@@ -116,27 +119,27 @@ class Project < ActiveRecord::Base
validates_uniqueness_of :name, scope: :namespace_id
validates_uniqueness_of :path, scope: :namespace_id
validates :import_url,
format: { with: URI::regexp(%w(git http https)), message: "should be a valid url" },
format: { with: URI::regexp(%w(git http https)), message: 'should be a valid url' },
if: :import?
validates :star_count, numericality: { greater_than_or_equal_to: 0 }
validate :check_limit, on: :create
validate :avatar_type,
if: ->(project) { project.avatar && project.avatar_changed? }
validates :avatar, file_size: { maximum: 100.kilobytes.to_i }
validates :avatar, file_size: { maximum: 200.kilobytes.to_i }
 
mount_uploader :avatar, AttachmentUploader
 
# Scopes
scope :without_user, ->(user) { where("projects.id NOT IN (:ids)", ids: user.authorized_projects.map(&:id) ) }
scope :without_team, ->(team) { team.projects.present? ? where("projects.id NOT IN (:ids)", ids: team.projects.map(&:id)) : scoped }
scope :not_in_group, ->(group) { where("projects.id NOT IN (:ids)", ids: group.project_ids ) }
scope :in_team, ->(team) { where("projects.id IN (:ids)", ids: team.projects.map(&:id)) }
scope :without_user, ->(user) { where('projects.id NOT IN (:ids)', ids: user.authorized_projects.map(&:id) ) }
scope :without_team, ->(team) { team.projects.present? ? where('projects.id NOT IN (:ids)', ids: team.projects.map(&:id)) : scoped }
scope :not_in_group, ->(group) { where('projects.id NOT IN (:ids)', ids: group.project_ids ) }
scope :in_team, ->(team) { where('projects.id IN (:ids)', ids: team.projects.map(&:id)) }
scope :in_namespace, ->(namespace) { where(namespace_id: namespace.id) }
scope :in_group_namespace, -> { joins(:group) }
scope :sorted_by_activity, -> { reorder("projects.last_activity_at DESC") }
scope :sorted_by_stars, -> { reorder("projects.star_count DESC") }
scope :sorted_by_activity, -> { reorder('projects.last_activity_at DESC') }
scope :sorted_by_stars, -> { reorder('projects.star_count DESC') }
scope :personal, ->(user) { where(namespace_id: user.namespace_id) }
scope :joined, ->(user) { where("namespace_id != ?", user.namespace_id) }
scope :joined, ->(user) { where('namespace_id != ?', user.namespace_id) }
scope :public_only, -> { where(visibility_level: Project::PUBLIC) }
scope :public_and_internal_only, -> { where(visibility_level: Project.public_and_internal_levels) }
scope :non_archived, -> { where(archived: false) }
Loading
Loading
@@ -187,26 +190,26 @@ class Project < ActiveRecord::Base
end
 
def active
joins(:issues, :notes, :merge_requests).order("issues.created_at, notes.created_at, merge_requests.created_at DESC")
joins(:issues, :notes, :merge_requests).order('issues.created_at, notes.created_at, merge_requests.created_at DESC')
end
 
def search(query)
joins(:namespace).where("projects.archived = ?", false).
where("LOWER(projects.name) LIKE :query OR
joins(:namespace).where('projects.archived = ?', false).
where('LOWER(projects.name) LIKE :query OR
LOWER(projects.path) LIKE :query OR
LOWER(namespaces.name) LIKE :query OR
LOWER(projects.description) LIKE :query",
LOWER(projects.description) LIKE :query',
query: "%#{query.try(:downcase)}%")
end
 
def search_by_title(query)
where("projects.archived = ?", false).where("LOWER(projects.name) LIKE :query", query: "%#{query.downcase}%")
where('projects.archived = ?', false).where('LOWER(projects.name) LIKE :query', query: "%#{query.downcase}%")
end
 
def find_with_namespace(id)
return nil unless id.include?("/")
return nil unless id.include?('/')
 
id = id.split("/")
id = id.split('/')
namespace = Namespace.find_by(path: id.first)
return nil unless namespace
 
Loading
Loading
@@ -224,7 +227,7 @@ class Project < ActiveRecord::Base
when 'recently_updated' then reorder('projects.updated_at DESC')
when 'last_updated' then reorder('projects.updated_at ASC')
when 'largest_repository' then reorder('projects.repository_size DESC')
else reorder("namespaces.path, projects.name ASC")
else reorder('namespaces.path, projects.name ASC')
end
end
end
Loading
Loading
@@ -274,19 +277,19 @@ class Project < ActiveRecord::Base
end
 
def to_param
namespace.path + "/" + path
namespace.path + '/' + path
end
 
def web_url
[gitlab_config.url, path_with_namespace].join("/")
[gitlab_config.url, path_with_namespace].join('/')
end
 
def web_url_without_protocol
web_url.split("://")[1]
web_url.split('://')[1]
end
 
def build_commit_note(commit)
notes.new(commit_id: commit.id, noteable_type: "Commit")
notes.new(commit_id: commit.id, noteable_type: 'Commit')
end
 
def last_activity
Loading
Loading
@@ -345,8 +348,8 @@ class Project < ActiveRecord::Base
end
 
def avatar_type
unless avatar.image?
errors.add :avatar, 'only images allowed'
unless self.avatar.image?
self.errors.add :avatar, 'only images allowed'
end
end
 
Loading
Loading
@@ -384,7 +387,7 @@ class Project < ActiveRecord::Base
end
 
def team_member_by_name_or_email(name = nil, email = nil)
user = users.where("name like ? or email like ?", name, email).first
user = users.where('name like ? or email like ?', name, email).first
project_members.where(user: user) if user
end
 
Loading
Loading
@@ -396,7 +399,7 @@ class Project < ActiveRecord::Base
def name_with_namespace
@name_with_namespace ||= begin
if namespace
namespace.human_name + " / " + name
namespace.human_name + ' / ' + name
else
name
end
Loading
Loading
@@ -431,7 +434,7 @@ class Project < ActiveRecord::Base
def valid_repo?
repository.exists?
rescue
errors.add(:path, "Invalid repository path")
errors.add(:path, 'Invalid repository path')
false
end
 
Loading
Loading
@@ -490,7 +493,7 @@ class Project < ActiveRecord::Base
end
 
def http_url_to_repo
[gitlab_config.url, "/", path_with_namespace, ".git"].join('')
[gitlab_config.url, '/', path_with_namespace, '.git'].join('')
end
 
# Check if current branch name is marked as protected in the system
Loading
Loading
@@ -618,7 +621,7 @@ class Project < ActiveRecord::Base
if gitlab_shell.add_repository(path_with_namespace)
true
else
errors.add(:base, "Failed to create repository")
errors.add(:base, 'Failed to create repository')
false
end
end
Loading
Loading
@@ -631,7 +634,7 @@ class Project < ActiveRecord::Base
ProjectWiki.new(self, self.owner).wiki
true
rescue ProjectWiki::CouldNotCreateWikiError => ex
errors.add(:base, "Failed create wiki")
errors.add(:base, 'Failed create wiki')
false
end
end
Loading
Loading
@@ -14,7 +14,7 @@ module Projects
project.name = @from_project.name
project.path = @from_project.path
project.creator = @current_user
if @from_project.avatar && @from_project.avatar.image?
if @from_project.avatar.present? && @from_project.avatar.image?
project.avatar = @from_project.avatar
end
 
Loading
Loading
@@ -42,16 +42,16 @@ module Projects
end
#Now fork the repo
unless gitlab_shell.fork_repository(@from_project.path_with_namespace, project.namespace.path)
raise "forking failed in gitlab-shell"
raise 'forking failed in gitlab-shell'
end
project.ensure_satellite_exists
end
rescue => ex
project.errors.add(:base, "Fork transaction failed.")
project.errors.add(:base, 'Fork transaction failed.')
project.destroy
end
else
project.errors.add(:base, "Invalid fork destination")
project.errors.add(:base, 'Invalid fork destination')
end
 
project
Loading
Loading
Loading
Loading
@@ -12,6 +12,8 @@
- projects.each do |project|
%li.project-row
= link_to project_path(project), class: dom_class(project) do
.dash-project-avatar
= project_icon(project.to_param, alt: '', class: 'avatar s24')
.dash-project-access-icon
= visibility_level_icon(project.visibility_level)
%span.str-truncated
Loading
Loading
Loading
Loading
@@ -87,7 +87,10 @@
.form-group
.col-sm-2
.col-sm-10
= project_icon(@project.to_param, alt: '', class: 'avatar s160', only_uploaded: true)
- if @project.avatar?
= project_icon(@project.to_param, alt: '', class: 'avatar s160')
- else
= project_icon(@project.to_param, alt: '', class: 'avatar s160', only_uploaded: true)
%p.light
- if @project.avatar_in_git
Project avatar in repository: #{ @project.avatar_in_git }
Loading
Loading
@@ -102,7 +105,7 @@
&nbsp;
%span.file_name.js-avatar-filename File name...
= f.file_field :avatar, class: "js-project-avatar-input hidden"
.light The maximum file size allowed is 100KB.
.light The maximum file size allowed is 200KB.
- if @project.avatar?
%hr
= link_to 'Remove avatar', project_avatar_path(@project), data: { confirm: "Project avatar will be removed. Are you sure?"}, method: :delete, class: "btn btn-remove btn-small remove-avatar"
Loading
Loading
Loading
Loading
@@ -10,8 +10,8 @@ Gitlab::Application.routes.draw do
#
# Search
#
get 'search' => "search#show"
get 'search/autocomplete' => "search#autocomplete", as: :search_autocomplete
get 'search' => 'search#show'
get 'search/autocomplete' => 'search#autocomplete', as: :search_autocomplete
 
# API
API::API.logger Rails.logger
Loading
Loading
@@ -20,9 +20,9 @@ Gitlab::Application.routes.draw do
# Get all keys of user
get ':username.keys' => 'profiles/keys#get_keys' , constraints: { username: /.*/ }
 
constraint = lambda { |request| request.env["warden"].authenticate? and request.env['warden'].user.admin? }
constraint = lambda { |request| request.env['warden'].authenticate? and request.env['warden'].user.admin? }
constraints constraint do
mount Sidekiq::Web, at: "/admin/sidekiq", as: :sidekiq
mount Sidekiq::Web, at: '/admin/sidekiq', as: :sidekiq
end
 
# Enable Grack support
Loading
Loading
@@ -46,10 +46,10 @@ Gitlab::Application.routes.draw do
#
resources :snippets do
member do
get "raw"
get 'raw'
end
end
get "/s/:username" => "snippets#user_index", as: :user_snippets, constraints: { username: /.*/ }
get '/s/:username' => 'snippets#user_index', as: :user_snippets, constraints: { username: /.*/ }
 
#
# Github importer area
Loading
Loading
@@ -72,12 +72,12 @@ Gitlab::Application.routes.draw do
end
 
resources :groups, only: [:index]
root to: "projects#trending"
root to: 'projects#trending'
end
 
# Compatibility with old routing
get 'public' => "explore/projects#index"
get 'public/projects' => "explore/projects#index"
get 'public' => 'explore/projects#index'
get 'public/projects' => 'explore/projects#index'
 
#
# Attachments serving
Loading
Loading
@@ -122,7 +122,7 @@ Gitlab::Application.routes.draw do
 
resource :application_settings, only: [:show, :update]
 
root to: "dashboard#index"
root to: 'dashboard#index'
end
 
#
Loading
Loading
@@ -163,7 +163,7 @@ Gitlab::Application.routes.draw do
#
# Dashboard Area
#
resource :dashboard, controller: "dashboard", only: [:show] do
resource :dashboard, controller: 'dashboard', only: [:show] do
member do
get :projects
get :issues
Loading
Loading
@@ -194,12 +194,12 @@ Gitlab::Application.routes.draw do
devise_for :users, controllers: { omniauth_callbacks: :omniauth_callbacks, registrations: :registrations , passwords: :passwords, sessions: :sessions, confirmations: :confirmations }
 
devise_scope :user do
get "/users/auth/:provider/omniauth_error" => "omniauth_callbacks#omniauth_error", as: :omniauth_error
get '/users/auth/:provider/omniauth_error' => 'omniauth_callbacks#omniauth_error', as: :omniauth_error
end
#
# Project Area
#
resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: "/" do
resources :projects, constraints: { id: /[a-zA-Z.0-9_\-]+\/[a-zA-Z.0-9_\-]+/ }, except: [:new, :create, :index], path: '/' do
member do
put :transfer
post :archive
Loading
Loading
@@ -220,6 +220,7 @@ Gitlab::Application.routes.draw do
# Cannot be GET to differentiate from GET paths that end in preview.
post :preview, on: :member
end
resource :avatar, only: [:show, :destroy]
resources :new_tree, only: [:show, :update], constraints: {id: /.+/}, path: 'new'
resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/}
resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
Loading
Loading
@@ -237,7 +238,7 @@ Gitlab::Application.routes.draw do
 
resources :snippets, constraints: {id: /\d+/} do
member do
get "raw"
get 'raw'
end
end
 
Loading
Loading
@@ -249,7 +250,7 @@ Gitlab::Application.routes.draw do
end
 
member do
get "history"
get 'history'
end
end
 
Loading
Loading
@@ -258,7 +259,7 @@ Gitlab::Application.routes.draw do
 
resource :repository, only: [:show, :create] do
member do
get "archive", constraints: { format: Gitlab::Regex.archive_formats_regex }
get 'archive', constraints: { format: Gitlab::Regex.archive_formats_regex }
end
end
 
Loading
Loading
@@ -281,13 +282,13 @@ Gitlab::Application.routes.draw do
 
resources :refs, only: [] do
collection do
get "switch"
get 'switch'
end
 
member do
# tree viewer logs
get "logs_tree", constraints: { id: Gitlab::Regex.git_reference_regex }
get "logs_tree/:path" => "refs#logs_tree",
get 'logs_tree', constraints: { id: Gitlab::Regex.git_reference_regex }
get 'logs_tree/:path' => 'refs#logs_tree',
as: :logs_file,
constraints: {
id: Gitlab::Regex.git_reference_regex,
Loading
Loading
@@ -354,11 +355,10 @@ Gitlab::Application.routes.draw do
end
end
 
resource :avatar, only: [:show, :destroy]
end
end
 
get ':id' => "namespaces#show", constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
get ':id' => 'namespaces#show', constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/}
 
root to: "dashboard#show"
root to: 'dashboard#show'
end
Loading
Loading
@@ -68,7 +68,7 @@ class Spinach::Features::Project < Spinach::FeatureSteps
 
step 'I should see project "Shop" version' do
within '.project-side' do
page.should have_content "Version: 6.7.0.pre"
page.should have_content 'Version: 6.7.0.pre'
end
end
 
Loading
Loading
@@ -86,12 +86,12 @@ class Spinach::Features::Project < Spinach::FeatureSteps
end
 
step 'I should see project "Forum" README' do
page.should have_link "README.md"
page.should have_content "Sample repo for testing gitlab features"
page.should have_link 'README.md'
page.should have_content 'Sample repo for testing gitlab features'
end
 
step 'I should see project "Shop" README' do
page.should have_link "README.md"
page.should have_content "testme"
page.should have_link 'README.md'
page.should have_content 'testme'
end
end
Loading
Loading
@@ -6,15 +6,15 @@ describe ApplicationHelper do
controller.stub(:controller_name).and_return('foo')
end
 
it "returns true when controller matches argument" do
it 'returns true when controller matches argument' do
current_controller?(:foo).should be_true
end
 
it "returns false when controller does not match argument" do
it 'returns false when controller does not match argument' do
current_controller?(:bar).should_not be_true
end
 
it "should take any number of arguments" do
it 'should take any number of arguments' do
current_controller?(:baz, :bar).should_not be_true
current_controller?(:baz, :bar, :foo).should be_true
end
Loading
Loading
@@ -25,34 +25,34 @@ describe ApplicationHelper do
allow(self).to receive(:action_name).and_return('foo')
end
 
it "returns true when action matches argument" do
it 'returns true when action matches argument' do
current_action?(:foo).should be_true
end
 
it "returns false when action does not match argument" do
it 'returns false when action does not match argument' do
current_action?(:bar).should_not be_true
end
 
it "should take any number of arguments" do
it 'should take any number of arguments' do
current_action?(:baz, :bar).should_not be_true
current_action?(:baz, :bar, :foo).should be_true
end
end
 
describe "group_icon" do
describe 'group_icon' do
avatar_file_path = File.join(Rails.root, 'public', 'gitlab_logo.png')
 
it "should return an url for the avatar" do
it 'should return an url for the avatar' do
group = create(:group)
group.avatar = File.open(avatar_file_path)
group.save!
group_icon(group.path).to_s.should match("/uploads/group/avatar/#{ group.id }/gitlab_logo.png")
end
 
it "should give default avatar_icon when no avatar is present" do
it 'should give default avatar_icon when no avatar is present' do
group = create(:group)
group.save!
group_icon(group.path).should match("group_avatar.png")
group_icon(group.path).should match('group_avatar.png')
end
end
 
Loading
Loading
@@ -64,10 +64,10 @@ describe ApplicationHelper do
project.avatar = File.open(avatar_file_path)
project.save!
project_icon(project.to_param).to_s.should ==
"/uploads/project/avatar/#{ project.id }/gitlab_logo.png"
"<img alt=\"Gitlab logo\" src=\"/uploads/project/avatar/#{ project.id }/gitlab_logo.png\" />"
end
 
it "should give uploaded icon when present" do
it 'should give uploaded icon when present' do
project = create(:project)
project.save!
 
Loading
Loading
@@ -78,18 +78,18 @@ describe ApplicationHelper do
end
end
 
describe "avatar_icon" do
describe 'avatar_icon' do
avatar_file_path = File.join(Rails.root, 'public', 'gitlab_logo.png')
 
it "should return an url for the avatar" do
it 'should return an url for the avatar' do
user = create(:user)
user.avatar = File.open(avatar_file_path)
user.save!
avatar_icon(user.email).to_s.should match("/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end
 
it "should return an url for the avatar with relative url" do
Gitlab.config.gitlab.stub(relative_url_root: "/gitlab")
it 'should return an url for the avatar with relative url' do
Gitlab.config.gitlab.stub(relative_url_root: '/gitlab')
Gitlab.config.gitlab.stub(url: Settings.send(:build_gitlab_url))
 
user = create(:user)
Loading
Loading
@@ -98,58 +98,58 @@ describe ApplicationHelper do
avatar_icon(user.email).to_s.should match("/gitlab/uploads/user/avatar/#{ user.id }/gitlab_logo.png")
end
 
it "should call gravatar_icon when no avatar is present" do
it 'should call gravatar_icon when no avatar is present' do
user = create(:user, email: 'test@example.com')
user.save!
avatar_icon(user.email).to_s.should == "http://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=40&d=identicon"
avatar_icon(user.email).to_s.should == 'http://www.gravatar.com/avatar/55502f40dc8b7c769880b10874abc9d0?s=40&d=identicon'
end
end
 
describe "gravatar_icon" do
describe 'gravatar_icon' do
let(:user_email) { 'user@email.com' }
 
it "should return a generic avatar path when Gravatar is disabled" do
it 'should return a generic avatar path when Gravatar is disabled' do
ApplicationSetting.any_instance.stub(gravatar_enabled?: false)
gravatar_icon(user_email).should match('no_avatar.png')
end
 
it "should return a generic avatar path when email is blank" do
it 'should return a generic avatar path when email is blank' do
gravatar_icon('').should match('no_avatar.png')
end
 
it "should return default gravatar url" do
it 'should return default gravatar url' do
Gitlab.config.gitlab.stub(https: false)
gravatar_icon(user_email).should match('http://www.gravatar.com/avatar/b58c6f14d292556214bd64909bcdb118')
end
 
it "should use SSL when appropriate" do
it 'should use SSL when appropriate' do
Gitlab.config.gitlab.stub(https: true)
gravatar_icon(user_email).should match('https://secure.gravatar.com')
end
 
it "should return custom gravatar path when gravatar_url is set" do
it 'should return custom gravatar path when gravatar_url is set' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
Gitlab.config.gravatar.stub(:plain_url).and_return('http://example.local/?s=%{size}&hash=%{hash}')
gravatar_icon(user_email, 20).should == 'http://example.local/?s=20&hash=b58c6f14d292556214bd64909bcdb118'
end
 
it "should accept a custom size" do
it 'should accept a custom size' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
gravatar_icon(user_email, 64).should match(/\?s=64/)
end
 
it "should use default size when size is wrong" do
it 'should use default size when size is wrong' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
gravatar_icon(user_email, nil).should match(/\?s=40/)
end
 
it "should be case insensitive" do
it 'should be case insensitive' do
allow(self).to receive(:request).and_return(double(:ssl? => false))
gravatar_icon(user_email).should == gravatar_icon(user_email.upcase + " ")
gravatar_icon(user_email).should == gravatar_icon(user_email.upcase + ' ')
end
end
 
describe "grouped_options_refs" do
describe 'grouped_options_refs' do
# Override Rails' grouped_options_for_select helper since HTML is harder to work with
def grouped_options_for_select(options, *args)
options
Loading
Loading
@@ -162,17 +162,17 @@ describe ApplicationHelper do
@project = create(:project)
end
 
it "includes a list of branch names" do
it 'includes a list of branch names' do
options[0][0].should == 'Branches'
options[0][1].should include('master', 'feature')
end
 
it "includes a list of tag names" do
it 'includes a list of tag names' do
options[1][0].should == 'Tags'
options[1][1].should include('v1.0.0','v1.1.0')
end
 
it "includes a specific commit ref if defined" do
it 'includes a specific commit ref if defined' do
# Must be an instance variable
@ref = '2ed06dc41dbb5936af845b87d79e05bbf24c73b8'
 
Loading
Loading
@@ -180,26 +180,26 @@ describe ApplicationHelper do
options[2][1].should == [@ref]
end
 
it "sorts tags in a natural order" do
it 'sorts tags in a natural order' do
# Stub repository.tag_names to make sure we get some valid testing data
expect(@project.repository).to receive(:tag_names).and_return(["v1.0.9", "v1.0.10", "v2.0", "v3.1.4.2", "v1.0.9a"])
expect(@project.repository).to receive(:tag_names).and_return(['v1.0.9', 'v1.0.10', 'v2.0', 'v3.1.4.2', 'v1.0.9a'])
 
options[1][1].should == ["v3.1.4.2", "v2.0", "v1.0.10", "v1.0.9a", "v1.0.9"]
options[1][1].should == ['v3.1.4.2', 'v2.0', 'v1.0.10', 'v1.0.9a', 'v1.0.9']
end
end
 
describe "user_color_scheme_class" do
context "with current_user is nil" do
it "should return a string" do
describe 'user_color_scheme_class' do
context 'with current_user is nil' do
it 'should return a string' do
allow(self).to receive(:current_user).and_return(nil)
user_color_scheme_class.should be_kind_of(String)
end
end
 
context "with a current_user" do
context 'with a current_user' do
(1..5).each do |color_scheme_id|
context "with color_scheme_id == #{color_scheme_id}" do
it "should return a string" do
it 'should return a string' do
current_user = double(:color_scheme_id => color_scheme_id)
allow(self).to receive(:current_user).and_return(current_user)
user_color_scheme_class.should be_kind_of(String)
Loading
Loading
@@ -209,43 +209,43 @@ describe ApplicationHelper do
end
end
 
describe "simple_sanitize" do
describe 'simple_sanitize' do
let(:a_tag) { '<a href="#">Foo</a>' }
 
it "allows the a tag" do
it 'allows the a tag' do
simple_sanitize(a_tag).should == a_tag
end
 
it "allows the span tag" do
it 'allows the span tag' do
input = '<span class="foo">Bar</span>'
simple_sanitize(input).should == input
end
 
it "disallows other tags" do
it 'disallows other tags' do
input = "<strike><b>#{a_tag}</b></strike>"
simple_sanitize(input).should == a_tag
end
end
 
describe "link_to" do
describe 'link_to' do
 
it "should not include rel=nofollow for internal links" do
expect(link_to("Home", root_path)).to eq("<a href=\"/\">Home</a>")
it 'should not include rel=nofollow for internal links' do
expect(link_to('Home', root_path)).to eq("<a href=\"/\">Home</a>")
end
 
it "should include rel=nofollow for external links" do
expect(link_to("Example", "http://www.example.com")).to eq("<a href=\"http://www.example.com\" rel=\"nofollow\">Example</a>")
it 'should include rel=nofollow for external links' do
expect(link_to('Example', 'http://www.example.com')).to eq("<a href=\"http://www.example.com\" rel=\"nofollow\">Example</a>")
end
 
it "should include re=nofollow for external links and honor existing html_options" do
it 'should include re=nofollow for external links and honor existing html_options' do
expect(
link_to("Example", "http://www.example.com", class: "toggle", data: {toggle: "dropdown"})
link_to('Example', 'http://www.example.com', class: 'toggle', data: {toggle: 'dropdown'})
).to eq("<a class=\"toggle\" data-toggle=\"dropdown\" href=\"http://www.example.com\" rel=\"nofollow\">Example</a>")
end
 
it "should include rel=nofollow for external links and preserver other rel values" do
it 'should include rel=nofollow for external links and preserver other rel values' do
expect(
link_to("Example", "http://www.example.com", rel: "noreferrer")
link_to('Example', 'http://www.example.com', rel: 'noreferrer')
).to eq("<a href=\"http://www.example.com\" rel=\"noreferrer nofollow\">Example</a>")
end
end
Loading
Loading
Loading
Loading
@@ -14,7 +14,7 @@
# merge_requests_enabled :boolean default(TRUE), not null
# wiki_enabled :boolean default(TRUE), not null
# namespace_id :integer
# issues_tracker :string(255) default("gitlab"), not null
# issues_tracker :string(255) default('gitlab'), not null
# issues_tracker_id :string(255)
# snippets_enabled :boolean default(TRUE), not null
# last_activity_at :datetime
Loading
Loading
@@ -32,7 +32,7 @@
require 'spec_helper'
 
describe Project do
describe "Associations" do
describe 'Associations' do
it { should belong_to(:group) }
it { should belong_to(:namespace) }
it { should belong_to(:creator).class_name('User') }
Loading
Loading
@@ -53,10 +53,10 @@ describe Project do
it { should have_one(:pushover_service).dependent(:destroy) }
end
 
describe "Mass assignment" do
describe 'Mass assignment' do
end
 
describe "Validation" do
describe 'Validation' do
let!(:project) { create(:project) }
 
it { should validate_presence_of(:name) }
Loading
Loading
@@ -71,7 +71,7 @@ describe Project do
it { should ensure_length_of(:issues_tracker_id).is_within(0..255) }
it { should validate_presence_of(:namespace) }
 
it "should not allow new projects beyond user limits" do
it 'should not allow new projects beyond user limits' do
project2 = build(:project)
project2.stub(:creator).and_return(double(can_create_project?: false, projects_limit: 0).as_null_object)
project2.should_not be_valid
Loading
Loading
@@ -79,7 +79,7 @@ describe Project do
end
end
 
describe "Respond to" do
describe 'Respond to' do
it { should respond_to(:url_to_repo) }
it { should respond_to(:repo_exists?) }
it { should respond_to(:satellite) }
Loading
Loading
@@ -90,27 +90,27 @@ describe Project do
it { should respond_to(:path_with_namespace) }
end
 
it "should return valid url to repo" do
project = Project.new(path: "somewhere")
project.url_to_repo.should == Gitlab.config.gitlab_shell.ssh_path_prefix + "somewhere.git"
it 'should return valid url to repo' do
project = Project.new(path: 'somewhere')
project.url_to_repo.should == Gitlab.config.gitlab_shell.ssh_path_prefix + 'somewhere.git'
end
 
it "returns the full web URL for this repo" do
project = Project.new(path: "somewhere")
it 'returns the full web URL for this repo' do
project = Project.new(path: 'somewhere')
project.web_url.should == "#{Gitlab.config.gitlab.url}/somewhere"
end
 
it "returns the web URL without the protocol for this repo" do
project = Project.new(path: "somewhere")
project.web_url_without_protocol.should == "#{Gitlab.config.gitlab.url.split("://")[1]}/somewhere"
it 'returns the web URL without the protocol for this repo' do
project = Project.new(path: 'somewhere')
project.web_url_without_protocol.should == "#{Gitlab.config.gitlab.url.split('://')[1]}/somewhere"
end
 
describe "last_activity methods" do
describe 'last_activity methods' do
let(:project) { create(:project) }
let(:last_event) { double(created_at: Time.now) }
 
describe "last_activity" do
it "should alias last_activity to last_event" do
describe 'last_activity' do
it 'should alias last_activity to last_event' do
project.stub(last_event: last_event)
project.last_activity.should == last_event
end
Loading
Loading
@@ -135,13 +135,13 @@ describe Project do
let(:prev_commit_id) { merge_request.commits.last.id }
let(:commit_id) { merge_request.commits.first.id }
 
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
project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.target_branch}", key.user)
merge_request.reload
merge_request.merged?.should be_true
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
project.update_merge_requests(prev_commit_id, commit_id, "refs/heads/#{merge_request.source_branch}", key.user)
merge_request.reload
merge_request.last_commit.id.should == commit_id
Loading
Loading
@@ -167,14 +167,14 @@ describe Project do
@project = create(:project, name: 'gitlabhq', namespace: @group)
end
 
it { @project.to_param.should == "gitlab/gitlabhq" }
it { @project.to_param.should == 'gitlab/gitlabhq' }
end
end
 
describe :repository do
let(:project) { create(:project) }
 
it "should return valid repo" do
it 'should return valid repo' do
project.repository.should be_kind_of(Repository)
end
end
Loading
Loading
@@ -185,15 +185,15 @@ describe Project do
let(:not_existed_issue) { create(:issue) }
let(:ext_project) { create(:redmine_project) }
 
it "should be true or if used internal tracker and issue exists" do
it 'should be true or if used internal tracker and issue exists' do
project.issue_exists?(existed_issue.iid).should be_true
end
 
it "should be false or if used internal tracker and issue not exists" do
it 'should be false or if used internal tracker and issue not exists' do
project.issue_exists?(not_existed_issue.iid).should be_false
end
 
it "should always be true if used other tracker" do
it 'should always be true if used other tracker' do
ext_project.issue_exists?(rand(100)).should be_true
end
end
Loading
Loading
@@ -202,11 +202,11 @@ describe Project do
let(:project) { create(:project) }
let(:ext_project) { create(:redmine_project) }
 
it "should be true if used internal tracker" do
it 'should be true if used internal tracker' do
project.used_default_issues_tracker?.should be_true
end
 
it "should be false if used other tracker" do
it 'should be false if used other tracker' do
ext_project.used_default_issues_tracker?.should be_false
end
end
Loading
Loading
@@ -215,15 +215,15 @@ describe Project do
let(:project) { create(:project) }
let(:ext_project) { create(:redmine_project) }
 
it "should be true for projects with external issues tracker if issues enabled" do
it 'should be true for projects with external issues tracker if issues enabled' do
ext_project.can_have_issues_tracker_id?.should be_true
end
 
it "should be false for projects with internal issue tracker if issues enabled" do
it 'should be false for projects with internal issue tracker if issues enabled' do
project.can_have_issues_tracker_id?.should be_false
end
 
it "should be always false if issues disabled" do
it 'should be always false if issues disabled' do
project.issues_enabled = false
ext_project.issues_enabled = false
 
Loading
Loading
This diff is collapsed.
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment