From c68742ed560b0bbf84c9fe6f6707cf47e9ed792c Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Wed, 21 Jan 2015 15:14:46 +0100 Subject: Make omnibus the default in repo import docs --- doc/raketasks/import.md | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/doc/raketasks/import.md b/doc/raketasks/import.md index 32fe4dc8d0a..dbce6aae895 100644 --- a/doc/raketasks/import.md +++ b/doc/raketasks/import.md @@ -19,15 +19,20 @@ your repositories are located by looking at `config/gitlab.yml` under the `gitla New folder needs to have git user ownership and read/write/execute access for git user and its group: ``` -$ mkdir new_group -$ chown git:git new_group -$ chmod 770 new_group +# Replace /var/opt/gitlab/git-data with /home/git if you are using an +# installation from source. +sudo -u git mkdir /var/opt/gitlab/git-data/repositories/new_group ``` ### Copy your bare repositories inside this newly created folder: ``` -$ cp -r /old/git/foo.git/ /home/git/repositories/new_group/ +# Replace /var/opt/gitlab/git-data with /home/git if you are using an +# installation from source. +sudo cp -r /old/git/foo.git /var/opt/gitlab/git-data/repositories/new_group/ + +# Do this once when you are done copying git repositories +sudo chown -R git:git /var/opt/gitlab/git-data/repositories/new_group/ ``` `foo.git` needs to be owned by the git user and git users group. -- cgit v1.2.1 From 85b3c87b7f35843f26a9ead60f0bbfcb1d64dc2a Mon Sep 17 00:00:00 2001 From: Fred Chasen Date: Fri, 23 Jan 2015 14:57:48 -0500 Subject: Expose Link header in CORS Api calls --- config/application.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index a7d371c78ea..ac21d23294f 100644 --- a/config/application.rb +++ b/config/application.rb @@ -70,7 +70,7 @@ module Gitlab config.middleware.use Rack::Cors do allow do origins '*' - resource '/api/*', headers: :any, methods: [:get, :post, :options, :put, :delete] + resource '/api/*', headers: :any, methods: [:get, :post, :options, :put, :delete], expose: ["Link"] end end -- cgit v1.2.1 From 13c4e25d6fd7ce4ae34340667d6ee5640ff925a1 Mon Sep 17 00:00:00 2001 From: Fred Chasen Date: Fri, 23 Jan 2015 15:30:48 -0500 Subject: Split up line and use single qoutes to declare Cors settings --- config/application.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/application.rb b/config/application.rb index ac21d23294f..d5a69aa8a79 100644 --- a/config/application.rb +++ b/config/application.rb @@ -70,7 +70,10 @@ module Gitlab config.middleware.use Rack::Cors do allow do origins '*' - resource '/api/*', headers: :any, methods: [:get, :post, :options, :put, :delete], expose: ["Link"] + resource '/api/*', + :headers => :any, + :methods => [:get, :post, :options, :put, :delete], + :expose => ['Link'] end end -- cgit v1.2.1 From 1f5ecf6c502b1dffa26986b1e62cf46cbc58f981 Mon Sep 17 00:00:00 2001 From: Fred Chasen Date: Fri, 23 Jan 2015 15:33:20 -0500 Subject: use new hash syntax --- config/application.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/config/application.rb b/config/application.rb index d5a69aa8a79..24ba219cf3a 100644 --- a/config/application.rb +++ b/config/application.rb @@ -70,10 +70,10 @@ module Gitlab config.middleware.use Rack::Cors do allow do origins '*' - resource '/api/*', - :headers => :any, - :methods => [:get, :post, :options, :put, :delete], - :expose => ['Link'] + resource '/api/*', + headers: :any, + methods: [:get, :post, :options, :put, :delete], + expose: ['Link'] end end -- cgit v1.2.1 From addb2555841510bb48bc0fb9f1a90d80a7ed87fe Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Mon, 26 Jan 2015 17:03:04 +0100 Subject: Separate out the instructions for source installs --- doc/raketasks/import.md | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) diff --git a/doc/raketasks/import.md b/doc/raketasks/import.md index dbce6aae895..9a10c8d6850 100644 --- a/doc/raketasks/import.md +++ b/doc/raketasks/import.md @@ -19,16 +19,15 @@ your repositories are located by looking at `config/gitlab.yml` under the `gitla New folder needs to have git user ownership and read/write/execute access for git user and its group: ``` -# Replace /var/opt/gitlab/git-data with /home/git if you are using an -# installation from source. sudo -u git mkdir /var/opt/gitlab/git-data/repositories/new_group ``` +If you are using an installation from source, replace `/var/opt/gitlab/git-data` +with `/home/git`. + ### Copy your bare repositories inside this newly created folder: ``` -# Replace /var/opt/gitlab/git-data with /home/git if you are using an -# installation from source. sudo cp -r /old/git/foo.git /var/opt/gitlab/git-data/repositories/new_group/ # Do this once when you are done copying git repositories @@ -37,6 +36,9 @@ sudo chown -R git:git /var/opt/gitlab/git-data/repositories/new_group/ `foo.git` needs to be owned by the git user and git users group. +If you are using an installation from source, replace `/var/opt/gitlab/git-data` +with `/home/git`. + ### Run the command below depending on your type of installation: #### Omnibus Installation -- cgit v1.2.1 From 8633bbc9b852d8809f20db86a3cdfa2cd3b8dd95 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 28 Jan 2015 02:41:36 -0500 Subject: Add `icon` helper method --- app/helpers/icons_helper.rb | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index aaa8f8d0077..61c03d90072 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -1,21 +1,30 @@ module IconsHelper + # Creates an icon tag given icon name(s) and possible icon modifiers. + # + # Right now this method simply delegates directly to `fa_icon` from the + # font-awesome-rails gem, but should we ever use a different icon pack in the + # future we won't have to change hundreds of method calls. + def icon(names, options = {}) + fa_icon(names, options) + end + def boolean_to_icon(value) if value.to_s == "true" - content_tag :i, nil, class: 'fa fa-circle cgreen' + icon('circle', class: 'cgreen') else - content_tag :i, nil, class: 'fa fa-power-off clgray' + icon('power-off', class: 'clgray') end end def public_icon - content_tag :i, nil, class: 'fa fa-globe' + icon('globe') end def internal_icon - content_tag :i, nil, class: 'fa fa-shield' + icon('shield') end def private_icon - content_tag :i, nil, class: 'fa fa-lock' + icon('lock') end end -- cgit v1.2.1 From fe831dcd6f4af535abba1a9dc350c4d8a0f809e9 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 28 Jan 2015 03:30:27 -0500 Subject: Move `spinner` helper into IconsHelper Also updates it to use the new `icon` method. --- app/helpers/application_helper.rb | 9 --------- app/helpers/icons_helper.rb | 9 +++++++++ 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 104ae517a08..d00f1aac2d6 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -247,15 +247,6 @@ module ApplicationHelper Gitlab::MarkdownHelper.gitlab_markdown?(filename) end - def spinner(text = nil, visible = false) - 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 - end - end - def link_to(name = nil, options = nil, html_options = nil, &block) begin uri = URI(options) diff --git a/app/helpers/icons_helper.rb b/app/helpers/icons_helper.rb index 61c03d90072..18260f0ed4d 100644 --- a/app/helpers/icons_helper.rb +++ b/app/helpers/icons_helper.rb @@ -8,6 +8,15 @@ module IconsHelper fa_icon(names, options) end + def spinner(text = nil, visible = false) + css_class = 'loading' + css_class << ' hide' unless visible + + content_tag :div, class: css_class do + icon('spinner spin') + text + end + end + def boolean_to_icon(value) if value.to_s == "true" icon('circle', class: 'cgreen') -- cgit v1.2.1 From 4e7a4cd95696746bcab78a4f9ec071dd4089397a Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 28 Jan 2015 03:32:48 -0500 Subject: Use `icon` helper method in helper modules --- app/helpers/commits_helper.rb | 6 ++---- app/helpers/events_helper.rb | 11 +++++------ app/helpers/issues_helper.rb | 2 +- app/helpers/notes_helper.rb | 6 +++--- app/helpers/notifications_helper.rb | 8 ++++---- app/helpers/projects_helper.rb | 4 ++-- app/helpers/tree_helper.rb | 9 ++------- 7 files changed, 19 insertions(+), 27 deletions(-) diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 2a3e51ada50..1a322ac048f 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -65,8 +65,7 @@ module CommitsHelper branches.sort.map do |branch| link_to(project_tree_path(project, branch)) do content_tag :span, class: 'label label-gray' do - content_tag(:i, nil, class: 'fa fa-code-fork') + ' ' + - branch + icon('code-fork') + ' ' + branch end end end.join(" ").html_safe @@ -78,8 +77,7 @@ module CommitsHelper sorted.map do |tag| link_to(project_commits_path(project, project.repository.find_tag(tag).name)) do content_tag :span, class: 'label label-gray' do - content_tag(:i, nil, class: 'fa fa-tag') + ' ' + - tag + icon('tag') + ' ' + tag end end end.join(" ").html_safe diff --git a/app/helpers/events_helper.rb b/app/helpers/events_helper.rb index 903a5009616..d05f6df5f9f 100644 --- a/app/helpers/events_helper.rb +++ b/app/helpers/events_helper.rb @@ -27,18 +27,17 @@ module EventsHelper content_tag :li, class: "filter_icon #{active}" do link_to request.path, class: 'has_tooltip event_filter_link', id: "#{key}_event_filter", 'data-original-title' => tooltip do - content_tag(:i, nil, class: icon_for_event[key]) + - content_tag(:span, ' ' + tooltip) + icon(icon_for_event[key]) + content_tag(:span, ' ' + tooltip) end end end def icon_for_event { - EventFilter.push => 'fa fa-upload', - EventFilter.merged => 'fa fa-check-square-o', - EventFilter.comments => 'fa fa-comments', - EventFilter.team => 'fa fa-user', + EventFilter.push => 'upload', + EventFilter.merged => 'check-square-o', + EventFilter.comments => 'comments', + EventFilter.team => 'user', } end diff --git a/app/helpers/issues_helper.rb b/app/helpers/issues_helper.rb index 2bf430f9142..5fcc825acca 100644 --- a/app/helpers/issues_helper.rb +++ b/app/helpers/issues_helper.rb @@ -62,7 +62,7 @@ module IssuesHelper ts << capture_haml do haml_tag :span do haml_concat '·' - haml_concat ' ' + haml_concat icon('edit', title: 'edited') haml_concat time_ago_with_tooltip(issue.updated_at, 'bottom', 'issue_edited_ago') end end diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index 8f493f5d331..d41d5617396 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -22,7 +22,7 @@ module NotesHelper ts << capture_haml do haml_tag :span do haml_concat '·' - haml_concat ' ' + haml_concat icon('edit', title: 'edited') haml_concat time_ago_with_tooltip(note.updated_at, 'bottom', 'note_edited_ago') end end @@ -57,7 +57,7 @@ module NotesHelper button_tag(class: 'btn add-diff-note js-add-diff-note-button', data: data, title: 'Add a comment to this line') do - content_tag :i, nil, class: 'fa fa-comment-o' + icon('comment-o') end end @@ -74,7 +74,7 @@ module NotesHelper button_tag class: 'btn reply-btn js-discussion-reply-button', data: data, title: 'Add a reply' do - link_text = content_tag(:i, nil, class: 'fa fa-comment') + link_text = icon('comment') link_text << ' Reply' end end diff --git a/app/helpers/notifications_helper.rb b/app/helpers/notifications_helper.rb index bad380e98a8..f771fe761ef 100644 --- a/app/helpers/notifications_helper.rb +++ b/app/helpers/notifications_helper.rb @@ -1,13 +1,13 @@ module NotificationsHelper def notification_icon(notification) if notification.disabled? - content_tag :i, nil, class: 'fa fa-volume-off ns-mute' + icon('volume-off', class: 'ns-mute') elsif notification.participating? - content_tag :i, nil, class: 'fa fa-volume-down ns-part' + icon('volume-down', class: 'ns-part') elsif notification.watch? - content_tag :i, nil, class: 'fa fa-volume-up ns-watch' + icon('volume-up', class: 'ns-watch') else - content_tag :i, nil, class: 'fa fa-circle-o ns-default' + icon('circle-o', class: 'ns-default') end end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 351641e19af..0b01be79623 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -83,7 +83,7 @@ module ProjectsHelper ' Star' end - content_tag('i', ' ', class: 'fa fa-star') + toggle_text + icon('star') + toggle_text end count_html = content_tag('span', class: 'count') do @@ -107,7 +107,7 @@ module ProjectsHelper end def link_to_toggle_fork - out = content_tag(:i, '', class: 'fa fa-code-fork') + out = icon('code-fork') out << ' Fork' out << content_tag(:span, class: 'count') do @project.forks_count.to_s diff --git a/app/helpers/tree_helper.rb b/app/helpers/tree_helper.rb index 727ec3fb231..b6fb7a8aa5a 100644 --- a/app/helpers/tree_helper.rb +++ b/app/helpers/tree_helper.rb @@ -38,13 +38,8 @@ module TreeHelper # # type - String type of the tree item; either 'folder' or 'file' def tree_icon(type) - icon_class = if type == 'folder' - 'fa fa-folder' - else - 'fa fa-file-o' - end - - content_tag :i, nil, class: icon_class + icon_class = type == 'folder' ? 'folder' : 'file-o' + icon(icon_class) end def tree_hex_class(content) -- cgit v1.2.1 From 4eafc188437e0214c09d59083586ea871b625b14 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Wed, 28 Jan 2015 23:08:28 -0500 Subject: Refactor Repository to use new RepositoryCache class Abstracts away the lower-level implementation details from the Repository model. --- app/models/repository.rb | 61 +++++++++++++++------------------------ lib/repository_cache.rb | 25 ++++++++++++++++ spec/lib/repository_cache_spec.rb | 34 ++++++++++++++++++++++ 3 files changed, 83 insertions(+), 37 deletions(-) create mode 100644 lib/repository_cache.rb create mode 100644 spec/lib/repository_cache_spec.rb diff --git a/app/models/repository.rb b/app/models/repository.rb index f6400f7aff1..4e45a6723b8 100644 --- a/app/models/repository.rb +++ b/app/models/repository.rb @@ -30,7 +30,7 @@ class Repository commit = Gitlab::Git::Commit.find(raw_repository, id) commit = Commit.new(commit) if commit commit - rescue Rugged::OdbError => ex + rescue Rugged::OdbError nil end @@ -61,25 +61,25 @@ class Repository end def add_branch(branch_name, ref) - Rails.cache.delete(cache_key(:branch_names)) + cache.expire(:branch_names) gitlab_shell.add_branch(path_with_namespace, branch_name, ref) end def add_tag(tag_name, ref, message = nil) - Rails.cache.delete(cache_key(:tag_names)) + cache.expire(:tag_names) gitlab_shell.add_tag(path_with_namespace, tag_name, ref, message) end def rm_branch(branch_name) - Rails.cache.delete(cache_key(:branch_names)) + cache.expire(:branch_names) gitlab_shell.rm_branch(path_with_namespace, branch_name) end def rm_tag(tag_name) - Rails.cache.delete(cache_key(:tag_names)) + cache.expire(:tag_names) gitlab_shell.rm_tag(path_with_namespace, tag_name) end @@ -97,19 +97,15 @@ class Repository end def branch_names - Rails.cache.fetch(cache_key(:branch_names)) do - raw_repository.branch_names - end + cache.fetch(:branch_names) { raw_repository.branch_names } end def tag_names - Rails.cache.fetch(cache_key(:tag_names)) do - raw_repository.tag_names - end + cache.fetch(:tag_names) { raw_repository.tag_names } end def commit_count - Rails.cache.fetch(cache_key(:commit_count)) do + cache.fetch(:commit_count) do begin raw_repository.commit_count(self.root_ref) rescue @@ -121,26 +117,19 @@ class Repository # Return repo size in megabytes # Cached in redis def size - Rails.cache.fetch(cache_key(:size)) do - raw_repository.size - end + cache.fetch(:size) { raw_repository.size } end def expire_cache - Rails.cache.delete(cache_key(:size)) - Rails.cache.delete(cache_key(:branch_names)) - Rails.cache.delete(cache_key(:tag_names)) - Rails.cache.delete(cache_key(:commit_count)) - Rails.cache.delete(cache_key(:graph_log)) - Rails.cache.delete(cache_key(:readme)) - Rails.cache.delete(cache_key(:version)) - Rails.cache.delete(cache_key(:contribution_guide)) + %i(size branch_names tag_names commit_count graph_log + readme version contribution_guide).each do |key| + cache.expire(key) + end end def graph_log - Rails.cache.fetch(cache_key(:graph_log)) do - commits = raw_repository.log(limit: 6000, - skip_merges: true, + cache.fetch(:graph_log) do + commits = raw_repository.log(limit: 6000, skip_merges: true, ref: root_ref) commits.map do |rugged_commit| @@ -176,10 +165,6 @@ class Repository end end - def cache_key(type) - "#{type}:#{path_with_namespace}" - end - def method_missing(m, *args, &block) raw_repository.send(m, *args, &block) end @@ -199,13 +184,11 @@ class Repository end def readme - Rails.cache.fetch(cache_key(:readme)) do - tree(:head).readme - end + cache.fetch(:readme) { tree(:head).readme } end def version - Rails.cache.fetch(cache_key(:version)) do + cache.fetch(:version) do tree(:head).blobs.find do |file| file.name.downcase == 'version' end @@ -213,9 +196,7 @@ class Repository end def contribution_guide - Rails.cache.fetch(cache_key(:contribution_guide)) do - tree(:head).contribution_guide - end + cache.fetch(:contribution_guide) { tree(:head).contribution_guide } end def head_commit @@ -351,4 +332,10 @@ class Repository [] end end + + private + + def cache + @cache ||= RepositoryCache.new(path_with_namespace) + end end diff --git a/lib/repository_cache.rb b/lib/repository_cache.rb new file mode 100644 index 00000000000..0d52f50be91 --- /dev/null +++ b/lib/repository_cache.rb @@ -0,0 +1,25 @@ +# Interface to the Redis-backed cache store used by the Repository model +class RepositoryCache + attr_reader :namespace + + def initialize(namespace, backend = Rails.cache) + @namespace = namespace + @backend = backend + end + + def cache_key(type) + "#{type}:#{namespace}" + end + + def expire(key) + backend.delete(cache_key(key)) + end + + def fetch(key, &block) + backend.fetch(cache_key(key), &block) + end + + private + + attr_reader :backend +end diff --git a/spec/lib/repository_cache_spec.rb b/spec/lib/repository_cache_spec.rb new file mode 100644 index 00000000000..af399f3a731 --- /dev/null +++ b/spec/lib/repository_cache_spec.rb @@ -0,0 +1,34 @@ +require 'rspec' +require_relative '../../lib/repository_cache' + +describe RepositoryCache do + let(:backend) { double('backend').as_null_object } + let(:cache) { RepositoryCache.new('example', backend) } + + describe '#cache_key' do + it 'includes the namespace' do + expect(cache.cache_key(:foo)).to eq 'foo:example' + end + end + + describe '#expire' do + it 'expires the given key from the cache' do + cache.expire(:foo) + expect(backend).to have_received(:delete).with('foo:example') + end + end + + describe '#fetch' do + it 'fetches the given key from the cache' do + cache.fetch(:bar) + expect(backend).to have_received(:fetch).with('bar:example') + end + + it 'accepts a block' do + p = -> {} + + cache.fetch(:baz, &p) + expect(backend).to have_received(:fetch).with('baz:example', &p) + end + end +end -- cgit v1.2.1 From ff56b2d9edee0ed0c5bb6964446fab1d66222f38 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 29 Jan 2015 03:30:21 -0500 Subject: Use pry-rails gem instead of pry pry-rails has pry as a dependency and this lets us have all that pry when we run `rails console` :heart: --- Gemfile | 2 +- Gemfile.lock | 4 +++- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/Gemfile b/Gemfile index a0f5b70de32..e9301e59ca9 100644 --- a/Gemfile +++ b/Gemfile @@ -221,7 +221,7 @@ group :development, :test do gem 'spinach-rails' gem "rspec-rails" gem "capybara", '~> 2.2.1' - gem "pry" + gem "pry-rails" gem "awesome_print" gem "database_cleaner" gem "launchy" diff --git a/Gemfile.lock b/Gemfile.lock index 4b5b718c87e..3a8ae194bec 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -366,6 +366,8 @@ GEM coderay (~> 1.0) method_source (~> 0.8) slop (~> 3.4) + pry-rails (0.3.2) + pry (>= 0.9.10) pyu-ruby-sasl (0.0.3.3) quiet_assets (1.0.2) railties (>= 3.1, < 5.0) @@ -694,7 +696,7 @@ DEPENDENCIES org-ruby (= 0.9.12) pg poltergeist (~> 1.5.1) - pry + pry-rails quiet_assets (~> 1.0.1) rack-attack rack-cors -- cgit v1.2.1 From 9de4e696a68b7a0fb4d1e04becac24813fc4c922 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 29 Jan 2015 12:01:27 -0500 Subject: Remove errant print statements from votes spec This caused those random "true" outputs in the rspec output. --- spec/lib/votes_spec.rb | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/spec/lib/votes_spec.rb b/spec/lib/votes_spec.rb index 2c01a34756d..a88a10d927f 100644 --- a/spec/lib/votes_spec.rb +++ b/spec/lib/votes_spec.rb @@ -161,8 +161,8 @@ describe Issue, 'Votes' do add_note '+1 I still like this' add_note '+1 I really like this' add_note '+1 Give me this now!!!!' - p issue.downvotes.should == 0 - p issue.upvotes.should == 1 + issue.downvotes.should == 0 + issue.upvotes.should == 1 end it 'should count a users vote only once without caring about comments' do @@ -171,8 +171,8 @@ describe Issue, 'Votes' do add_note 'Another comment' add_note '+1 vote' add_note 'final comment' - p issue.downvotes.should == 0 - p issue.upvotes.should == 1 + issue.downvotes.should == 0 + issue.upvotes.should == 1 end end -- cgit v1.2.1 From ed17adfbcd7f279747ac8f23da079808299b06e6 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Thu, 29 Jan 2015 12:15:15 -0500 Subject: Update shoulda-matchers This outdated gem was the cause of those annoying MiniTest errors. Also updates one use of `ensure_inclusion_of` which was deprecated in favor of `validate_inclusion_of`. --- Gemfile | 2 +- Gemfile.lock | 8 ++++---- spec/models/members_spec.rb | 2 +- 3 files changed, 6 insertions(+), 6 deletions(-) diff --git a/Gemfile b/Gemfile index a0f5b70de32..5c18a20af15 100644 --- a/Gemfile +++ b/Gemfile @@ -254,7 +254,7 @@ end group :test do gem "simplecov", require: false - gem "shoulda-matchers", "~> 2.1.0" + gem "shoulda-matchers", "~> 2.7.0" gem 'email_spec' gem "webmock" gem 'test_after_commit' diff --git a/Gemfile.lock b/Gemfile.lock index 4b5b718c87e..cd02837008b 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -260,7 +260,7 @@ GEM multi_xml (>= 0.5.2) httpauth (0.2.1) httpclient (2.5.3.3) - i18n (0.6.11) + i18n (0.7.0) ice_nine (0.10.0) jasmine (2.0.2) jasmine-core (~> 2.0.0) @@ -279,7 +279,7 @@ GEM turbolinks jquery-ui-rails (4.2.1) railties (>= 3.2.16) - json (1.8.1) + json (1.8.2) jwt (0.1.13) multi_json (>= 1.5) kaminari (0.15.1) @@ -495,7 +495,7 @@ GEM sass (~> 3.2) settingslogic (2.0.9) sexp_processor (4.4.0) - shoulda-matchers (2.1.0) + shoulda-matchers (2.7.0) activesupport (>= 3.0.0) sidekiq (3.3.0) celluloid (>= 0.16.0) @@ -719,7 +719,7 @@ DEPENDENCIES select2-rails semantic-ui-sass (~> 1.8.0) settingslogic - shoulda-matchers (~> 2.1.0) + shoulda-matchers (~> 2.7.0) sidekiq (~> 3.3) simplecov sinatra diff --git a/spec/models/members_spec.rb b/spec/models/members_spec.rb index 6866c4794c2..cea653ec285 100644 --- a/spec/models/members_spec.rb +++ b/spec/models/members_spec.rb @@ -10,7 +10,7 @@ describe Member do it { should validate_presence_of(:user) } it { should validate_presence_of(:source) } - it { should ensure_inclusion_of(:access_level).in_array(Gitlab::Access.values) } + it { should validate_inclusion_of(:access_level).in_array(Gitlab::Access.values) } end describe "Delegate methods" do -- cgit v1.2.1 From 65a4e64b3ab54e53badce9bff5372188f51c3044 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 29 Jan 2015 15:38:22 -0800 Subject: Bump gitlab-shell version --- GITLAB_SHELL_VERSION | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/GITLAB_SHELL_VERSION b/GITLAB_SHELL_VERSION index 005119baaa0..8e8299dcc06 100644 --- a/GITLAB_SHELL_VERSION +++ b/GITLAB_SHELL_VERSION @@ -1 +1 @@ -2.4.1 +2.4.2 -- cgit v1.2.1 From 5ec36902dd41d1e6383373006ab16f2d1303ee0d Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 29 Jan 2015 16:00:46 -0800 Subject: Fix calendar js --- app/assets/javascripts/calendar.js.coffee | 2 -- 1 file changed, 2 deletions(-) diff --git a/app/assets/javascripts/calendar.js.coffee b/app/assets/javascripts/calendar.js.coffee index 6a0d5e43567..70940e13858 100644 --- a/app/assets/javascripts/calendar.js.coffee +++ b/app/assets/javascripts/calendar.js.coffee @@ -9,8 +9,6 @@ class @calendar cal.init itemName: ["commit"] data: timestamps - domain: "year" - subDomain: "month" start: new Date(starting_year, starting_month) domainLabelFormat: "%b" id: "cal-heatmap" -- cgit v1.2.1 From f1cf49218fb40b61f82ff74dbb7eaba32b439a5a Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 29 Jan 2015 17:07:44 -0800 Subject: Improve contribution calendar on user page * cache user contributions for day * ignore forks in calendar contribtuions --- app/controllers/users_controller.rb | 9 +++------ app/models/project_contributions.rb | 23 +++++++++++++++++++++++ lib/gitlab/commits_calendar.rb | 16 ++++++++++++---- 3 files changed, 38 insertions(+), 10 deletions(-) create mode 100644 app/models/project_contributions.rb diff --git a/app/controllers/users_controller.rb b/app/controllers/users_controller.rb index ff5e31067fb..57d8ef09faf 100644 --- a/app/controllers/users_controller.rb +++ b/app/controllers/users_controller.rb @@ -28,13 +28,10 @@ class UsersController < ApplicationController def calendar visible_projects = ProjectsFinder.new.execute(current_user) - - # Get user repositories and collect timestamps for commits - user_repositories = visible_projects.map(&:repository) - calendar = Gitlab::CommitsCalendar.new(user_repositories, @user) + calendar = Gitlab::CommitsCalendar.new(visible_projects, @user) @timestamps = calendar.timestamps - @starting_year = (Time.now - 1.year).strftime("%Y") - @starting_month = Date.today.strftime("%m").to_i + @starting_year = calendar.starting_year + @starting_month = calendar.starting_month render 'calendar', layout: false end diff --git a/app/models/project_contributions.rb b/app/models/project_contributions.rb new file mode 100644 index 00000000000..8ab2d814a94 --- /dev/null +++ b/app/models/project_contributions.rb @@ -0,0 +1,23 @@ +class ProjectContributions + attr_reader :project, :user + + def initialize(project, user) + @project, @user = project, user + end + + def commits_log + repository = project.repository + + if !repository.exists? || repository.empty? + return {} + end + + Rails.cache.fetch(cache_key) do + repository.commits_per_day_for_user(user) + end + end + + def cache_key + "#{Date.today.to_s}-commits-log-#{project.id}-#{user.email}" + end +end diff --git a/lib/gitlab/commits_calendar.rb b/lib/gitlab/commits_calendar.rb index ccc80d080af..2f30d238e6b 100644 --- a/lib/gitlab/commits_calendar.rb +++ b/lib/gitlab/commits_calendar.rb @@ -2,15 +2,15 @@ module Gitlab class CommitsCalendar attr_reader :timestamps - def initialize(repositories, user) + def initialize(projects, user) @timestamps = {} date_timestamps = [] - repositories.select(&:exists?).reject(&:empty?).each do |raw_repository| - commits_log = raw_repository.commits_per_day_for_user(user) - date_timestamps << commits_log + projects.reject(&:forked?).each do |project| + date_timestamps << ProjectContributions.new(project, user).commits_log end + # Sumarrize commits from all projects per days date_timestamps = date_timestamps.inject do |collection, date| collection.merge(date) { |k, old_v, new_v| old_v + new_v } end @@ -21,5 +21,13 @@ module Gitlab @timestamps[timestamp] = commits if timestamp end end + + def starting_year + (Time.now - 1.year).strftime("%Y") + end + + def starting_month + Date.today.strftime("%m").to_i + end end end -- cgit v1.2.1 From 31245a40c10a556998a9923be21b9ac947232824 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 29 Jan 2015 17:13:28 -0800 Subject: Remove : from headers --- app/views/users/calendar.html.haml | 2 +- app/views/users/show.html.haml | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/app/views/users/calendar.html.haml b/app/views/users/calendar.html.haml index 727faf23679..13bdc5ed1e7 100644 --- a/app/views/users/calendar.html.haml +++ b/app/views/users/calendar.html.haml @@ -1,4 +1,4 @@ -%h4 Calendar: +%h4 Calendar #cal-heatmap.calendar :javascript new calendar( diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index 445f43cd500..e47fed5513e 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -15,7 +15,7 @@ .clearfix - if @groups.any? - %h4 Groups: + %h4 Groups = render 'groups', groups: @groups %hr @@ -24,7 +24,7 @@ %i.fa.fa-spinner.fa-spin %hr %h4 - User Activity: + User Activity - if current_user %span.rss-icon.pull-right -- cgit v1.2.1 From 78d7c5087bafc316d298ac01745579990e3dd93c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 29 Jan 2015 17:30:51 -0800 Subject: Use tile avatars for user/group show pages --- app/assets/stylesheets/generic/avatar.scss | 4 ++++ app/views/groups/show.html.haml | 2 +- app/views/users/show.html.haml | 2 +- 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/assets/stylesheets/generic/avatar.scss b/app/assets/stylesheets/generic/avatar.scss index b6886206739..b88cdd83937 100644 --- a/app/assets/stylesheets/generic/avatar.scss +++ b/app/assets/stylesheets/generic/avatar.scss @@ -15,6 +15,10 @@ &.s24 { margin-right: 4px; } } + &.avatar-tile { + @include border-radius(0px); + } + &.s16 { width: 16px; height: 16px; margin-right: 6px; } &.s24 { width: 24px; height: 24px; margin-right: 8px; } &.s26 { width: 26px; height: 26px; margin-right: 8px; } diff --git a/app/views/groups/show.html.haml b/app/views/groups/show.html.haml index 81f0e1dd2d8..484bebca2d8 100644 --- a/app/views/groups/show.html.haml +++ b/app/views/groups/show.html.haml @@ -1,6 +1,6 @@ .dashboard %div - = image_tag group_icon(@group.path), class: "avatar s90" + = image_tag group_icon(@group.path), class: "avatar avatar-tile s90" .clearfix %h2 = @group.name diff --git a/app/views/users/show.html.haml b/app/views/users/show.html.haml index e47fed5513e..b05918b019e 100644 --- a/app/views/users/show.html.haml +++ b/app/views/users/show.html.haml @@ -1,7 +1,7 @@ .row .col-md-8 %h3.page-title - = image_tag avatar_icon(@user.email, 90), class: "avatar s90", alt: '' + = image_tag avatar_icon(@user.email, 90), class: "avatar avatar-tile s90", alt: '' = @user.name - if @user == current_user .pull-right -- cgit v1.2.1 From 7a5784ec41c6d51df75dc7cf284045edfc644c7c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 29 Jan 2015 22:03:34 -0800 Subject: Update changelog with version 7.7.2 --- CHANGELOG | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/CHANGELOG b/CHANGELOG index 4dc66e8e325..2db5beb0022 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -63,6 +63,10 @@ v 7.8.0 - - Added support for firing system hooks on group create/destroy and adding/removing users to group (Boyan Tabakov) +v 7.7.2 + - Update GitLab Shell to version 2.4.2 that fixes a bug when developers can push to protected branch + - Fix issue when LDAP user can't login with existing GitLab account + v 7.7.1 - Improve mention autocomplete performance - Show setup instructions for GitHub import if disabled -- cgit v1.2.1 From 23c31a0b12eaae7f7f25f30eca1066968bcb6059 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 29 Jan 2015 23:06:43 -0800 Subject: Skip tricky test for semaphore --- features/project/source/browse_files.feature | 2 +- lib/tasks/spinach.rake | 8 +++++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/features/project/source/browse_files.feature b/features/project/source/browse_files.feature index ccb29293a89..ec2aff4377d 100644 --- a/features/project/source/browse_files.feature +++ b/features/project/source/browse_files.feature @@ -24,7 +24,7 @@ Feature: Project Source Browse Files Given I click on "new file" link in repo Then I can see new file page - @javascript + @javascript @tricky Scenario: I can create and commit file Given I click on "new file" link in repo And I edit code diff --git a/lib/tasks/spinach.rake b/lib/tasks/spinach.rake index 507b315759d..ac885f315b9 100644 --- a/lib/tasks/spinach.rake +++ b/lib/tasks/spinach.rake @@ -2,9 +2,15 @@ Rake::Task["spinach"].clear if Rake::Task.task_defined?('spinach') desc "GITLAB | Run spinach" task :spinach do + tags = if ENV['SEMAPHORE'] + '~@tricky,~@wip' + else + '~@wip' + end + cmds = [ %W(rake gitlab:setup), - %W(spinach), + %W(spinach --tags #{tags}), ] run_commands(cmds) end -- cgit v1.2.1 From b21565f18d297c167f05f4c7861e01c916c15682 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 29 Jan 2015 23:28:38 -0800 Subject: Fix semaphore spinach tags --- lib/tasks/spinach.rake | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/tasks/spinach.rake b/lib/tasks/spinach.rake index ac885f315b9..4aefc18ce14 100644 --- a/lib/tasks/spinach.rake +++ b/lib/tasks/spinach.rake @@ -3,9 +3,9 @@ Rake::Task["spinach"].clear if Rake::Task.task_defined?('spinach') desc "GITLAB | Run spinach" task :spinach do tags = if ENV['SEMAPHORE'] - '~@tricky,~@wip' + '~@tricky' else - '~@wip' + '~@semaphore' end cmds = [ -- cgit v1.2.1 From d5d1802096ab8751dfa1e4cf535e9bee79457328 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Thu, 29 Jan 2015 23:48:00 -0800 Subject: Set right test as tricky --- features/project/source/browse_files.feature | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/features/project/source/browse_files.feature b/features/project/source/browse_files.feature index ec2aff4377d..ee8d0bffa9b 100644 --- a/features/project/source/browse_files.feature +++ b/features/project/source/browse_files.feature @@ -24,7 +24,7 @@ Feature: Project Source Browse Files Given I click on "new file" link in repo Then I can see new file page - @javascript @tricky + @javascript Scenario: I can create and commit file Given I click on "new file" link in repo And I edit code @@ -34,7 +34,7 @@ Feature: Project Source Browse Files Then I am redirected to the new file And I should see its new content - @javascript + @javascript @tricky Scenario: I can create file in empty repo Given I own an empty project And I visit my empty project page -- cgit v1.2.1 From c47328948b5fff218c68279260a57ab6b03e7423 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Fri, 30 Jan 2015 00:22:51 -0800 Subject: Fix specs for icons --- spec/helpers/notifications_helper_spec.rb | 3 +++ 1 file changed, 3 insertions(+) diff --git a/spec/helpers/notifications_helper_spec.rb b/spec/helpers/notifications_helper_spec.rb index 31ecdacf28e..dcc3318e4f9 100644 --- a/spec/helpers/notifications_helper_spec.rb +++ b/spec/helpers/notifications_helper_spec.rb @@ -1,6 +1,9 @@ require 'spec_helper' describe NotificationsHelper do + include FontAwesome::Rails::IconHelper + include IconsHelper + describe 'notification_icon' do let(:notification) { double(disabled?: false, participating?: false, watch?: false) } -- cgit v1.2.1 From 1a1d7085fa02e1ef681b10e15c2f144cc5224a9d Mon Sep 17 00:00:00 2001 From: Jacob Vosmaer Date: Fri, 30 Jan 2015 16:03:27 +0100 Subject: Mention libkrb5-dev dependency --- doc/update/6.x-or-7.x-to-7.7.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/doc/update/6.x-or-7.x-to-7.7.md b/doc/update/6.x-or-7.x-to-7.7.md index 6501a8d2148..0cbea5d5997 100644 --- a/doc/update/6.x-or-7.x-to-7.7.md +++ b/doc/update/6.x-or-7.x-to-7.7.md @@ -89,6 +89,9 @@ sudo apt-get install logrotate # Install pkg-config and cmake, which is needed for the latest versions of rugged sudo apt-get install pkg-config cmake + +# Install Kerberos header files, which are needed for GitLab EE Kerberos support +sudo apt-get install libkrb5-dev ``` ## 5. Configure Redis to use sockets -- cgit v1.2.1 From 8ac227bab2334c41784c567faf7aafb1ebd75890 Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Fri, 30 Jan 2015 10:17:55 -0500 Subject: Fix RepositoryCache backend attr_reader --- lib/repository_cache.rb | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/lib/repository_cache.rb b/lib/repository_cache.rb index 0d52f50be91..fa016a170cd 100644 --- a/lib/repository_cache.rb +++ b/lib/repository_cache.rb @@ -1,6 +1,6 @@ # Interface to the Redis-backed cache store used by the Repository model class RepositoryCache - attr_reader :namespace + attr_reader :namespace, :backend def initialize(namespace, backend = Rails.cache) @namespace = namespace @@ -18,8 +18,4 @@ class RepositoryCache def fetch(key, &block) backend.fetch(cache_key(key), &block) end - - private - - attr_reader :backend end -- cgit v1.2.1 From ab6f7164e03139889c09a6a207e9df3481e57b3b Mon Sep 17 00:00:00 2001 From: Robert Speicher Date: Fri, 30 Jan 2015 15:40:04 -0500 Subject: Make the structure of spec/models match app/models --- spec/models/assembla_service_spec.rb | 48 ---------- spec/models/buildbox_service_spec.rb | 73 --------------- spec/models/flowdock_service_spec.rb | 47 ---------- spec/models/gemnasium_service_spec.rb | 43 --------- spec/models/gitlab_ci_service_spec.rb | 44 --------- spec/models/group_member_spec.rb | 46 ---------- spec/models/hooks/project_hook_spec.rb | 36 ++++++++ spec/models/hooks/service_hook_spec.rb | 24 +++++ spec/models/hooks/system_hook_spec.rb | 100 +++++++++++++++++++++ spec/models/hooks/web_hook_spec.rb | 74 +++++++++++++++ spec/models/jira_service_spec.rb | 83 ----------------- spec/models/members/group_member_spec.rb | 46 ++++++++++ spec/models/members/project_member_spec.rb | 92 +++++++++++++++++++ spec/models/project_hook_spec.rb | 36 -------- spec/models/project_member_spec.rb | 92 ------------------- .../project_services/assembla_service_spec.rb | 48 ++++++++++ .../project_services/buildbox_service_spec.rb | 73 +++++++++++++++ .../project_services/flowdock_service_spec.rb | 47 ++++++++++ .../project_services/gemnasium_service_spec.rb | 43 +++++++++ .../project_services/gitlab_ci_service_spec.rb | 44 +++++++++ spec/models/project_services/jira_service_spec.rb | 83 +++++++++++++++++ .../project_services/pushover_service_spec.rb | 69 ++++++++++++++ spec/models/project_services/slack_message_spec.rb | 65 ++++++++++++++ spec/models/project_services/slack_service_spec.rb | 57 ++++++++++++ spec/models/pushover_service_spec.rb | 69 -------------- spec/models/service_hook_spec.rb | 24 ----- spec/models/slack_message_spec.rb | 65 -------------- spec/models/slack_service_spec.rb | 57 ------------ spec/models/system_hook_spec.rb | 100 --------------------- spec/models/web_hook_spec.rb | 74 --------------- 30 files changed, 901 insertions(+), 901 deletions(-) delete mode 100644 spec/models/assembla_service_spec.rb delete mode 100644 spec/models/buildbox_service_spec.rb delete mode 100644 spec/models/flowdock_service_spec.rb delete mode 100644 spec/models/gemnasium_service_spec.rb delete mode 100644 spec/models/gitlab_ci_service_spec.rb delete mode 100644 spec/models/group_member_spec.rb create mode 100644 spec/models/hooks/project_hook_spec.rb create mode 100644 spec/models/hooks/service_hook_spec.rb create mode 100644 spec/models/hooks/system_hook_spec.rb create mode 100644 spec/models/hooks/web_hook_spec.rb delete mode 100644 spec/models/jira_service_spec.rb create mode 100644 spec/models/members/group_member_spec.rb create mode 100644 spec/models/members/project_member_spec.rb delete mode 100644 spec/models/project_hook_spec.rb delete mode 100644 spec/models/project_member_spec.rb create mode 100644 spec/models/project_services/assembla_service_spec.rb create mode 100644 spec/models/project_services/buildbox_service_spec.rb create mode 100644 spec/models/project_services/flowdock_service_spec.rb create mode 100644 spec/models/project_services/gemnasium_service_spec.rb create mode 100644 spec/models/project_services/gitlab_ci_service_spec.rb create mode 100644 spec/models/project_services/jira_service_spec.rb create mode 100644 spec/models/project_services/pushover_service_spec.rb create mode 100644 spec/models/project_services/slack_message_spec.rb create mode 100644 spec/models/project_services/slack_service_spec.rb delete mode 100644 spec/models/pushover_service_spec.rb delete mode 100644 spec/models/service_hook_spec.rb delete mode 100644 spec/models/slack_message_spec.rb delete mode 100644 spec/models/slack_service_spec.rb delete mode 100644 spec/models/system_hook_spec.rb delete mode 100644 spec/models/web_hook_spec.rb diff --git a/spec/models/assembla_service_spec.rb b/spec/models/assembla_service_spec.rb deleted file mode 100644 index 005dd41fea9..00000000000 --- a/spec/models/assembla_service_spec.rb +++ /dev/null @@ -1,48 +0,0 @@ -# == Schema Information -# -# Table name: services -# -# id :integer not null, primary key -# type :string(255) -# title :string(255) -# project_id :integer not null -# created_at :datetime -# updated_at :datetime -# active :boolean default(FALSE), not null -# properties :text -# - -require 'spec_helper' - -describe AssemblaService, models: true do - describe "Associations" do - it { should belong_to :project } - it { should have_one :service_hook } - end - - describe "Execute" do - let(:user) { create(:user) } - let(:project) { create(:project) } - - before do - @assembla_service = AssemblaService.new - @assembla_service.stub( - project_id: project.id, - project: project, - service_hook: true, - token: 'verySecret', - subdomain: 'project_name' - ) - @sample_data = Gitlab::PushDataBuilder.build_sample(project, user) - @api_url = 'https://atlas.assembla.com/spaces/project_name/github_tool?secret_key=verySecret' - WebMock.stub_request(:post, @api_url) - end - - it "should call Assembla API" do - @assembla_service.execute(@sample_data) - WebMock.should have_requested(:post, @api_url).with( - body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/ - ).once - end - end -end diff --git a/spec/models/buildbox_service_spec.rb b/spec/models/buildbox_service_spec.rb deleted file mode 100644 index 1d9ca51be16..00000000000 --- a/spec/models/buildbox_service_spec.rb +++ /dev/null @@ -1,73 +0,0 @@ -# == Schema Information -# -# Table name: services -# -# id :integer not null, primary key -# type :string(255) -# title :string(255) -# project_id :integer not null -# created_at :datetime -# updated_at :datetime -# active :boolean default(FALSE), not null -# properties :text -# - -require 'spec_helper' - -describe BuildboxService do - describe 'Associations' do - it { should belong_to :project } - it { should have_one :service_hook } - end - - describe 'commits methods' do - before do - @project = Project.new - @project.stub( - default_branch: 'default-brancho' - ) - - @service = BuildboxService.new - @service.stub( - project: @project, - service_hook: true, - project_url: 'https://buildbox.io/account-name/example-project', - token: 'secret-sauce-webhook-token:secret-sauce-status-token' - ) - end - - describe :webhook_url do - it 'returns the webhook url' do - @service.webhook_url.should == - 'https://webhook.buildbox.io/deliver/secret-sauce-webhook-token' - end - end - - describe :commit_status_path do - it 'returns the correct status page' do - @service.commit_status_path('2ab7834c').should == - 'https://gitlab.buildbox.io/status/secret-sauce-status-token.json?commit=2ab7834c' - end - end - - describe :build_page do - it 'returns the correct build page' do - @service.build_page('2ab7834c').should == - 'https://buildbox.io/account-name/example-project/builds?commit=2ab7834c' - end - end - - describe :builds_page do - it 'returns the correct path to the builds page' do - @service.builds_path.should == - 'https://buildbox.io/account-name/example-project/builds?branch=default-brancho' - end - end - - describe :status_img_path do - it 'returns the correct path to the status image' do - @service.status_img_path.should == 'https://badge.buildbox.io/secret-sauce-status-token.svg' - end - end - end -end diff --git a/spec/models/flowdock_service_spec.rb b/spec/models/flowdock_service_spec.rb deleted file mode 100644 index ac156719b43..00000000000 --- a/spec/models/flowdock_service_spec.rb +++ /dev/null @@ -1,47 +0,0 @@ -# == Schema Information -# -# Table name: services -# -# id :integer not null, primary key -# type :string(255) -# title :string(255) -# project_id :integer not null -# created_at :datetime -# updated_at :datetime -# active :boolean default(FALSE), not null -# properties :text -# - -require 'spec_helper' - -describe FlowdockService do - describe "Associations" do - it { should belong_to :project } - it { should have_one :service_hook } - end - - describe "Execute" do - let(:user) { create(:user) } - let(:project) { create(:project) } - - before do - @flowdock_service = FlowdockService.new - @flowdock_service.stub( - project_id: project.id, - project: project, - service_hook: true, - token: 'verySecret' - ) - @sample_data = Gitlab::PushDataBuilder.build_sample(project, user) - @api_url = 'https://api.flowdock.com/v1/git/verySecret' - WebMock.stub_request(:post, @api_url) - end - - it "should call FlowDock API" do - @flowdock_service.execute(@sample_data) - WebMock.should have_requested(:post, @api_url).with( - body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/ - ).once - end - end -end diff --git a/spec/models/gemnasium_service_spec.rb b/spec/models/gemnasium_service_spec.rb deleted file mode 100644 index 2c560c11dac..00000000000 --- a/spec/models/gemnasium_service_spec.rb +++ /dev/null @@ -1,43 +0,0 @@ -# == Schema Information -# -# Table name: services -# -# id :integer not null, primary key -# type :string(255) -# title :string(255) -# project_id :integer not null -# created_at :datetime -# updated_at :datetime -# active :boolean default(FALSE), not null -# properties :text -# - -require 'spec_helper' - -describe GemnasiumService do - describe "Associations" do - it { should belong_to :project } - it { should have_one :service_hook } - end - - describe "Execute" do - let(:user) { create(:user) } - let(:project) { create(:project) } - - before do - @gemnasium_service = GemnasiumService.new - @gemnasium_service.stub( - project_id: project.id, - project: project, - service_hook: true, - token: 'verySecret', - api_key: 'GemnasiumUserApiKey' - ) - @sample_data = Gitlab::PushDataBuilder.build_sample(project, user) - end - it "should call Gemnasium service" do - Gemnasium::GitlabService.should_receive(:execute).with(an_instance_of(Hash)).once - @gemnasium_service.execute(@sample_data) - end - end -end diff --git a/spec/models/gitlab_ci_service_spec.rb b/spec/models/gitlab_ci_service_spec.rb deleted file mode 100644 index 83277058fbb..00000000000 --- a/spec/models/gitlab_ci_service_spec.rb +++ /dev/null @@ -1,44 +0,0 @@ -# == Schema Information -# -# Table name: services -# -# id :integer not null, primary key -# type :string(255) -# title :string(255) -# project_id :integer not null -# created_at :datetime -# updated_at :datetime -# active :boolean default(FALSE), not null -# properties :text -# - -require 'spec_helper' - -describe GitlabCiService do - describe "Associations" do - it { should belong_to :project } - it { should have_one :service_hook } - end - - describe "Mass assignment" do - end - - describe 'commits methods' do - before do - @service = GitlabCiService.new - @service.stub( - service_hook: true, - project_url: 'http://ci.gitlab.org/projects/2', - token: 'verySecret' - ) - end - - describe :commit_status_path do - it { @service.commit_status_path("2ab7834c").should == "http://ci.gitlab.org/projects/2/commits/2ab7834c/status.json?token=verySecret"} - end - - describe :build_page do - it { @service.build_page("2ab7834c").should == "http://ci.gitlab.org/projects/2/commits/2ab7834c"} - end - end -end diff --git a/spec/models/group_member_spec.rb b/spec/models/group_member_spec.rb deleted file mode 100644 index 38657de6793..00000000000 --- a/spec/models/group_member_spec.rb +++ /dev/null @@ -1,46 +0,0 @@ -# == Schema Information -# -# Table name: members -# -# id :integer not null, primary key -# access_level :integer not null -# source_id :integer not null -# source_type :string(255) not null -# user_id :integer not null -# notification_level :integer not null -# type :string(255) -# created_at :datetime -# updated_at :datetime -# - -require 'spec_helper' - -describe GroupMember do - context 'notification' do - describe "#after_create" do - it "should send email to user" do - membership = build(:group_member) - membership.stub(notification_service: double('NotificationService').as_null_object) - membership.should_receive(:notification_service) - membership.save - end - end - - describe "#after_update" do - before do - @membership = create :group_member - @membership.stub(notification_service: double('NotificationService').as_null_object) - end - - it "should send email to user" do - @membership.should_receive(:notification_service) - @membership.update_attribute(:access_level, GroupMember::MASTER) - end - - it "does not send an email when the access level has not changed" do - @membership.should_not_receive(:notification_service) - @membership.update_attribute(:access_level, GroupMember::OWNER) - end - end - end -end diff --git a/spec/models/hooks/project_hook_spec.rb b/spec/models/hooks/project_hook_spec.rb new file mode 100644 index 00000000000..4e0d50d7f3f --- /dev/null +++ b/spec/models/hooks/project_hook_spec.rb @@ -0,0 +1,36 @@ +# == Schema Information +# +# Table name: web_hooks +# +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) +# + +require 'spec_helper' + +describe ProjectHook do + describe '.push_hooks' do + it 'should return hooks for push events only' do + hook = create(:project_hook, push_events: true) + hook2 = create(:project_hook, push_events: false) + expect(ProjectHook.push_hooks).to eq([hook]) + end + end + + describe '.tag_push_hooks' do + it 'should return hooks for tag push events only' do + hook = create(:project_hook, tag_push_events: true) + hook2 = create(:project_hook, tag_push_events: false) + expect(ProjectHook.tag_push_hooks).to eq([hook]) + end + end +end diff --git a/spec/models/hooks/service_hook_spec.rb b/spec/models/hooks/service_hook_spec.rb new file mode 100644 index 00000000000..6ec82438dfe --- /dev/null +++ b/spec/models/hooks/service_hook_spec.rb @@ -0,0 +1,24 @@ +# == Schema Information +# +# Table name: web_hooks +# +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) +# + +require "spec_helper" + +describe ServiceHook do + describe "Associations" do + it { should belong_to :service } + end +end diff --git a/spec/models/hooks/system_hook_spec.rb b/spec/models/hooks/system_hook_spec.rb new file mode 100644 index 00000000000..8deb732de9c --- /dev/null +++ b/spec/models/hooks/system_hook_spec.rb @@ -0,0 +1,100 @@ +# == Schema Information +# +# Table name: web_hooks +# +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) +# + +require "spec_helper" + +describe SystemHook do + describe "execute" do + before(:each) do + @system_hook = create(:system_hook) + WebMock.stub_request(:post, @system_hook.url) + end + + it "project_create hook" do + Projects::CreateService.new(create(:user), name: 'empty').execute + WebMock.should have_requested(:post, @system_hook.url).with(body: /project_create/).once + end + + it "project_destroy hook" do + user = create(:user) + project = create(:empty_project, namespace: user.namespace) + Projects::DestroyService.new(project, user, {}).execute + WebMock.should have_requested(:post, @system_hook.url).with(body: /project_destroy/).once + end + + it "user_create hook" do + create(:user) + WebMock.should have_requested(:post, @system_hook.url).with(body: /user_create/).once + end + + it "user_destroy hook" do + user = create(:user) + user.destroy + WebMock.should have_requested(:post, @system_hook.url).with(body: /user_destroy/).once + end + + it "project_create hook" do + user = create(:user) + project = create(:project) + project.team << [user, :master] + WebMock.should have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once + end + + it "project_destroy hook" do + user = create(:user) + project = create(:project) + project.team << [user, :master] + project.project_members.destroy_all + WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once + end + + it 'group create hook' do + create(:group) + WebMock.should have_requested(:post, @system_hook.url).with( + body: /group_create/ + ).once + end + + it 'group destroy hook' do + group = create(:group) + group.destroy + WebMock.should have_requested(:post, @system_hook.url).with( + body: /group_destroy/ + ).once + end + + it 'group member create hook' do + group = create(:group) + user = create(:user) + group.add_user(user, Gitlab::Access::MASTER) + WebMock.should have_requested(:post, @system_hook.url).with( + body: /user_add_to_group/ + ).once + end + + it 'group member destroy hook' do + group = create(:group) + user = create(:user) + group.add_user(user, Gitlab::Access::MASTER) + group.group_members.destroy_all + WebMock.should have_requested(:post, @system_hook.url).with( + body: /user_remove_from_group/ + ).once + end + + end +end diff --git a/spec/models/hooks/web_hook_spec.rb b/spec/models/hooks/web_hook_spec.rb new file mode 100644 index 00000000000..e9c04ee89cb --- /dev/null +++ b/spec/models/hooks/web_hook_spec.rb @@ -0,0 +1,74 @@ +# == Schema Information +# +# Table name: web_hooks +# +# id :integer not null, primary key +# url :string(255) +# project_id :integer +# created_at :datetime +# updated_at :datetime +# type :string(255) default("ProjectHook") +# service_id :integer +# push_events :boolean default(TRUE), not null +# issues_events :boolean default(FALSE), not null +# merge_requests_events :boolean default(FALSE), not null +# tag_push_events :boolean default(FALSE) +# + +require 'spec_helper' + +describe ProjectHook do + describe "Associations" do + it { should belong_to :project } + end + + describe "Mass assignment" do + end + + describe "Validations" do + it { should validate_presence_of(:url) } + + context "url format" do + it { should allow_value("http://example.com").for(:url) } + it { should allow_value("https://excample.com").for(:url) } + it { should allow_value("http://test.com/api").for(:url) } + it { should allow_value("http://test.com/api?key=abc").for(:url) } + it { should allow_value("http://test.com/api?key=abc&type=def").for(:url) } + + it { should_not allow_value("example.com").for(:url) } + it { should_not allow_value("ftp://example.com").for(:url) } + it { should_not allow_value("herp-and-derp").for(:url) } + end + end + + describe "execute" do + before(:each) do + @project_hook = create(:project_hook) + @project = create(:project) + @project.hooks << [@project_hook] + @data = { before: 'oldrev', after: 'newrev', ref: 'ref'} + + WebMock.stub_request(:post, @project_hook.url) + end + + it "POSTs to the web hook URL" do + @project_hook.execute(@data) + WebMock.should have_requested(:post, @project_hook.url).once + end + + it "POSTs the data as JSON" do + json = @data.to_json + + @project_hook.execute(@data) + WebMock.should have_requested(:post, @project_hook.url).with(body: json).once + end + + it "catches exceptions" do + WebHook.should_receive(:post).and_raise("Some HTTP Post error") + + lambda { + @project_hook.execute(@data) + }.should raise_error + end + end +end diff --git a/spec/models/jira_service_spec.rb b/spec/models/jira_service_spec.rb deleted file mode 100644 index 0c73a68c924..00000000000 --- a/spec/models/jira_service_spec.rb +++ /dev/null @@ -1,83 +0,0 @@ -require 'spec_helper' - -describe JiraService do - describe "Associations" do - it { should belong_to :project } - it { should have_one :service_hook } - end - - describe "Validations" do - context "active" do - before do - subject.active = true - end - - it { should validate_presence_of :project_url } - it { should validate_presence_of :issues_url } - it { should validate_presence_of :new_issue_url } - end - end - - describe 'description and title' do - let(:project) { create(:project) } - - context 'when it is not set' do - before do - @service = project.create_jira_service(active: true) - end - - after do - @service.destroy! - end - - it 'should be initialized' do - expect(@service.title).to eq('JIRA') - expect(@service.description).to eq("Jira issue tracker") - end - end - - context 'when it is set' do - before do - properties = { 'title' => 'Jira One', 'description' => 'Jira One issue tracker' } - @service = project.create_jira_service(active: true, properties: properties) - end - - after do - @service.destroy! - end - - it "should be correct" do - expect(@service.title).to eq('Jira One') - expect(@service.description).to eq('Jira One issue tracker') - end - end - end - - describe 'project and issue urls' do - let(:project) { create(:project) } - - context 'when gitlab.yml was initialized' do - before do - settings = { "jira" => { - "title" => "Jira", - "project_url" => "http://jira.sample/projects/project_a", - "issues_url" => "http://jira.sample/issues/:id", - "new_issue_url" => "http://jira.sample/projects/project_a/issues/new" - } - } - Gitlab.config.stub(:issues_tracker).and_return(settings) - @service = project.create_jira_service(active: true) - end - - after do - @service.destroy! - end - - it 'should be prepopulated with the settings' do - expect(@service.properties[:project_url]).to eq('http://jira.sample/projects/project_a') - expect(@service.properties[:issues_url]).to eq("http://jira.sample/issues/:id") - expect(@service.properties[:new_issue_url]).to eq("http://jira.sample/projects/project_a/issues/new") - end - end - end -end diff --git a/spec/models/members/group_member_spec.rb b/spec/models/members/group_member_spec.rb new file mode 100644 index 00000000000..38657de6793 --- /dev/null +++ b/spec/models/members/group_member_spec.rb @@ -0,0 +1,46 @@ +# == Schema Information +# +# Table name: members +# +# id :integer not null, primary key +# access_level :integer not null +# source_id :integer not null +# source_type :string(255) not null +# user_id :integer not null +# notification_level :integer not null +# type :string(255) +# created_at :datetime +# updated_at :datetime +# + +require 'spec_helper' + +describe GroupMember do + context 'notification' do + describe "#after_create" do + it "should send email to user" do + membership = build(:group_member) + membership.stub(notification_service: double('NotificationService').as_null_object) + membership.should_receive(:notification_service) + membership.save + end + end + + describe "#after_update" do + before do + @membership = create :group_member + @membership.stub(notification_service: double('NotificationService').as_null_object) + end + + it "should send email to user" do + @membership.should_receive(:notification_service) + @membership.update_attribute(:access_level, GroupMember::MASTER) + end + + it "does not send an email when the access level has not changed" do + @membership.should_not_receive(:notification_service) + @membership.update_attribute(:access_level, GroupMember::OWNER) + end + end + end +end diff --git a/spec/models/members/project_member_spec.rb b/spec/models/members/project_member_spec.rb new file mode 100644 index 00000000000..9b5f89b6d7d --- /dev/null +++ b/spec/models/members/project_member_spec.rb @@ -0,0 +1,92 @@ +# == Schema Information +# +# Table name: members +# +# id :integer not null, primary key +# access_level :integer not null +# source_id :integer not null +# source_type :string(255) not null +# user_id :integer not null +# notification_level :integer not null +# type :string(255) +# created_at :datetime +# updated_at :datetime +# + +require 'spec_helper' + +describe ProjectMember do + describe :import_team do + before do + @abilities = Six.new + @abilities << Ability + + @project_1 = create :project + @project_2 = create :project + + @user_1 = create :user + @user_2 = create :user + + @project_1.team << [ @user_1, :developer ] + @project_2.team << [ @user_2, :reporter ] + + @status = @project_2.team.import(@project_1) + end + + it { @status.should be_true } + + describe 'project 2 should get user 1 as developer. user_2 should not be changed' do + it { @project_2.users.should include(@user_1) } + it { @project_2.users.should include(@user_2) } + + it { @abilities.allowed?(@user_1, :write_project, @project_2).should be_true } + it { @abilities.allowed?(@user_2, :read_project, @project_2).should be_true } + end + + describe 'project 1 should not be changed' do + it { @project_1.users.should include(@user_1) } + it { @project_1.users.should_not include(@user_2) } + end + end + + describe :add_users_into_projects do + before do + @project_1 = create :project + @project_2 = create :project + + @user_1 = create :user + @user_2 = create :user + + ProjectMember.add_users_into_projects( + [@project_1.id, @project_2.id], + [@user_1.id, @user_2.id], + ProjectMember::MASTER + ) + end + + it { @project_1.users.should include(@user_1) } + it { @project_1.users.should include(@user_2) } + + + it { @project_2.users.should include(@user_1) } + it { @project_2.users.should include(@user_2) } + end + + describe :truncate_teams do + before do + @project_1 = create :project + @project_2 = create :project + + @user_1 = create :user + @user_2 = create :user + + @project_1.team << [ @user_1, :developer] + @project_2.team << [ @user_2, :reporter] + + ProjectMember.truncate_teams([@project_1.id, @project_2.id]) + end + + it { @project_1.users.should be_empty } + it { @project_2.users.should be_empty } + end +end diff --git a/spec/models/project_hook_spec.rb b/spec/models/project_hook_spec.rb deleted file mode 100644 index 4e0d50d7f3f..00000000000 --- a/spec/models/project_hook_spec.rb +++ /dev/null @@ -1,36 +0,0 @@ -# == Schema Information -# -# Table name: web_hooks -# -# id :integer not null, primary key -# url :string(255) -# project_id :integer -# created_at :datetime -# updated_at :datetime -# type :string(255) default("ProjectHook") -# service_id :integer -# push_events :boolean default(TRUE), not null -# issues_events :boolean default(FALSE), not null -# merge_requests_events :boolean default(FALSE), not null -# tag_push_events :boolean default(FALSE) -# - -require 'spec_helper' - -describe ProjectHook do - describe '.push_hooks' do - it 'should return hooks for push events only' do - hook = create(:project_hook, push_events: true) - hook2 = create(:project_hook, push_events: false) - expect(ProjectHook.push_hooks).to eq([hook]) - end - end - - describe '.tag_push_hooks' do - it 'should return hooks for tag push events only' do - hook = create(:project_hook, tag_push_events: true) - hook2 = create(:project_hook, tag_push_events: false) - expect(ProjectHook.tag_push_hooks).to eq([hook]) - end - end -end diff --git a/spec/models/project_member_spec.rb b/spec/models/project_member_spec.rb deleted file mode 100644 index 9b5f89b6d7d..00000000000 --- a/spec/models/project_member_spec.rb +++ /dev/null @@ -1,92 +0,0 @@ -# == Schema Information -# -# Table name: members -# -# id :integer not null, primary key -# access_level :integer not null -# source_id :integer not null -# source_type :string(255) not null -# user_id :integer not null -# notification_level :integer not null -# type :string(255) -# created_at :datetime -# updated_at :datetime -# - -require 'spec_helper' - -describe ProjectMember do - describe :import_team do - before do - @abilities = Six.new - @abilities << Ability - - @project_1 = create :project - @project_2 = create :project - - @user_1 = create :user - @user_2 = create :user - - @project_1.team << [ @user_1, :developer ] - @project_2.team << [ @user_2, :reporter ] - - @status = @project_2.team.import(@project_1) - end - - it { @status.should be_true } - - describe 'project 2 should get user 1 as developer. user_2 should not be changed' do - it { @project_2.users.should include(@user_1) } - it { @project_2.users.should include(@user_2) } - - it { @abilities.allowed?(@user_1, :write_project, @project_2).should be_true } - it { @abilities.allowed?(@user_2, :read_project, @project_2).should be_true } - end - - describe 'project 1 should not be changed' do - it { @project_1.users.should include(@user_1) } - it { @project_1.users.should_not include(@user_2) } - end - end - - describe :add_users_into_projects do - before do - @project_1 = create :project - @project_2 = create :project - - @user_1 = create :user - @user_2 = create :user - - ProjectMember.add_users_into_projects( - [@project_1.id, @project_2.id], - [@user_1.id, @user_2.id], - ProjectMember::MASTER - ) - end - - it { @project_1.users.should include(@user_1) } - it { @project_1.users.should include(@user_2) } - - - it { @project_2.users.should include(@user_1) } - it { @project_2.users.should include(@user_2) } - end - - describe :truncate_teams do - before do - @project_1 = create :project - @project_2 = create :project - - @user_1 = create :user - @user_2 = create :user - - @project_1.team << [ @user_1, :developer] - @project_2.team << [ @user_2, :reporter] - - ProjectMember.truncate_teams([@project_1.id, @project_2.id]) - end - - it { @project_1.users.should be_empty } - it { @project_2.users.should be_empty } - end -end diff --git a/spec/models/project_services/assembla_service_spec.rb b/spec/models/project_services/assembla_service_spec.rb new file mode 100644 index 00000000000..005dd41fea9 --- /dev/null +++ b/spec/models/project_services/assembla_service_spec.rb @@ -0,0 +1,48 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + +require 'spec_helper' + +describe AssemblaService, models: true do + describe "Associations" do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe "Execute" do + let(:user) { create(:user) } + let(:project) { create(:project) } + + before do + @assembla_service = AssemblaService.new + @assembla_service.stub( + project_id: project.id, + project: project, + service_hook: true, + token: 'verySecret', + subdomain: 'project_name' + ) + @sample_data = Gitlab::PushDataBuilder.build_sample(project, user) + @api_url = 'https://atlas.assembla.com/spaces/project_name/github_tool?secret_key=verySecret' + WebMock.stub_request(:post, @api_url) + end + + it "should call Assembla API" do + @assembla_service.execute(@sample_data) + WebMock.should have_requested(:post, @api_url).with( + body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/ + ).once + end + end +end diff --git a/spec/models/project_services/buildbox_service_spec.rb b/spec/models/project_services/buildbox_service_spec.rb new file mode 100644 index 00000000000..1d9ca51be16 --- /dev/null +++ b/spec/models/project_services/buildbox_service_spec.rb @@ -0,0 +1,73 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + +require 'spec_helper' + +describe BuildboxService do + describe 'Associations' do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe 'commits methods' do + before do + @project = Project.new + @project.stub( + default_branch: 'default-brancho' + ) + + @service = BuildboxService.new + @service.stub( + project: @project, + service_hook: true, + project_url: 'https://buildbox.io/account-name/example-project', + token: 'secret-sauce-webhook-token:secret-sauce-status-token' + ) + end + + describe :webhook_url do + it 'returns the webhook url' do + @service.webhook_url.should == + 'https://webhook.buildbox.io/deliver/secret-sauce-webhook-token' + end + end + + describe :commit_status_path do + it 'returns the correct status page' do + @service.commit_status_path('2ab7834c').should == + 'https://gitlab.buildbox.io/status/secret-sauce-status-token.json?commit=2ab7834c' + end + end + + describe :build_page do + it 'returns the correct build page' do + @service.build_page('2ab7834c').should == + 'https://buildbox.io/account-name/example-project/builds?commit=2ab7834c' + end + end + + describe :builds_page do + it 'returns the correct path to the builds page' do + @service.builds_path.should == + 'https://buildbox.io/account-name/example-project/builds?branch=default-brancho' + end + end + + describe :status_img_path do + it 'returns the correct path to the status image' do + @service.status_img_path.should == 'https://badge.buildbox.io/secret-sauce-status-token.svg' + end + end + end +end diff --git a/spec/models/project_services/flowdock_service_spec.rb b/spec/models/project_services/flowdock_service_spec.rb new file mode 100644 index 00000000000..ac156719b43 --- /dev/null +++ b/spec/models/project_services/flowdock_service_spec.rb @@ -0,0 +1,47 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + +require 'spec_helper' + +describe FlowdockService do + describe "Associations" do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe "Execute" do + let(:user) { create(:user) } + let(:project) { create(:project) } + + before do + @flowdock_service = FlowdockService.new + @flowdock_service.stub( + project_id: project.id, + project: project, + service_hook: true, + token: 'verySecret' + ) + @sample_data = Gitlab::PushDataBuilder.build_sample(project, user) + @api_url = 'https://api.flowdock.com/v1/git/verySecret' + WebMock.stub_request(:post, @api_url) + end + + it "should call FlowDock API" do + @flowdock_service.execute(@sample_data) + WebMock.should have_requested(:post, @api_url).with( + body: /#{@sample_data[:before]}.*#{@sample_data[:after]}.*#{project.path}/ + ).once + end + end +end diff --git a/spec/models/project_services/gemnasium_service_spec.rb b/spec/models/project_services/gemnasium_service_spec.rb new file mode 100644 index 00000000000..2c560c11dac --- /dev/null +++ b/spec/models/project_services/gemnasium_service_spec.rb @@ -0,0 +1,43 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + +require 'spec_helper' + +describe GemnasiumService do + describe "Associations" do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe "Execute" do + let(:user) { create(:user) } + let(:project) { create(:project) } + + before do + @gemnasium_service = GemnasiumService.new + @gemnasium_service.stub( + project_id: project.id, + project: project, + service_hook: true, + token: 'verySecret', + api_key: 'GemnasiumUserApiKey' + ) + @sample_data = Gitlab::PushDataBuilder.build_sample(project, user) + end + it "should call Gemnasium service" do + Gemnasium::GitlabService.should_receive(:execute).with(an_instance_of(Hash)).once + @gemnasium_service.execute(@sample_data) + end + end +end diff --git a/spec/models/project_services/gitlab_ci_service_spec.rb b/spec/models/project_services/gitlab_ci_service_spec.rb new file mode 100644 index 00000000000..83277058fbb --- /dev/null +++ b/spec/models/project_services/gitlab_ci_service_spec.rb @@ -0,0 +1,44 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + +require 'spec_helper' + +describe GitlabCiService do + describe "Associations" do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe "Mass assignment" do + end + + describe 'commits methods' do + before do + @service = GitlabCiService.new + @service.stub( + service_hook: true, + project_url: 'http://ci.gitlab.org/projects/2', + token: 'verySecret' + ) + end + + describe :commit_status_path do + it { @service.commit_status_path("2ab7834c").should == "http://ci.gitlab.org/projects/2/commits/2ab7834c/status.json?token=verySecret"} + end + + describe :build_page do + it { @service.build_page("2ab7834c").should == "http://ci.gitlab.org/projects/2/commits/2ab7834c"} + end + end +end diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb new file mode 100644 index 00000000000..0c73a68c924 --- /dev/null +++ b/spec/models/project_services/jira_service_spec.rb @@ -0,0 +1,83 @@ +require 'spec_helper' + +describe JiraService do + describe "Associations" do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe "Validations" do + context "active" do + before do + subject.active = true + end + + it { should validate_presence_of :project_url } + it { should validate_presence_of :issues_url } + it { should validate_presence_of :new_issue_url } + end + end + + describe 'description and title' do + let(:project) { create(:project) } + + context 'when it is not set' do + before do + @service = project.create_jira_service(active: true) + end + + after do + @service.destroy! + end + + it 'should be initialized' do + expect(@service.title).to eq('JIRA') + expect(@service.description).to eq("Jira issue tracker") + end + end + + context 'when it is set' do + before do + properties = { 'title' => 'Jira One', 'description' => 'Jira One issue tracker' } + @service = project.create_jira_service(active: true, properties: properties) + end + + after do + @service.destroy! + end + + it "should be correct" do + expect(@service.title).to eq('Jira One') + expect(@service.description).to eq('Jira One issue tracker') + end + end + end + + describe 'project and issue urls' do + let(:project) { create(:project) } + + context 'when gitlab.yml was initialized' do + before do + settings = { "jira" => { + "title" => "Jira", + "project_url" => "http://jira.sample/projects/project_a", + "issues_url" => "http://jira.sample/issues/:id", + "new_issue_url" => "http://jira.sample/projects/project_a/issues/new" + } + } + Gitlab.config.stub(:issues_tracker).and_return(settings) + @service = project.create_jira_service(active: true) + end + + after do + @service.destroy! + end + + it 'should be prepopulated with the settings' do + expect(@service.properties[:project_url]).to eq('http://jira.sample/projects/project_a') + expect(@service.properties[:issues_url]).to eq("http://jira.sample/issues/:id") + expect(@service.properties[:new_issue_url]).to eq("http://jira.sample/projects/project_a/issues/new") + end + end + end +end diff --git a/spec/models/project_services/pushover_service_spec.rb b/spec/models/project_services/pushover_service_spec.rb new file mode 100644 index 00000000000..f2813d66c7d --- /dev/null +++ b/spec/models/project_services/pushover_service_spec.rb @@ -0,0 +1,69 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + +require 'spec_helper' + +describe PushoverService do + describe 'Associations' do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe 'Validations' do + context 'active' do + before do + subject.active = true + end + + it { should validate_presence_of :api_key } + it { should validate_presence_of :user_key } + it { should validate_presence_of :priority } + end + end + + describe 'Execute' do + let(:pushover) { PushoverService.new } + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) } + + let(:api_key) { 'verySecret' } + let(:user_key) { 'verySecret' } + let(:device) { 'myDevice' } + let(:priority) { 0 } + let(:sound) { 'bike' } + let(:api_url) { 'https://api.pushover.net/1/messages.json' } + + before do + pushover.stub( + project: project, + project_id: project.id, + service_hook: true, + api_key: api_key, + user_key: user_key, + device: device, + priority: priority, + sound: sound + ) + + WebMock.stub_request(:post, api_url) + end + + it 'should call Pushover API' do + pushover.execute(sample_data) + + WebMock.should have_requested(:post, api_url).once + end + end +end diff --git a/spec/models/project_services/slack_message_spec.rb b/spec/models/project_services/slack_message_spec.rb new file mode 100644 index 00000000000..c530fad619b --- /dev/null +++ b/spec/models/project_services/slack_message_spec.rb @@ -0,0 +1,65 @@ +require 'spec_helper' + +describe SlackMessage do + subject { SlackMessage.new(args) } + + let(:args) { + { + after: 'after', + before: 'before', + project_name: 'project_name', + ref: 'refs/heads/master', + user_name: 'user_name', + project_url: 'url' + } + } + + let(:color) { '#345' } + + context 'push' do + before do + args[:commits] = [ + { message: 'message1', url: 'url1', id: 'abcdefghijkl', author: { name: 'author1' } }, + { message: 'message2', url: 'url2', id: '123456789012', author: { name: 'author2' } }, + ] + end + + it 'returns a message regarding pushes' do + subject.pretext.should == + 'user_name pushed to branch of '\ + ' ()' + subject.attachments.should == [ + { + text: ": message1 - author1\n"\ + ": message2 - author2", + color: color, + } + ] + end + end + + context 'new branch' do + before do + args[:before] = '000000' + end + + it 'returns a message regarding a new branch' do + subject.pretext.should == + 'user_name pushed new branch to '\ + '' + subject.attachments.should be_empty + end + end + + context 'removed branch' do + before do + args[:after] = '000000' + end + + it 'returns a message regarding a removed branch' do + subject.pretext.should == + 'user_name removed branch master from ' + subject.attachments.should be_empty + end + end +end diff --git a/spec/models/project_services/slack_service_spec.rb b/spec/models/project_services/slack_service_spec.rb new file mode 100644 index 00000000000..34594072409 --- /dev/null +++ b/spec/models/project_services/slack_service_spec.rb @@ -0,0 +1,57 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + +require 'spec_helper' + +describe SlackService do + describe "Associations" do + it { should belong_to :project } + it { should have_one :service_hook } + end + + describe "Validations" do + context "active" do + before do + subject.active = true + end + + it { should validate_presence_of :webhook } + end + end + + describe "Execute" do + let(:slack) { SlackService.new } + let(:user) { create(:user) } + let(:project) { create(:project) } + let(:sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) } + let(:webhook_url) { 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' } + + before do + slack.stub( + project: project, + project_id: project.id, + service_hook: true, + webhook: webhook_url + ) + + WebMock.stub_request(:post, webhook_url) + end + + it "should call Slack API" do + slack.execute(sample_data) + + WebMock.should have_requested(:post, webhook_url).once + end + end +end diff --git a/spec/models/pushover_service_spec.rb b/spec/models/pushover_service_spec.rb deleted file mode 100644 index f2813d66c7d..00000000000 --- a/spec/models/pushover_service_spec.rb +++ /dev/null @@ -1,69 +0,0 @@ -# == Schema Information -# -# Table name: services -# -# id :integer not null, primary key -# type :string(255) -# title :string(255) -# project_id :integer not null -# created_at :datetime -# updated_at :datetime -# active :boolean default(FALSE), not null -# properties :text -# - -require 'spec_helper' - -describe PushoverService do - describe 'Associations' do - it { should belong_to :project } - it { should have_one :service_hook } - end - - describe 'Validations' do - context 'active' do - before do - subject.active = true - end - - it { should validate_presence_of :api_key } - it { should validate_presence_of :user_key } - it { should validate_presence_of :priority } - end - end - - describe 'Execute' do - let(:pushover) { PushoverService.new } - let(:user) { create(:user) } - let(:project) { create(:project) } - let(:sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) } - - let(:api_key) { 'verySecret' } - let(:user_key) { 'verySecret' } - let(:device) { 'myDevice' } - let(:priority) { 0 } - let(:sound) { 'bike' } - let(:api_url) { 'https://api.pushover.net/1/messages.json' } - - before do - pushover.stub( - project: project, - project_id: project.id, - service_hook: true, - api_key: api_key, - user_key: user_key, - device: device, - priority: priority, - sound: sound - ) - - WebMock.stub_request(:post, api_url) - end - - it 'should call Pushover API' do - pushover.execute(sample_data) - - WebMock.should have_requested(:post, api_url).once - end - end -end diff --git a/spec/models/service_hook_spec.rb b/spec/models/service_hook_spec.rb deleted file mode 100644 index 6ec82438dfe..00000000000 --- a/spec/models/service_hook_spec.rb +++ /dev/null @@ -1,24 +0,0 @@ -# == Schema Information -# -# Table name: web_hooks -# -# id :integer not null, primary key -# url :string(255) -# project_id :integer -# created_at :datetime -# updated_at :datetime -# type :string(255) default("ProjectHook") -# service_id :integer -# push_events :boolean default(TRUE), not null -# issues_events :boolean default(FALSE), not null -# merge_requests_events :boolean default(FALSE), not null -# tag_push_events :boolean default(FALSE) -# - -require "spec_helper" - -describe ServiceHook do - describe "Associations" do - it { should belong_to :service } - end -end diff --git a/spec/models/slack_message_spec.rb b/spec/models/slack_message_spec.rb deleted file mode 100644 index c530fad619b..00000000000 --- a/spec/models/slack_message_spec.rb +++ /dev/null @@ -1,65 +0,0 @@ -require 'spec_helper' - -describe SlackMessage do - subject { SlackMessage.new(args) } - - let(:args) { - { - after: 'after', - before: 'before', - project_name: 'project_name', - ref: 'refs/heads/master', - user_name: 'user_name', - project_url: 'url' - } - } - - let(:color) { '#345' } - - context 'push' do - before do - args[:commits] = [ - { message: 'message1', url: 'url1', id: 'abcdefghijkl', author: { name: 'author1' } }, - { message: 'message2', url: 'url2', id: '123456789012', author: { name: 'author2' } }, - ] - end - - it 'returns a message regarding pushes' do - subject.pretext.should == - 'user_name pushed to branch of '\ - ' ()' - subject.attachments.should == [ - { - text: ": message1 - author1\n"\ - ": message2 - author2", - color: color, - } - ] - end - end - - context 'new branch' do - before do - args[:before] = '000000' - end - - it 'returns a message regarding a new branch' do - subject.pretext.should == - 'user_name pushed new branch to '\ - '' - subject.attachments.should be_empty - end - end - - context 'removed branch' do - before do - args[:after] = '000000' - end - - it 'returns a message regarding a removed branch' do - subject.pretext.should == - 'user_name removed branch master from ' - subject.attachments.should be_empty - end - end -end diff --git a/spec/models/slack_service_spec.rb b/spec/models/slack_service_spec.rb deleted file mode 100644 index 34594072409..00000000000 --- a/spec/models/slack_service_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -# == Schema Information -# -# Table name: services -# -# id :integer not null, primary key -# type :string(255) -# title :string(255) -# project_id :integer not null -# created_at :datetime -# updated_at :datetime -# active :boolean default(FALSE), not null -# properties :text -# - -require 'spec_helper' - -describe SlackService do - describe "Associations" do - it { should belong_to :project } - it { should have_one :service_hook } - end - - describe "Validations" do - context "active" do - before do - subject.active = true - end - - it { should validate_presence_of :webhook } - end - end - - describe "Execute" do - let(:slack) { SlackService.new } - let(:user) { create(:user) } - let(:project) { create(:project) } - let(:sample_data) { Gitlab::PushDataBuilder.build_sample(project, user) } - let(:webhook_url) { 'https://hooks.slack.com/services/SVRWFV0VVAR97N/B02R25XN3/ZBqu7xMupaEEICInN685' } - - before do - slack.stub( - project: project, - project_id: project.id, - service_hook: true, - webhook: webhook_url - ) - - WebMock.stub_request(:post, webhook_url) - end - - it "should call Slack API" do - slack.execute(sample_data) - - WebMock.should have_requested(:post, webhook_url).once - end - end -end diff --git a/spec/models/system_hook_spec.rb b/spec/models/system_hook_spec.rb deleted file mode 100644 index 8deb732de9c..00000000000 --- a/spec/models/system_hook_spec.rb +++ /dev/null @@ -1,100 +0,0 @@ -# == Schema Information -# -# Table name: web_hooks -# -# id :integer not null, primary key -# url :string(255) -# project_id :integer -# created_at :datetime -# updated_at :datetime -# type :string(255) default("ProjectHook") -# service_id :integer -# push_events :boolean default(TRUE), not null -# issues_events :boolean default(FALSE), not null -# merge_requests_events :boolean default(FALSE), not null -# tag_push_events :boolean default(FALSE) -# - -require "spec_helper" - -describe SystemHook do - describe "execute" do - before(:each) do - @system_hook = create(:system_hook) - WebMock.stub_request(:post, @system_hook.url) - end - - it "project_create hook" do - Projects::CreateService.new(create(:user), name: 'empty').execute - WebMock.should have_requested(:post, @system_hook.url).with(body: /project_create/).once - end - - it "project_destroy hook" do - user = create(:user) - project = create(:empty_project, namespace: user.namespace) - Projects::DestroyService.new(project, user, {}).execute - WebMock.should have_requested(:post, @system_hook.url).with(body: /project_destroy/).once - end - - it "user_create hook" do - create(:user) - WebMock.should have_requested(:post, @system_hook.url).with(body: /user_create/).once - end - - it "user_destroy hook" do - user = create(:user) - user.destroy - WebMock.should have_requested(:post, @system_hook.url).with(body: /user_destroy/).once - end - - it "project_create hook" do - user = create(:user) - project = create(:project) - project.team << [user, :master] - WebMock.should have_requested(:post, @system_hook.url).with(body: /user_add_to_team/).once - end - - it "project_destroy hook" do - user = create(:user) - project = create(:project) - project.team << [user, :master] - project.project_members.destroy_all - WebMock.should have_requested(:post, @system_hook.url).with(body: /user_remove_from_team/).once - end - - it 'group create hook' do - create(:group) - WebMock.should have_requested(:post, @system_hook.url).with( - body: /group_create/ - ).once - end - - it 'group destroy hook' do - group = create(:group) - group.destroy - WebMock.should have_requested(:post, @system_hook.url).with( - body: /group_destroy/ - ).once - end - - it 'group member create hook' do - group = create(:group) - user = create(:user) - group.add_user(user, Gitlab::Access::MASTER) - WebMock.should have_requested(:post, @system_hook.url).with( - body: /user_add_to_group/ - ).once - end - - it 'group member destroy hook' do - group = create(:group) - user = create(:user) - group.add_user(user, Gitlab::Access::MASTER) - group.group_members.destroy_all - WebMock.should have_requested(:post, @system_hook.url).with( - body: /user_remove_from_group/ - ).once - end - - end -end diff --git a/spec/models/web_hook_spec.rb b/spec/models/web_hook_spec.rb deleted file mode 100644 index e9c04ee89cb..00000000000 --- a/spec/models/web_hook_spec.rb +++ /dev/null @@ -1,74 +0,0 @@ -# == Schema Information -# -# Table name: web_hooks -# -# id :integer not null, primary key -# url :string(255) -# project_id :integer -# created_at :datetime -# updated_at :datetime -# type :string(255) default("ProjectHook") -# service_id :integer -# push_events :boolean default(TRUE), not null -# issues_events :boolean default(FALSE), not null -# merge_requests_events :boolean default(FALSE), not null -# tag_push_events :boolean default(FALSE) -# - -require 'spec_helper' - -describe ProjectHook do - describe "Associations" do - it { should belong_to :project } - end - - describe "Mass assignment" do - end - - describe "Validations" do - it { should validate_presence_of(:url) } - - context "url format" do - it { should allow_value("http://example.com").for(:url) } - it { should allow_value("https://excample.com").for(:url) } - it { should allow_value("http://test.com/api").for(:url) } - it { should allow_value("http://test.com/api?key=abc").for(:url) } - it { should allow_value("http://test.com/api?key=abc&type=def").for(:url) } - - it { should_not allow_value("example.com").for(:url) } - it { should_not allow_value("ftp://example.com").for(:url) } - it { should_not allow_value("herp-and-derp").for(:url) } - end - end - - describe "execute" do - before(:each) do - @project_hook = create(:project_hook) - @project = create(:project) - @project.hooks << [@project_hook] - @data = { before: 'oldrev', after: 'newrev', ref: 'ref'} - - WebMock.stub_request(:post, @project_hook.url) - end - - it "POSTs to the web hook URL" do - @project_hook.execute(@data) - WebMock.should have_requested(:post, @project_hook.url).once - end - - it "POSTs the data as JSON" do - json = @data.to_json - - @project_hook.execute(@data) - WebMock.should have_requested(:post, @project_hook.url).with(body: json).once - end - - it "catches exceptions" do - WebHook.should_receive(:post).and_raise("Some HTTP Post error") - - lambda { - @project_hook.execute(@data) - }.should raise_error - end - end -end -- cgit v1.2.1 From a7a45dc949b9475dff674be57e8d3a7aa8811857 Mon Sep 17 00:00:00 2001 From: Vincent Robert Date: Fri, 30 Jan 2015 22:29:41 +0100 Subject: Bump GitLab for Docker to version 7.7.2 --- docker/Dockerfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docker/Dockerfile b/docker/Dockerfile index 70d6c721f1c..ec0923bd4c7 100644 --- a/docker/Dockerfile +++ b/docker/Dockerfile @@ -11,7 +11,7 @@ RUN apt-get update -q \ # If the Omnibus package version below is outdated please contribute a merge request to update it. # If you run GitLab Enterprise Edition point it to a location where you have downloaded it. RUN TMP_FILE=$(mktemp); \ - wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.7.1-omnibus.5.4.1.ci-1_amd64.deb \ + wget -q -O $TMP_FILE https://downloads-packages.s3.amazonaws.com/ubuntu-14.04/gitlab_7.7.2-omnibus.5.4.2.ci-1_amd64.deb \ && dpkg -i $TMP_FILE \ && rm -f $TMP_FILE -- cgit v1.2.1 From 561a7153082ef6cad7ec244d7881b8ddd35b9f8c Mon Sep 17 00:00:00 2001 From: Job van der Voort Date: Mon, 2 Feb 2015 10:00:05 -0800 Subject: add clear documentation on searching between groups --- doc/api/groups.md | 22 +++++++++++++++++++++- 1 file changed, 21 insertions(+), 1 deletion(-) diff --git a/doc/api/groups.md b/doc/api/groups.md index e6893d71774..9217c7a7f24 100644 --- a/doc/api/groups.md +++ b/doc/api/groups.md @@ -20,7 +20,7 @@ GET /groups ] ``` -You can search for groups by name or path with: `/groups?search=Rails` +You can search for groups by name or path, see below. ## Details of a group @@ -73,6 +73,26 @@ Parameters: - `id` (required) - The ID of a user group +## Search for group + +Get all groups that match your string in their name or path. + +``` +GET /groups?search=foobar +``` + +```json +[ + { + "id": 1, + "name": "Foobar Group", + "path": "foo-bar", + "owner_id": 18, + "description": "An interesting group" + } +] +``` + ## Group members **Group access levels** -- cgit v1.2.1 From c0acb28c4ec710c90eb55dc996251a30001c8e79 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 10:24:40 -0800 Subject: Annotate models --- app/models/project.rb | 2 +- .../project_services/custom_issue_tracker_service.rb | 14 ++++++++++++++ .../project_services/gitlab_issue_tracker_service.rb | 14 ++++++++++++++ app/models/project_services/issue_tracker_service.rb | 14 ++++++++++++++ app/models/project_services/jira_service.rb | 14 ++++++++++++++ app/models/project_services/redmine_service.rb | 14 ++++++++++++++ spec/factories/projects.rb | 1 + spec/models/project_services/jira_service_spec.rb | 14 ++++++++++++++ spec/models/project_spec.rb | 2 +- 9 files changed, 87 insertions(+), 2 deletions(-) diff --git a/app/models/project.rb b/app/models/project.rb index b26c697a7b7..f3dddc28adb 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -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 diff --git a/app/models/project_services/custom_issue_tracker_service.rb b/app/models/project_services/custom_issue_tracker_service.rb index 2476b62da89..b6b79589f1d 100644 --- a/app/models/project_services/custom_issue_tracker_service.rb +++ b/app/models/project_services/custom_issue_tracker_service.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + class CustomIssueTrackerService < IssueTrackerService prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url diff --git a/app/models/project_services/gitlab_issue_tracker_service.rb b/app/models/project_services/gitlab_issue_tracker_service.rb index 25f5f23bdf9..25e399883b7 100644 --- a/app/models/project_services/gitlab_issue_tracker_service.rb +++ b/app/models/project_services/gitlab_issue_tracker_service.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + class GitlabIssueTrackerService < IssueTrackerService include Rails.application.routes.url_helpers prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb index 632f053d17b..acc8b33178c 100644 --- a/app/models/project_services/issue_tracker_service.rb +++ b/app/models/project_services/issue_tracker_service.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + class IssueTrackerService < Service validates :project_url, :issues_url, :new_issue_url, presence: true, if: :activated? diff --git a/app/models/project_services/jira_service.rb b/app/models/project_services/jira_service.rb index b0d668948d0..7a32b0e8c2c 100644 --- a/app/models/project_services/jira_service.rb +++ b/app/models/project_services/jira_service.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + class JiraService < IssueTrackerService prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url diff --git a/app/models/project_services/redmine_service.rb b/app/models/project_services/redmine_service.rb index 11cce3e0561..547b2401832 100644 --- a/app/models/project_services/redmine_service.rb +++ b/app/models/project_services/redmine_service.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + class RedmineService < IssueTrackerService prop_accessor :title, :description, :project_url, :issues_url, :new_issue_url diff --git a/spec/factories/projects.rb b/spec/factories/projects.rb index 5ae57718c1a..0899a7603fc 100644 --- a/spec/factories/projects.rb +++ b/spec/factories/projects.rb @@ -26,6 +26,7 @@ # star_count :integer default(0), not null # import_type :string(255) # import_source :string(255) +# avatar :string(255) # FactoryGirl.define do diff --git a/spec/models/project_services/jira_service_spec.rb b/spec/models/project_services/jira_service_spec.rb index 0c73a68c924..99ca04eff6e 100644 --- a/spec/models/project_services/jira_service_spec.rb +++ b/spec/models/project_services/jira_service_spec.rb @@ -1,3 +1,17 @@ +# == Schema Information +# +# Table name: services +# +# id :integer not null, primary key +# type :string(255) +# title :string(255) +# project_id :integer not null +# created_at :datetime +# updated_at :datetime +# active :boolean default(FALSE), not null +# properties :text +# + require 'spec_helper' describe JiraService do diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index 092c02d552e..4669a9fd87d 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -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 -- cgit v1.2.1 From 2bd70b6a01b6b5b3406718d1f539f9f480cf3bec Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 15:47:51 -0800 Subject: Improve project icons for dashboard --- app/assets/stylesheets/sections/dashboard.scss | 10 ++++++++++ app/views/dashboard/_groups.html.haml | 3 ++- app/views/dashboard/_project.html.haml | 4 ++-- app/views/groups/_projects.html.haml | 4 ++-- app/views/users/_groups.html.haml | 4 ++-- 5 files changed, 18 insertions(+), 7 deletions(-) diff --git a/app/assets/stylesheets/sections/dashboard.scss b/app/assets/stylesheets/sections/dashboard.scss index 90010781af0..17c0cd81b93 100644 --- a/app/assets/stylesheets/sections/dashboard.scss +++ b/app/assets/stylesheets/sections/dashboard.scss @@ -97,7 +97,17 @@ .dash-project-avatar { float: left; + + .avatar { + margin-top: -8px; + margin-left: -15px; + @include border-radius(0px); + } + .identicon { + line-height: 40px; + } } + .dash-project-access-icon { float: left; margin-right: 5px; diff --git a/app/views/dashboard/_groups.html.haml b/app/views/dashboard/_groups.html.haml index ddabd6e0d52..ddf44270802 100644 --- a/app/views/dashboard/_groups.html.haml +++ b/app/views/dashboard/_groups.html.haml @@ -10,7 +10,8 @@ - groups.each do |group| %li.group-row = link_to group_path(id: group.path), class: dom_class(group) do - = image_tag group_icon(group.path), class: "avatar s24" + .dash-project-avatar + = image_tag group_icon(group.path), class: "avatar s40" %span.group-name.filter-title = truncate(group.name, length: 35) %span.arrow diff --git a/app/views/dashboard/_project.html.haml b/app/views/dashboard/_project.html.haml index 76b95264fd8..e9f411725a3 100644 --- a/app/views/dashboard/_project.html.haml +++ b/app/views/dashboard/_project.html.haml @@ -1,8 +1,8 @@ = link_to project_path(project), class: dom_class(project) do + .dash-project-avatar + = project_icon(project.to_param, alt: '', class: 'avatar s40') .dash-project-access-icon = visibility_level_icon(project.visibility_level) - .dash-project-avatar - = project_icon(project.to_param, alt: '', class: 'avatar s24') %span.str-truncated %span.namespace-name - if project.namespace diff --git a/app/views/groups/_projects.html.haml b/app/views/groups/_projects.html.haml index 34221595fd7..a2f1d28a275 100644 --- a/app/views/groups/_projects.html.haml +++ b/app/views/groups/_projects.html.haml @@ -12,10 +12,10 @@ - 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 s40') .dash-project-access-icon = visibility_level_icon(project.visibility_level) - .dash-project-avatar - = project_icon(project.to_param, alt: '', class: 'avatar s24') %span.str-truncated %span.project-name = project.name diff --git a/app/views/users/_groups.html.haml b/app/views/users/_groups.html.haml index 32a1dc83b57..b66a8808f87 100644 --- a/app/views/users/_groups.html.haml +++ b/app/views/users/_groups.html.haml @@ -1,4 +1,4 @@ .clearfix - groups.each do |group| - = link_to group, class: 'profile-groups-avatars', title: group.name do - = image_tag group_icon(group.path), class: 'avatar avatar-inline s40' + = link_to group, class: 'profile-groups-avatars inline', title: group.name do + = image_tag group_icon(group.path), class: 'avatar avatar-tile s40' -- cgit v1.2.1 From 7ba97ab4a53eba8d28d028a04e20e6ead1cd9f52 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 16:43:51 -0800 Subject: Web editor documnetation --- doc/workflow/README.md | 1 + doc/workflow/web_editor.md | 23 +++++++++++++++++++++++ doc/workflow/web_editor/edit_file.png | Bin 0 -> 99624 bytes doc/workflow/web_editor/empty_project.png | Bin 0 -> 122296 bytes doc/workflow/web_editor/new_file.png | Bin 0 -> 100516 bytes doc/workflow/web_editor/show_file.png | Bin 0 -> 111479 bytes 6 files changed, 24 insertions(+) create mode 100644 doc/workflow/web_editor.md create mode 100644 doc/workflow/web_editor/edit_file.png create mode 100644 doc/workflow/web_editor/empty_project.png create mode 100644 doc/workflow/web_editor/new_file.png create mode 100644 doc/workflow/web_editor/show_file.png diff --git a/doc/workflow/README.md b/doc/workflow/README.md index 33176aaba44..3c0007d8198 100644 --- a/doc/workflow/README.md +++ b/doc/workflow/README.md @@ -10,3 +10,4 @@ - [Migrating from SVN to GitLab](migrating_from_svn.md) - [Project importing from GitHub to GitLab](import_projects_from_github.md) - [Protected branches](protected_branches.md) +- [Web Editor](web_editor.md) diff --git a/doc/workflow/web_editor.md b/doc/workflow/web_editor.md new file mode 100644 index 00000000000..c83715deff7 --- /dev/null +++ b/doc/workflow/web_editor.md @@ -0,0 +1,23 @@ +# GitLab Web Editor + +In GitLab you can create new files and edit existing one using our web editor. +Its really useful if you dont have access to command line or you want to make a quick small fix. +You can access to web editor in several ways depends on context. +Lets start from newly created project. +Click on `Add a file` button to start web editor for creating first file. + +![web editor 1](web_editor/empty_project.png) + +Fill in file name, content, commit message and press commit button. +After this file will be saved to repository. + +![web editor 2](web_editor/new_file.png) + +You can edit any text file in repository by pressing edit button when browsing file. + +![web editor 3](web_editor/show_file.png) + +Edit of file is pretty same as creating new file. +Except you can see preview of your changes to file in separate tab + +![web editor 3](web_editor/edit_file.png) diff --git a/doc/workflow/web_editor/edit_file.png b/doc/workflow/web_editor/edit_file.png new file mode 100644 index 00000000000..1522c50b62f Binary files /dev/null and b/doc/workflow/web_editor/edit_file.png differ diff --git a/doc/workflow/web_editor/empty_project.png b/doc/workflow/web_editor/empty_project.png new file mode 100644 index 00000000000..6a049f6beaf Binary files /dev/null and b/doc/workflow/web_editor/empty_project.png differ diff --git a/doc/workflow/web_editor/new_file.png b/doc/workflow/web_editor/new_file.png new file mode 100644 index 00000000000..80941f37cea Binary files /dev/null and b/doc/workflow/web_editor/new_file.png differ diff --git a/doc/workflow/web_editor/show_file.png b/doc/workflow/web_editor/show_file.png new file mode 100644 index 00000000000..9cafcb55109 Binary files /dev/null and b/doc/workflow/web_editor/show_file.png differ -- cgit v1.2.1 From 76027e5efd739f9699f92c8e8cc0199ab17d7c47 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 18:54:27 -0800 Subject: Add rubocop and remove rails_best_practices gem --- .rubocop.yml | 26 ++++++++++++++++++++++++++ Gemfile | 3 +-- Gemfile.lock | 32 ++++++++++++++++---------------- 3 files changed, 43 insertions(+), 18 deletions(-) create mode 100644 .rubocop.yml diff --git a/.rubocop.yml b/.rubocop.yml new file mode 100644 index 00000000000..4579fbcd2e4 --- /dev/null +++ b/.rubocop.yml @@ -0,0 +1,26 @@ +StringLiterals: + Enabled: false +LineLength: + Enabled: false +Documentation: + Enabled: false +UnusedMethodArgument: + Enabled: false +UnusedBlockArgument: + Enabled: false +TrailingWhitespace: + Enabled: false +MethodLength: + Enabled: false +ClassLength: + Enabled: false +AllCops: + Exclude: + - 'spec/**/*' + - 'features/**/*' + - 'vendor/**/*' + - 'db/**/*' + - 'tmp/**/*' + - 'bin/**/*' + - 'lib/backup/**/*' + - 'lib/tasks/**/*' diff --git a/Gemfile b/Gemfile index be78831e1fc..8eede269e2d 100644 --- a/Gemfile +++ b/Gemfile @@ -206,8 +206,6 @@ group :development do gem 'better_errors' gem 'binding_of_caller' - gem 'rails_best_practices' - # Docs generator gem "sdoc" @@ -217,6 +215,7 @@ end group :development, :test do gem 'coveralls', require: false + gem 'rubocop', '0.28.0', require: false # gem 'rails-dev-tweaks' gem 'spinach-rails' gem "rspec-rails" diff --git a/Gemfile.lock b/Gemfile.lock index 551f16722f2..cde7bfa66f5 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -37,6 +37,9 @@ GEM rake (>= 0.8.7) arel (5.0.1.20140414130214) asciidoctor (0.1.4) + ast (2.0.0) + astrolabe (1.3.0) + parser (>= 2.2.0.pre.3, < 3.0) attr_required (1.0.0) awesome_print (1.2.0) axiom-types (0.0.5) @@ -67,8 +70,6 @@ GEM timers (~> 4.0.0) charlock_holmes (0.6.9.4) cliver (0.3.2) - code_analyzer (0.4.3) - sexp_processor coderay (1.1.0) coercible (1.0.0) descendants_tracker (~> 0.0.1) @@ -353,6 +354,8 @@ GEM org-ruby (0.9.12) rubypants (~> 0.2) orm_adapter (0.5.0) + parser (2.2.0.2) + ast (>= 1.1, < 3.0) pg (0.15.1) phantomjs (1.9.2.0) poltergeist (1.5.1) @@ -362,6 +365,7 @@ GEM websocket-driver (>= 0.2.0) polyglot (0.3.4) posix-spawn (0.3.9) + powerpack (0.0.9) pry (0.9.12.4) coderay (~> 1.0) method_source (~> 0.8) @@ -404,20 +408,12 @@ GEM sprockets-rails (~> 2.0) rails_autolink (1.1.6) rails (> 3.1) - rails_best_practices (1.14.4) - activesupport - awesome_print - code_analyzer (>= 0.4.3) - colored - erubis - i18n - require_all - ruby-progressbar railties (4.1.1) actionpack (= 4.1.1) activesupport (= 4.1.1) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) + rainbow (2.0.0) raindrops (0.13.0) rake (10.3.2) raphael-rails (2.1.2) @@ -448,7 +444,6 @@ GEM redis (>= 2.2) ref (1.0.5) request_store (1.0.5) - require_all (1.3.2) rest-client (1.6.7) mime-types (>= 1.16) rinku (1.7.3) @@ -468,7 +463,13 @@ GEM rspec-core (~> 2.14.0) rspec-expectations (~> 2.14.0) rspec-mocks (~> 2.14.0) - ruby-progressbar (1.2.0) + rubocop (0.28.0) + astrolabe (~> 1.3) + parser (>= 2.2.0.pre.7, < 3.0) + powerpack (~> 0.0.6) + rainbow (>= 1.99.1, < 3.0) + ruby-progressbar (~> 1.4) + ruby-progressbar (1.7.1) rubyntlm (0.4.0) rubypants (0.2.0) rugged (0.21.2) @@ -496,7 +497,6 @@ GEM semantic-ui-sass (1.8.0.0) sass (~> 3.2) settingslogic (2.0.9) - sexp_processor (4.4.0) shoulda-matchers (2.7.0) activesupport (>= 3.0.0) sidekiq (3.3.0) @@ -520,7 +520,7 @@ GEM slim (2.0.2) temple (~> 0.6.6) tilt (>= 1.3.3, < 2.1) - slop (3.4.7) + slop (3.6.0) spinach (0.8.7) colorize (= 0.5.8) gherkin-ruby (>= 0.3.1) @@ -704,7 +704,6 @@ DEPENDENCIES rack-oauth2 (~> 1.0.5) rails (~> 4.1.0) rails_autolink (~> 1.1) - rails_best_practices raphael-rails (~> 2.1.2) rb-fsevent rb-inotify @@ -713,6 +712,7 @@ DEPENDENCIES redis-rails request_store rspec-rails + rubocop (= 0.28.0) rugments sanitize (~> 2.0) sass-rails (~> 4.0.2) -- cgit v1.2.1 From 46b6ceeac7a6c24456a5669a49599e4d7fcd4755 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 19:11:45 -0800 Subject: At first disable all checks. We will enable it one by one later --- .rubocop.yml | 996 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 988 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 4579fbcd2e4..8f54d5d3765 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,19 +1,999 @@ -StringLiterals: +Style/AccessModifierIndentation: + Description: Check indentation of private/protected visibility modifiers. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-public-private-protected' Enabled: false -LineLength: + +Style/AccessorMethodName: + Description: Check the naming of accessor methods for get_/set_. Enabled: false -Documentation: + +Style/Alias: + Description: 'Use alias_method instead of alias.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method' Enabled: false -UnusedMethodArgument: + +Style/AlignArray: + Description: >- + Align the elements of an array literal if they span more than + one line. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#align-multiline-arrays' Enabled: false -UnusedBlockArgument: + +Style/AlignHash: + Description: >- + Align the elements of a hash literal if they span more than + one line. Enabled: false -TrailingWhitespace: + +Style/AlignParameters: + Description: >- + Align the parameters of a method call if they span more + than one line. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-double-indent' Enabled: false -MethodLength: + +Style/AndOr: + Description: 'Use &&/|| instead of and/or.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-and-or-or' Enabled: false -ClassLength: + +Style/ArrayJoin: + Description: 'Use Array#join instead of Array#*.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#array-join' Enabled: false + +Style/AsciiComments: + Description: 'Use only ascii symbols in comments.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments' + Enabled: false + +Style/AsciiIdentifiers: + Description: 'Use only ascii symbols in identifiers.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers' + Enabled: false + +Style/Attr: + Description: 'Checks for uses of Module#attr.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr' + Enabled: false + +Style/BeginBlock: + Description: 'Avoid the use of BEGIN blocks.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-BEGIN-blocks' + Enabled: false + +Style/BarePercentLiterals: + Description: 'Checks if usage of %() or %Q() matches configuration.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q-shorthand' + Enabled: false + +Style/BlockComments: + Description: 'Do not use block comments.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-block-comments' + Enabled: false + +Style/BlockEndNewline: + Description: 'Put end statement of multiline block on its own line.' + Enabled: false + +Style/Blocks: + Description: >- + Avoid using {...} for multi-line blocks (multiline chaining is + always ugly). + Prefer {...} over do...end for single-line blocks. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks' + Enabled: false + +Style/BracesAroundHashParameters: + Description: 'Enforce braces style around hash parameters.' + Enabled: false + +Style/CaseEquality: + Description: 'Avoid explicit use of the case equality operator(===).' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-case-equality' + Enabled: false + +Style/CaseIndentation: + Description: 'Indentation of when in a case/when/[else/]end.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-when-to-case' + Enabled: false + +Style/CharacterLiteral: + Description: 'Checks for uses of character literals.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals' + Enabled: false + +Style/ClassAndModuleCamelCase: + Description: 'Use CamelCase for classes and modules.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#camelcase-classes' + Enabled: false + +Style/ClassAndModuleChildren: + Description: 'Checks style of children classes and modules.' + Enabled: false + +Style/ClassCheck: + Description: 'Enforces consistent use of `Object#is_a?` or `Object#kind_of?`.' + Enabled: false + +Style/ClassMethods: + Description: 'Use self when defining module/class methods.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#def-self-singletons' + Enabled: false + +Style/ClassVars: + Description: 'Avoid the use of class variables.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars' + Enabled: false + +Style/ColonMethodCall: + Description: 'Do not use :: for method call.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#double-colons' + Enabled: false + +Style/CommentAnnotation: + Description: >- + Checks formatting of special comments + (TODO, FIXME, OPTIMIZE, HACK, REVIEW). + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#annotate-keywords' + Enabled: false + +Style/CommentIndentation: + Description: 'Indentation of comments.' + Enabled: false + +Style/ConstantName: + Description: 'Constants should use SCREAMING_SNAKE_CASE.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#screaming-snake-case' + Enabled: false + +Style/DefWithParentheses: + Description: 'Use def with parentheses when there are arguments.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens' + Enabled: false + +Style/DeprecatedHashMethods: + Description: 'Checks for use of deprecated Hash methods.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-key' + Enabled: false + +Style/Documentation: + Description: 'Document classes and non-namespace modules.' + Enabled: false + +Style/DotPosition: + Description: 'Checks the position of the dot in multi-line method calls.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-multi-line-chains' + Enabled: false + +Style/DoubleNegation: + Description: 'Checks for uses of double negation (!!).' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-bang-bang' + Enabled: false + +Style/EachWithObject: + Description: 'Prefer `each_with_object` over `inject` or `reduce`.' + Enabled: false + +Style/ElseAlignment: + Description: 'Align elses and elsifs correctly.' + Enabled: false + +Style/EmptyElse: + Description: 'Avoid empty else-clauses.' + Enabled: false + +Style/EmptyLineBetweenDefs: + Description: 'Use empty lines between defs.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#empty-lines-between-methods' + Enabled: false + +Style/EmptyLines: + Description: "Don't use several empty lines in a row." + Enabled: false + +Style/EmptyLinesAroundAccessModifier: + Description: "Keep blank lines around access modifiers." + Enabled: false + +Style/EmptyLinesAroundBlockBody: + Description: "Keeps track of empty lines around block bodies." + Enabled: false + +Style/EmptyLinesAroundClassBody: + Description: "Keeps track of empty lines around class bodies." + Enabled: false + +Style/EmptyLinesAroundModuleBody: + Description: "Keeps track of empty lines around module bodies." + Enabled: false + +Style/EmptyLinesAroundMethodBody: + Description: "Keeps track of empty lines around method bodies." + Enabled: false + +Style/EmptyLiteral: + Description: 'Prefer literals to Array.new/Hash.new/String.new.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#literal-array-hash' + Enabled: false + +Style/EndBlock: + Description: 'Avoid the use of END blocks.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-END-blocks' + Enabled: false + +Style/EndOfLine: + Description: 'Use Unix-style line endings.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#crlf' + Enabled: false + +Style/EvenOdd: + Description: 'Favor the use of Fixnum#even? && Fixnum#odd?' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods' + Enabled: false + +Style/FileName: + Description: 'Use snake_case for source file names.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-files' + Enabled: false + +Style/FlipFlop: + Description: 'Checks for flip flops' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-flip-flops' + Enabled: false + +Style/For: + Description: 'Checks use of for or each in multiline loops.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-for-loops' + Enabled: false + +Style/FormatString: + Description: 'Enforce the use of Kernel#sprintf, Kernel#format or String#%.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#sprintf' + Enabled: false + +Style/GlobalVars: + Description: 'Do not introduce global variables.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#instance-vars' + Enabled: false + +Style/GuardClause: + Description: 'Check for conditionals that can be replaced with guard clauses' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals' + Enabled: false + +Style/HashSyntax: + Description: >- + Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax + { :a => 1, :b => 2 }. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-literals' + Enabled: false + +Style/IfUnlessModifier: + Description: >- + Favor modifier if/unless usage when you have a + single-line body. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#if-as-a-modifier' + Enabled: false + +Style/IfWithSemicolon: + Description: 'Do not use if x; .... Use the ternary operator instead.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon-ifs' + Enabled: false + +Style/IndentationConsistency: + Description: 'Keep indentation straight.' + Enabled: false + +Style/IndentationWidth: + Description: 'Use 2 spaces for indentation.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation' + Enabled: false + +Style/IndentArray: + Description: >- + Checks the indentation of the first element in an array + literal. + Enabled: false + +Style/IndentHash: + Description: 'Checks the indentation of the first key in a hash literal.' + Enabled: false + +Style/InfiniteLoop: + Description: 'Use Kernel#loop for infinite loops.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#infinite-loop' + Enabled: false + +Style/Lambda: + Description: 'Use the new lambda literal syntax for single-line blocks.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#lambda-multi-line' + Enabled: false + +Style/LambdaCall: + Description: 'Use lambda.call(...) instead of lambda.(...).' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc-call' + Enabled: false + +Style/LeadingCommentSpace: + Description: 'Comments should start with a space.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-space' + Enabled: false + +Style/LineEndConcatenation: + Description: >- + Use \ instead of + or << to concatenate two string literals at + line end. + Enabled: false + +Style/MethodCallParentheses: + Description: 'Do not use parentheses for method calls with no arguments.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-args-no-parens' + Enabled: false + +Style/MethodDefParentheses: + Description: >- + Checks if the method definitions have or don't have + parentheses. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#method-parens' + Enabled: false + +Style/MethodName: + Description: 'Use the configured style when naming methods.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars' + Enabled: false + +Style/ModuleFunction: + Description: 'Checks for usage of `extend self` in modules.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#module-function' + Enabled: false + +Style/MultilineBlockChain: + Description: 'Avoid multi-line chains of blocks.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks' + Enabled: false + +Style/MultilineBlockLayout: + Description: 'Ensures newlines after multiline block do statements.' + Enabled: false + +Style/MultilineIfThen: + Description: 'Do not use then for multi-line if/unless.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-then' + Enabled: false + +Style/MultilineOperationIndentation: + Description: >- + Checks indentation of binary operations that span more than + one line. + Enabled: false + +Style/MultilineTernaryOperator: + Description: >- + Avoid multi-line ?: (the ternary operator); + use if/unless instead. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-multiline-ternary' + Enabled: false + +Style/NegatedIf: + Description: >- + Favor unless over if for negative conditions + (or control flow or). + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#unless-for-negatives' + Enabled: false + +Style/NegatedWhile: + Description: 'Favor until over while for negative conditions.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#until-for-negatives' + Enabled: false + +Style/NestedTernaryOperator: + Description: 'Use one expression per branch in a ternary operator.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-ternary' + Enabled: false + +Style/Next: + Description: 'Use `next` to skip iteration instead of a condition at the end.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-nested-conditionals' + Enabled: false + +Style/NilComparison: + Description: 'Prefer x.nil? to x == nil.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#predicate-methods' + Enabled: false + +Style/NonNilCheck: + Description: 'Checks for redundant nil checks.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-non-nil-checks' + Enabled: false + +Style/Not: + Description: 'Use ! instead of not.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bang-not-not' + Enabled: false + +Style/NumericLiterals: + Description: >- + Add underscores to large numeric literals to improve their + readability. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscores-in-numerics' + Enabled: false + +Style/OneLineConditional: + Description: >- + Favor the ternary operator(?:) over + if/then/else/end constructs. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#ternary-operator' + Enabled: false + +Style/OpMethod: + Description: 'When defining binary operators, name the argument other.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#other-arg' + Enabled: false + +Style/ParenthesesAroundCondition: + Description: >- + Don't use parentheses around the condition of an + if/unless/while. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-parens-if' + Enabled: false + +Style/PercentLiteralDelimiters: + Description: 'Use `%`-literal delimiters consistently' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-literal-braces' + Enabled: false + +Style/PercentQLiterals: + Description: 'Checks if uses of %Q/%q match the configured preference.' + Enabled: false + +Style/PerlBackrefs: + Description: 'Avoid Perl-style regex back references.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-perl-regexp-last-matchers' + Enabled: false + +Style/PredicateName: + Description: 'Check the names of predicate methods.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#bool-methods-qmark' + Enabled: false + +Style/Proc: + Description: 'Use proc instead of Proc.new.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#proc' + Enabled: false + +Style/RaiseArgs: + Description: 'Checks the arguments passed to raise/fail.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#exception-class-messages' + Enabled: false + +Style/RedundantBegin: + Description: "Don't use begin blocks when they are not needed." + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#begin-implicit' + Enabled: false + +Style/RedundantException: + Description: "Checks for an obsolete RuntimeException argument in raise/fail." + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-explicit-runtimeerror' + Enabled: false + +Style/RedundantReturn: + Description: "Don't use return where it's not required." + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-explicit-return' + Enabled: false + +Style/RedundantSelf: + Description: "Don't use self where it's not needed." + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-self-unless-required' + Enabled: false + +Style/RegexpLiteral: + Description: >- + Use %r for regular expressions matching more than + `MaxSlashes` '/' characters. + Use %r only for regular expressions matching more than + `MaxSlashes` '/' character. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-r' + Enabled: false + +Style/RescueModifier: + Description: 'Avoid using rescue in its modifier form.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-rescue-modifiers' + Enabled: false + +Style/SelfAssignment: + Description: >- + Checks for places where self-assignment shorthand should have + been used. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#self-assignment' + Enabled: false + +Style/Semicolon: + Description: "Don't use semicolons to terminate expressions." + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-semicolon' + Enabled: false + +Style/SignalException: + Description: 'Checks for proper usage of fail and raise.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#fail-method' + Enabled: false + +Style/SingleLineBlockParams: + Description: 'Enforces the names of some block params.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#reduce-blocks' + Enabled: false + +Style/SingleLineMethods: + Description: 'Avoid single-line methods.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-single-line-methods' + Enabled: false + +Style/SingleSpaceBeforeFirstArg: + Description: >- + Checks that exactly one space is used between a method name + and the first argument for method calls without parentheses. + Enabled: false + +Style/SpaceAfterColon: + Description: 'Use spaces after colons.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' + Enabled: false + +Style/SpaceAfterComma: + Description: 'Use spaces after commas.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' + Enabled: false + +Style/SpaceAfterControlKeyword: + Description: 'Use spaces after if/elsif/unless/while/until/case/when.' + Enabled: false + +Style/SpaceAfterMethodName: + Description: >- + Do not put a space between a method name and the opening + parenthesis in a method definition. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces' + Enabled: false + +Style/SpaceAfterNot: + Description: Tracks redundant space after the ! operator. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-space-bang' + Enabled: false + +Style/SpaceAfterSemicolon: + Description: 'Use spaces after semicolons.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' + Enabled: false + +Style/SpaceBeforeBlockBraces: + Description: >- + Checks that the left block brace has or doesn't have space + before it. + Enabled: false + +Style/SpaceBeforeComma: + Description: 'No spaces before commas.' + Enabled: false + +Style/SpaceBeforeComment: + Description: >- + Checks for missing space between code and a comment on the + same line. + Enabled: false + +Style/SpaceBeforeSemicolon: + Description: 'No spaces before semicolons.' + Enabled: false + +Style/SpaceInsideBlockBraces: + Description: >- + Checks that block braces have or don't have surrounding space. + For blocks taking parameters, checks that the left brace has + or doesn't have trailing space. + Enabled: false + +Style/SpaceAroundEqualsInParameterDefault: + Description: >- + Checks that the equals signs in parameter default assignments + have or don't have surrounding space depending on + configuration. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-around-equals' + Enabled: false + +Style/SpaceAroundOperators: + Description: 'Use spaces around operators.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' + Enabled: false + +Style/SpaceBeforeModifierKeyword: + Description: 'Put a space before the modifier keyword.' + Enabled: false + +Style/SpaceInsideBrackets: + Description: 'No spaces after [ or before ].' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-spaces-braces' + Enabled: false + +Style/SpaceInsideHashLiteralBraces: + Description: "Use spaces inside hash literal braces - or don't." + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' + Enabled: false + +Style/SpaceInsideParens: + Description: 'No spaces after ( or before ).' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-spaces-braces' + Enabled: false + +Style/SpaceInsideRangeLiteral: + Description: 'No spaces inside range literals.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-space-inside-range-literals' + Enabled: false + +Style/SpecialGlobalVars: + Description: 'Avoid Perl-style global variables.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-cryptic-perlisms' + Enabled: false + +Style/StringLiterals: + Description: 'Checks if uses of quotes match the configured preference.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#consistent-string-literals' + Enabled: false + +Style/StringLiteralsInInterpolation: + Description: >- + Checks if uses of quotes inside expressions in interpolated + strings match the configured preference. + Enabled: false + +Style/SymbolProc: + Description: 'Use symbols as procs instead of blocks when possible.' + Enabled: false + +Style/Tab: + Description: 'No hard tabs.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation' + Enabled: false + +Style/TrailingBlankLines: + Description: 'Checks trailing blank lines and final newline.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#newline-eof' + Enabled: false + +Style/TrailingComma: + Description: 'Checks for trailing comma in parameter lists and literals.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-array-commas' + Enabled: false + +Style/TrailingWhitespace: + Description: 'Avoid trailing whitespace.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-trailing-whitespace' + Enabled: false + +Style/TrivialAccessors: + Description: 'Prefer attr_* methods to trivial readers/writers.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#attr_family' + Enabled: false + +Style/UnlessElse: + Description: >- + Do not use unless with else. Rewrite these with the positive + case first. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-else-with-unless' + Enabled: false + +Style/UnneededCapitalW: + Description: 'Checks for %W when interpolation is not needed.' + Enabled: false + +Style/UnneededPercentQ: + Description: 'Checks for %q/%Q when single quotes or double quotes would do.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-q' + Enabled: false + +Style/UnneededPercentX: + Description: 'Checks for %x when `` would do.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-x' + Enabled: false + +Style/VariableInterpolation: + Description: >- + Don't interpolate global, instance and class variables + directly in strings. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#curlies-interpolate' + Enabled: false + +Style/VariableName: + Description: 'Use the configured style when naming variables.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#snake-case-symbols-methods-vars' + Enabled: false + +Style/WhenThen: + Description: 'Use when x then ... for one-line cases.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#one-line-cases' + Enabled: false + +Style/WhileUntilDo: + Description: 'Checks for redundant do after while or until.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-multiline-while-do' + Enabled: false + +Style/WhileUntilModifier: + Description: >- + Favor modifier while/until usage when you have a + single-line body. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#while-as-a-modifier' + Enabled: false + +Style/WordArray: + Description: 'Use %w or %W for arrays of words.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#percent-w' + Enabled: false + +#################### Metrics ################################ + +Metrics/AbcSize: + Description: >- + A calculated magnitude based on number of assignments, + branches, and conditions. + Enabled: false + +Metrics/BlockNesting: + Description: 'Avoid excessive block nesting' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#three-is-the-number-thou-shalt-count' + Enabled: false + +Metrics/ClassLength: + Description: 'Avoid classes longer than 100 lines of code.' + Enabled: false + +Metrics/CyclomaticComplexity: + Description: >- + A complexity metric that is strongly correlated to the number + of test cases needed to validate a method. + Enabled: false + +Metrics/LineLength: + Description: 'Limit lines to 80 characters.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#80-character-limits' + Enabled: false + +Metrics/MethodLength: + Description: 'Avoid methods longer than 10 lines of code.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#short-methods' + Enabled: false + +Metrics/ParameterLists: + Description: 'Avoid parameter lists longer than three or four parameters.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#too-many-params' + Enabled: false + +Metrics/PerceivedComplexity: + Description: >- + A complexity metric geared towards measuring complexity for a + human reader. + Enabled: false + +#################### Lint ################################ +### Warnings + +Lint/AmbiguousOperator: + Description: >- + Checks for ambiguous operators in the first argument of a + method invocation without parentheses. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-as-args' + Enabled: false + +Lint/AmbiguousRegexpLiteral: + Description: >- + Checks for ambiguous regexp literals in the first argument of + a method invocation without parenthesis. + Enabled: false + +Lint/AssignmentInCondition: + Description: "Don't use assignment in conditions." + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#safe-assignment-in-condition' + Enabled: false + +Lint/BlockAlignment: + Description: 'Align block ends correctly.' + Enabled: false + +Lint/ConditionPosition: + Description: >- + Checks for condition placed in a confusing position relative to + the keyword. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#same-line-condition' + Enabled: false + +Lint/Debugger: + Description: 'Check for debugger calls.' + Enabled: false + +Lint/DefEndAlignment: + Description: 'Align ends corresponding to defs correctly.' + Enabled: false + +Lint/DeprecatedClassMethods: + Description: 'Check for deprecated class method calls.' + Enabled: false + +Lint/DuplicateMethods: + Description: 'Check for duplicate methods calls.' + Enabled: false + +Lint/ElseLayout: + Description: 'Check for odd code arrangement in an else block.' + Enabled: false + +Lint/EmptyEnsure: + Description: 'Checks for empty ensure block.' + Enabled: false + +Lint/EmptyInterpolation: + Description: 'Checks for empty string interpolation.' + Enabled: false + +Lint/EndAlignment: + Description: 'Align ends correctly.' + Enabled: false + +Lint/EndInMethod: + Description: 'END blocks should not be placed inside method definitions.' + Enabled: false + +Lint/EnsureReturn: + Description: 'Do not use return in an ensure block.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-return-ensure' + Enabled: false + +Lint/Eval: + Description: 'The use of eval represents a serious security risk.' + Enabled: false + +Lint/HandleExceptions: + Description: "Don't suppress exception." + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#dont-hide-exceptions' + Enabled: false + +Lint/InvalidCharacterLiteral: + Description: >- + Checks for invalid character literals with a non-escaped + whitespace character. + Enabled: false + +Lint/LiteralInCondition: + Description: 'Checks of literals used in conditions.' + Enabled: false + +Lint/LiteralInInterpolation: + Description: 'Checks for literals used in interpolation.' + Enabled: false + +Lint/Loop: + Description: >- + Use Kernel#loop with break rather than begin/end/until or + begin/end/while for post-loop tests. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#loop-with-break' + Enabled: false + +Lint/ParenthesesAsGroupedExpression: + Description: >- + Checks for method calls with a space before the opening + parenthesis. + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#parens-no-spaces' + Enabled: false + +Lint/RequireParentheses: + Description: >- + Use parentheses in the method call to avoid confusion + about precedence. + Enabled: false + +Lint/RescueException: + Description: 'Avoid rescuing the Exception class.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-blind-rescues' + Enabled: false + +Lint/ShadowingOuterLocalVariable: + Description: >- + Do not use the same name as outer local variable + for block arguments or block local variables. + Enabled: false + +Lint/SpaceBeforeFirstArg: + Description: >- + Put a space between a method name and the first argument + in a method call without parentheses. + Enabled: false + +Lint/StringConversionInInterpolation: + Description: 'Checks for Object#to_s usage in string interpolation.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-to-s' + Enabled: false + +Lint/UnderscorePrefixedVariableName: + Description: 'Do not use prefix `_` for a variable that is used.' + Enabled: false + +Lint/UnusedBlockArgument: + Description: 'Checks for unused block arguments.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars' + Enabled: false + +Lint/UnusedMethodArgument: + Description: 'Checks for unused method arguments.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars' + Enabled: false + +Lint/UnreachableCode: + Description: 'Unreachable code.' + Enabled: false + +Lint/UselessAccessModifier: + Description: 'Checks for useless access modifiers.' + Enabled: false + +Lint/UselessAssignment: + Description: 'Checks for useless assignment to a local variable.' + StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#underscore-unused-vars' + Enabled: false + +Lint/UselessComparison: + Description: 'Checks for comparison of something with itself.' + Enabled: false + +Lint/UselessElseWithoutRescue: + Description: 'Checks for useless `else` in `begin..end` without `rescue`.' + Enabled: false + +Lint/UselessSetterCall: + Description: 'Checks for useless setter call to a local variable.' + Enabled: false + +Lint/Void: + Description: 'Possible use of operator/literal/variable in void context.' + Enabled: false + +##################### Rails ################################## + +Rails/ActionFilter: + Description: 'Enforces consistent use of action filter methods.' + Enabled: false + +Rails/DefaultScope: + Description: 'Checks if the argument passed to default_scope is a block.' + Enabled: false + +Rails/Delegate: + Description: 'Prefer delegate method for delegations.' + Enabled: false + +Rails/HasAndBelongsToMany: + Description: 'Prefer has_many :through to has_and_belongs_to_many.' + Enabled: false + +Rails/Output: + Description: 'Checks for calls to puts, print, etc.' + Enabled: false + +Rails/ReadWriteAttribute: + Description: >- + Checks for read_attribute(:attr) and + write_attribute(:attr, val). + Enabled: false + +Rails/ScopeArgs: + Description: 'Checks the arguments of ActiveRecord scopes.' + Enabled: false + +Rails/Validation: + Description: 'Use validates :attribute, hash of validations.' + Enabled: false + + +# Exclude some of GitLab files +# +# AllCops: Exclude: - 'spec/**/*' -- cgit v1.2.1 From 4f1d1fc51baf396d49f6b159c84e15194706847c Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 19:30:09 -0800 Subject: Convert hashes to ruby 1.9 style --- .rubocop.yml | 6 +----- app/controllers/github_imports_controller.rb | 4 ++-- app/helpers/emails_helper.rb | 2 +- app/helpers/merge_requests_helper.rb | 2 +- app/models/merge_request.rb | 2 +- app/models/project.rb | 8 ++++---- config/initializers/carrierwave.rb | 10 +++++----- config/initializers/doorkeeper.rb | 4 ++-- config/routes.rb | 6 +++--- lib/api/api_guard.rb | 4 ++-- lib/api/entities.rb | 2 +- lib/gitlab/github/importer.rb | 8 ++++---- 12 files changed, 27 insertions(+), 31 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 8f54d5d3765..807527e8d4b 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -267,7 +267,7 @@ Style/HashSyntax: Prefer Ruby 1.9 hash syntax { a: 1, b: 2 } over 1.8 syntax { :a => 1, :b => 2 }. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#hash-literals' - Enabled: false + Enabled: true Style/IfUnlessModifier: Description: >- @@ -817,10 +817,6 @@ Lint/DeprecatedClassMethods: Description: 'Check for deprecated class method calls.' Enabled: false -Lint/DuplicateMethods: - Description: 'Check for duplicate methods calls.' - Enabled: false - Lint/ElseLayout: Description: 'Check for odd code arrangement in an else block.' Enabled: false diff --git a/app/controllers/github_imports_controller.rb b/app/controllers/github_imports_controller.rb index 3c5448bc709..b73e3f7ffac 100644 --- a/app/controllers/github_imports_controller.rb +++ b/app/controllers/github_imports_controller.rb @@ -23,7 +23,7 @@ class GithubImportsController < ApplicationController end def jobs - jobs = current_user.created_projects.where(import_type: "github").to_json(:only => [:id, :import_status]) + jobs = current_user.created_projects.where(import_type: "github").to_json(only: [:id, :import_status]) render json: jobs end @@ -58,7 +58,7 @@ class GithubImportsController < ApplicationController def octo_client Octokit.auto_paginate = true - @octo_client ||= Octokit::Client.new(:access_token => current_user.github_access_token) + @octo_client ||= Octokit::Client.new(access_token: current_user.github_access_token) end def github_auth diff --git a/app/helpers/emails_helper.rb b/app/helpers/emails_helper.rb index b336263049c..92cc9c426b8 100644 --- a/app/helpers/emails_helper.rb +++ b/app/helpers/emails_helper.rb @@ -31,7 +31,7 @@ module EmailsHelper end def add_email_highlight_css - Rugments::Themes::Github.render(:scope => '.highlight') + Rugments::Themes::Github.render(scope: '.highlight') end def color_email_diff(diffcontent) diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index fe6fd5832fc..2c9aeba570a 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -15,7 +15,7 @@ module MergeRequestsHelper end def new_mr_from_push_event(event, target_project) - return :merge_request => { + return merge_request: { source_project_id: event.project.id, target_project_id: target_project.id, source_branch: event.branch_name, diff --git a/app/models/merge_request.rb b/app/models/merge_request.rb index 715257f905f..ad2e8d7879b 100644 --- a/app/models/merge_request.rb +++ b/app/models/merge_request.rb @@ -76,7 +76,7 @@ class MergeRequest < ActiveRecord::Base merge_request.save end - after_transition :locked => (any - :locked) do |merge_request, transition| + after_transition locked: (any - :locked) do |merge_request, transition| merge_request.locked_at = nil merge_request.save end diff --git a/app/models/project.rb b/app/models/project.rb index f3dddc28adb..f314ed9bd25 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -156,22 +156,22 @@ class Project < ActiveRecord::Base end event :import_finish do - transition :started => :finished + transition started: :finished end event :import_fail do - transition :started => :failed + transition started: :failed end event :import_retry do - transition :failed => :started + transition failed: :started end state :started state :finished state :failed - after_transition any => :started, :do => :add_import_job + after_transition any => :started, do: :add_import_job end class << self diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index d0065b63e54..10dfc30a0c5 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -23,11 +23,11 @@ if File.exists?(aws_file) if Rails.env.test? Fog.mock! connection = ::Fog::Storage.new( - :aws_access_key_id => AWS_CONFIG['access_key_id'], - :aws_secret_access_key => AWS_CONFIG['secret_access_key'], - :provider => 'AWS', - :region => AWS_CONFIG['region'] + aws_access_key_id: AWS_CONFIG['access_key_id'], + aws_secret_access_key: AWS_CONFIG['secret_access_key'], + provider: 'AWS', + region: AWS_CONFIG['region'] ) - connection.directories.create(:key => AWS_CONFIG['bucket']) + connection.directories.create(key: AWS_CONFIG['bucket']) end end diff --git a/config/initializers/doorkeeper.rb b/config/initializers/doorkeeper.rb index 4819ab273dc..e9b843e29b4 100644 --- a/config/initializers/doorkeeper.rb +++ b/config/initializers/doorkeeper.rb @@ -43,10 +43,10 @@ Doorkeeper.configure do force_ssl_in_redirect_uri false # Provide support for an owner to be assigned to each registered application (disabled by default) - # Optional parameter :confirmation => true (default false) if you want to enforce ownership of + # Optional parameter confirmation: true (default false) if you want to enforce ownership of # a registered application # Note: you must also run the rails g doorkeeper:application_owner generator to provide the necessary support - enable_application_owner :confirmation => false + enable_application_owner confirmation: false # Define access token scopes for your provider # For more information go to diff --git a/config/routes.rb b/config/routes.rb index e122777314a..30df1ba0dfe 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -3,9 +3,9 @@ require 'api/api' Gitlab::Application.routes.draw do use_doorkeeper do - controllers :applications => 'oauth/applications', - :authorized_applications => 'oauth/authorized_applications', - :authorizations => 'oauth/authorizations' + controllers applications: 'oauth/applications', + authorized_applications: 'oauth/authorized_applications', + authorizations: 'oauth/authorizations' end # # Search diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb index 23975518181..28765b142f6 100644 --- a/lib/api/api_guard.rb +++ b/lib/api/api_guard.rb @@ -146,7 +146,7 @@ module APIGuard Rack::OAuth2::Server::Resource::Bearer::Forbidden.new( :insufficient_scope, Rack::OAuth2::Server::Resource::ErrorMethods::DEFAULT_DESCRIPTION[:insufficient_scope], - { :scope => e.scopes}) + { scope: e.scopes}) end response.finish @@ -172,4 +172,4 @@ module APIGuard @scopes = scopes end end -end \ No newline at end of file +end diff --git a/lib/api/entities.rb b/lib/api/entities.rb index ac166ed4fba..58339908fd2 100644 --- a/lib/api/entities.rb +++ b/lib/api/entities.rb @@ -55,7 +55,7 @@ module API expose :path, :path_with_namespace expose :issues_enabled, :merge_requests_enabled, :wiki_enabled, :snippets_enabled, :created_at, :last_activity_at expose :namespace - expose :forked_from_project, using: Entities::ForkedFromProject, :if => lambda{ | project, options | project.forked? } + expose :forked_from_project, using: Entities::ForkedFromProject, if: lambda{ | project, options | project.forked? } end class ProjectMember < UserBasic diff --git a/lib/gitlab/github/importer.rb b/lib/gitlab/github/importer.rb index c72a1c25e9e..9f0fc6c4471 100644 --- a/lib/gitlab/github/importer.rb +++ b/lib/gitlab/github/importer.rb @@ -9,12 +9,12 @@ module Gitlab def execute client = octo_client(project.creator.github_access_token) - + #Issues && Comments client.list_issues(project.import_source, state: :all).each do |issue| if issue.pull_request.nil? body = "*Created by: #{issue.user.login}*\n\n#{issue.body}" - + if issue.comments > 0 body += "\n\n\n**Imported comments:**\n" client.issue_comments(project.import_source, issue.number).each do |c| @@ -23,7 +23,7 @@ module Gitlab end project.issues.create!( - description: body, + description: body, title: issue.title, state: issue.state == 'closed' ? 'closed' : 'opened', author_id: gl_user_id(project, issue.user.id) @@ -36,7 +36,7 @@ module Gitlab def octo_client(access_token) ::Octokit.auto_paginate = true - ::Octokit::Client.new(:access_token => access_token) + ::Octokit::Client.new(access_token: access_token) end def gl_user_id(project, github_id) -- cgit v1.2.1 From c8e7928e348117447380455684a3689d43fa492b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 19:33:57 -0800 Subject: Update CHANGELOG with rubocop --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 2db5beb0022..aa7daa11947 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -25,7 +25,7 @@ v 7.8.0 - Upgrade Sidekiq gem to version 3.3.0 - Stop git zombie creation during force push check - Show success/error messages for test setting button in services - - + - Added Rubocop for code style checks - Fix commits pagination - - -- cgit v1.2.1 From afb8ecc3d1569520379a2d0613137c46d44a12ce Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 20:02:46 -0800 Subject: Fix syntax error --- app/helpers/merge_requests_helper.rb | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/app/helpers/merge_requests_helper.rb b/app/helpers/merge_requests_helper.rb index 2c9aeba570a..4c640d4fc5f 100644 --- a/app/helpers/merge_requests_helper.rb +++ b/app/helpers/merge_requests_helper.rb @@ -15,11 +15,13 @@ module MergeRequestsHelper end def new_mr_from_push_event(event, target_project) - return merge_request: { - source_project_id: event.project.id, - target_project_id: target_project.id, - source_branch: event.branch_name, - target_branch: target_project.repository.root_ref + return { + merge_request: { + source_project_id: event.project.id, + target_project_id: target_project.id, + source_branch: event.branch_name, + target_branch: target_project.repository.root_ref + } } end -- cgit v1.2.1 From 84a5a548a5e1377f34b7989fc546eaedf86c3510 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 20:08:23 -0800 Subject: Add rubocop to rake test and rake test_ci --- lib/tasks/gitlab/test.rake | 1 + lib/tasks/rubocop.rake | 2 ++ lib/tasks/test.rake | 2 +- 3 files changed, 4 insertions(+), 1 deletion(-) create mode 100644 lib/tasks/rubocop.rake diff --git a/lib/tasks/gitlab/test.rake b/lib/tasks/gitlab/test.rake index c01b00bd1c0..b4076f8238f 100644 --- a/lib/tasks/gitlab/test.rake +++ b/lib/tasks/gitlab/test.rake @@ -2,6 +2,7 @@ namespace :gitlab do desc "GITLAB | Run all tests" task :test do cmds = [ + %W(rake rubocop), %W(rake spinach), %W(rake spec), %W(rake jasmine:ci) diff --git a/lib/tasks/rubocop.rake b/lib/tasks/rubocop.rake new file mode 100644 index 00000000000..c28e529f86d --- /dev/null +++ b/lib/tasks/rubocop.rake @@ -0,0 +1,2 @@ +require 'rubocop/rake_task' +RuboCop::RakeTask.new diff --git a/lib/tasks/test.rake b/lib/tasks/test.rake index 583f4a876da..3ea9290a814 100644 --- a/lib/tasks/test.rake +++ b/lib/tasks/test.rake @@ -9,5 +9,5 @@ unless Rails.env.production? require 'coveralls/rake/task' Coveralls::RakeTask.new desc "GITLAB | Run all tests on CI with simplecov" - task :test_ci => [:spinach, :spec, 'coveralls:push'] + task :test_ci => [:rubocop, :spinach, :spec, 'coveralls:push'] end -- cgit v1.2.1 From e89058268118e3b2be4ebaf5d7bf2c684b590437 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 20:36:54 -0800 Subject: Rubocop enabled for: Use spaces inside hash literal braces --- .rubocop.yml | 2 +- app/controllers/snippets_controller.rb | 2 +- app/helpers/compare_helper.rb | 4 +- app/helpers/projects_helper.rb | 2 +- app/models/hooks/web_hook.rb | 2 +- app/models/identity.rb | 2 +- .../custom_issue_tracker_service.rb | 4 +- app/models/project_services/gitlab_ci_service.rb | 2 +- .../project_services/issue_tracker_service.rb | 4 +- app/models/project_wiki.rb | 2 +- app/models/user.rb | 4 +- config/initializers/1_settings.rb | 2 +- config/initializers/carrierwave.rb | 2 +- config/routes.rb | 48 +++++++++++----------- lib/api/api.rb | 4 +- lib/api/api_guard.rb | 2 +- lib/api/helpers.rb | 2 +- lib/api/project_members.rb | 2 +- lib/gitlab/backend/grack_auth.rb | 8 ++-- lib/gitlab/git_access_status.rb | 4 +- lib/gitlab/satellite/action.rb | 2 +- lib/gitlab/satellite/files/delete_file_action.rb | 4 +- lib/gitlab/satellite/files/edit_file_action.rb | 4 +- lib/gitlab/satellite/files/new_file_action.rb | 4 +- lib/gitlab/satellite/merge_action.rb | 6 +-- lib/gitlab/satellite/satellite.rb | 6 +-- lib/gitlab/upgrader.rb | 2 +- 27 files changed, 66 insertions(+), 66 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 807527e8d4b..17494974d14 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -617,7 +617,7 @@ Style/SpaceInsideBrackets: Style/SpaceInsideHashLiteralBraces: Description: "Use spaces inside hash literal braces - or don't." StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-operators' - Enabled: false + Enabled: true Style/SpaceInsideParens: Description: 'No spaces after ( or before ).' diff --git a/app/controllers/snippets_controller.rb b/app/controllers/snippets_controller.rb index 312e561b522..1ed3bc388fb 100644 --- a/app/controllers/snippets_controller.rb +++ b/app/controllers/snippets_controller.rb @@ -27,7 +27,7 @@ class SnippetsController < ApplicationController @snippets = SnippetsFinder.new.execute(current_user, { filter: :by_user, user: @user, - scope: params[:scope]}). + scope: params[:scope] }). page(params[:page]).per(20) if @user == current_user diff --git a/app/helpers/compare_helper.rb b/app/helpers/compare_helper.rb index 5ff19b88293..dd2e713a54e 100644 --- a/app/helpers/compare_helper.rb +++ b/app/helpers/compare_helper.rb @@ -1,7 +1,7 @@ module CompareHelper def compare_to_mr_button? @project.merge_requests_enabled && - params[:from].present? && + params[:from].present? && params[:to].present? && @repository.branch_names.include?(params[:from]) && @repository.branch_names.include?(params[:to]) && @@ -10,6 +10,6 @@ module CompareHelper end def compare_mr_path - new_project_merge_request_path(@project, merge_request: {source_branch: params[:to], target_branch: params[:from]}) + new_project_merge_request_path(@project, merge_request: { source_branch: params[:to], target_branch: params[:from] }) end end diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 0b01be79623..687b087e683 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -95,7 +95,7 @@ module ProjectsHelper class: cls, method: :post, remote: true, - data: {type: 'json'} + data: { type: 'json' } } diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb index d1d522be194..327cb585ffa 100644 --- a/app/models/hooks/web_hook.rb +++ b/app/models/hooks/web_hook.rb @@ -44,7 +44,7 @@ class WebHook < ActiveRecord::Base } WebHook.post(post_url, body: data.to_json, - headers: {"Content-Type" => "application/json"}, + headers: { "Content-Type" => "application/json" }, verify: false, basic_auth: auth) end diff --git a/app/models/identity.rb b/app/models/identity.rb index c7cdb63e3d2..80e0e3a8a23 100644 --- a/app/models/identity.rb +++ b/app/models/identity.rb @@ -11,5 +11,5 @@ class Identity < ActiveRecord::Base belongs_to :user - validates :extern_uid, allow_blank: true, uniqueness: {scope: :provider} + validates :extern_uid, allow_blank: true, uniqueness: { scope: :provider } end diff --git a/app/models/project_services/custom_issue_tracker_service.rb b/app/models/project_services/custom_issue_tracker_service.rb index b6b79589f1d..5845e2d3525 100644 --- a/app/models/project_services/custom_issue_tracker_service.rb +++ b/app/models/project_services/custom_issue_tracker_service.rb @@ -41,8 +41,8 @@ class CustomIssueTrackerService < IssueTrackerService { type: 'text', name: 'title', placeholder: title }, { type: 'text', name: 'description', placeholder: description }, { type: 'text', name: 'project_url', placeholder: 'Project url' }, - { type: 'text', name: 'issues_url', placeholder: 'Issue url'}, - { type: 'text', name: 'new_issue_url', placeholder: 'New Issue url'} + { type: 'text', name: 'issues_url', placeholder: 'Issue url' }, + { type: 'text', name: 'new_issue_url', placeholder: 'New Issue url' } ] end diff --git a/app/models/project_services/gitlab_ci_service.rb b/app/models/project_services/gitlab_ci_service.rb index fadebf968bc..248f749b310 100644 --- a/app/models/project_services/gitlab_ci_service.rb +++ b/app/models/project_services/gitlab_ci_service.rb @@ -81,7 +81,7 @@ class GitlabCiService < CiService def fields [ { type: 'text', name: 'token', placeholder: 'GitLab CI project specific token' }, - { type: 'text', name: 'project_url', placeholder: 'http://ci.gitlabhq.com/projects/3'} + { type: 'text', name: 'project_url', placeholder: 'http://ci.gitlabhq.com/projects/3' } ] end end diff --git a/app/models/project_services/issue_tracker_service.rb b/app/models/project_services/issue_tracker_service.rb index acc8b33178c..b19c02bab44 100644 --- a/app/models/project_services/issue_tracker_service.rb +++ b/app/models/project_services/issue_tracker_service.rb @@ -44,8 +44,8 @@ class IssueTrackerService < Service [ { type: 'text', name: 'description', placeholder: description }, { type: 'text', name: 'project_url', placeholder: 'Project url' }, - { type: 'text', name: 'issues_url', placeholder: 'Issue url'}, - { type: 'text', name: 'new_issue_url', placeholder: 'New Issue url'} + { type: 'text', name: 'issues_url', placeholder: 'Issue url' }, + { type: 'text', name: 'new_issue_url', placeholder: 'New Issue url' } ] end diff --git a/app/models/project_wiki.rb b/app/models/project_wiki.rb index f8a28ca9866..55438bee245 100644 --- a/app/models/project_wiki.rb +++ b/app/models/project_wiki.rb @@ -136,7 +136,7 @@ class ProjectWiki def commit_details(action, message = nil, title = nil) commit_message = message || default_message(action, title) - {email: @user.email, name: @user.name, message: commit_message} + { email: @user.email, name: @user.name, message: commit_message } end def default_message(action, title) diff --git a/app/models/user.rb b/app/models/user.rb index 69fe674df83..27724b3ccba 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -113,9 +113,9 @@ class User < ActiveRecord::Base # Validations # validates :name, presence: true - validates :email, presence: true, email: {strict_mode: true}, uniqueness: true + validates :email, presence: true, email: { strict_mode: true }, uniqueness: true validates :bio, length: { maximum: 255 }, allow_blank: true - validates :projects_limit, presence: true, numericality: {greater_than_or_equal_to: 0} + validates :projects_limit, presence: true, numericality: { greater_than_or_equal_to: 0 } validates :username, presence: true, uniqueness: { case_sensitive: false }, exclusion: { in: Gitlab::Blacklist.path }, format: { with: Gitlab::Regex.username_regex, diff --git a/config/initializers/1_settings.rb b/config/initializers/1_settings.rb index 1ec842761ff..4296e755370 100644 --- a/config/initializers/1_settings.rb +++ b/config/initializers/1_settings.rb @@ -148,7 +148,7 @@ Settings.gitlab_shell['ssh_path_prefix'] ||= Settings.send(:build_gitlab_shell_s Settings['backup'] ||= Settingslogic.new({}) Settings.backup['keep_time'] ||= 0 Settings.backup['path'] = File.expand_path(Settings.backup['path'] || "tmp/backups/", Rails.root) -Settings.backup['upload'] ||= Settingslogic.new({'remote_directory' => nil, 'connection' => nil}) +Settings.backup['upload'] ||= Settingslogic.new({ 'remote_directory' => nil, 'connection' => nil }) # Convert upload connection settings to use symbol keys, to make Fog happy if Settings.backup['upload']['connection'] Settings.backup['upload']['connection'] = Hash[Settings.backup['upload']['connection'].map { |k, v| [k.to_sym, v] }] diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index 10dfc30a0c5..667f198667c 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -14,7 +14,7 @@ if File.exists?(aws_file) } config.fog_directory = AWS_CONFIG['bucket'] # required config.fog_public = false # optional, defaults to true - config.fog_attributes = {'Cache-Control'=>'max-age=315576000'} # optional, defaults to {} + config.fog_attributes = { 'Cache-Control'=>'max-age=315576000' } # optional, defaults to {} config.fog_authenticated_url_expiration = 1 << 29 # optional time (in seconds) that authenticated urls will be valid. # when fog_public is false and provider is AWS or Google, defaults to 600 end diff --git a/config/routes.rb b/config/routes.rb index 30df1ba0dfe..a83c112a882 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -177,7 +177,7 @@ Gitlab::Application.routes.draw do # # Groups Area # - resources :groups, constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} do + resources :groups, constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ } do member do get :issues get :merge_requests @@ -215,40 +215,40 @@ Gitlab::Application.routes.draw do scope module: :projects do # Blob routes: - get '/new/:id', to: 'blob#new', constraints: {id: /.+/}, as: 'new_blob' - post '/create/:id', to: 'blob#create', constraints: {id: /.+/}, as: 'create_blob' - get '/edit/:id', to: 'blob#edit', constraints: {id: /.+/}, as: 'edit_blob' - put '/update/:id', to: 'blob#update', constraints: {id: /.+/}, as: 'update_blob' - post '/preview/:id', to: 'blob#preview', constraints: {id: /.+/}, as: 'preview_blob' + get '/new/:id', to: 'blob#new', constraints: { id: /.+/ }, as: 'new_blob' + post '/create/:id', to: 'blob#create', constraints: { id: /.+/ }, as: 'create_blob' + get '/edit/:id', to: 'blob#edit', constraints: { id: /.+/ }, as: 'edit_blob' + put '/update/:id', to: 'blob#update', constraints: { id: /.+/ }, as: 'update_blob' + post '/preview/:id', to: 'blob#preview', constraints: { id: /.+/ }, as: 'preview_blob' resources :blob, only: [:show, :destroy], constraints: { id: /.+/, format: false } do get :diff, on: :member end - resources :raw, only: [:show], constraints: {id: /.+/} - resources :tree, only: [:show], constraints: {id: /.+/, format: /(html|js)/ } + resources :raw, only: [:show], constraints: { id: /.+/ } + resources :tree, only: [:show], constraints: { id: /.+/, format: /(html|js)/ } resource :avatar, only: [:show, :destroy] - resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} - resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} + resources :commit, only: [:show], constraints: { id: /[[:alnum:]]{6,40}/ } + resources :commits, only: [:show], constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ } resources :compare, only: [:index, :create] - resources :blame, only: [:show], constraints: {id: /.+/} - resources :network, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} - resources :graphs, only: [:show], constraints: {id: /(?:[^.]|\.(?!json$))+/, format: /json/} do + resources :blame, only: [:show], constraints: { id: /.+/ } + resources :network, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } + resources :graphs, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } do member do get :commits end end get '/compare/:from...:to' => 'compare#show', :as => 'compare', - :constraints => {from: /.+/, to: /.+/} + :constraints => { from: /.+/, to: /.+/ } - resources :snippets, constraints: {id: /\d+/} do + resources :snippets, constraints: { id: /\d+/ } do member do get 'raw' end end - resources :wikis, only: [:show, :edit, :destroy, :create], constraints: {id: /[a-zA-Z.0-9_\-\/]+/} do + resources :wikis, only: [:show, :edit, :destroy, :create], constraints: { id: /[a-zA-Z.0-9_\-\/]+/ } do collection do get :pages put ':id' => 'wikis#update' @@ -275,7 +275,7 @@ Gitlab::Application.routes.draw do end end - resources :deploy_keys, constraints: {id: /\d+/} do + resources :deploy_keys, constraints: { id: /\d+/ } do member do put :enable put :disable @@ -303,7 +303,7 @@ Gitlab::Application.routes.draw do end end - resources :merge_requests, constraints: {id: /\d+/}, except: [:destroy] do + resources :merge_requests, constraints: { id: /\d+/ }, except: [:destroy] do member do get :diffs post :automerge @@ -318,27 +318,27 @@ Gitlab::Application.routes.draw do end end - resources :hooks, only: [:index, :create, :destroy], constraints: {id: /\d+/} do + resources :hooks, only: [:index, :create, :destroy], constraints: { id: /\d+/ } do member do get :test end end resources :team, controller: 'team_members', only: [:index] - resources :milestones, except: [:destroy], constraints: {id: /\d+/} do + resources :milestones, except: [:destroy], constraints: { id: /\d+/ } do member do put :sort_issues put :sort_merge_requests end end - resources :labels, constraints: {id: /\d+/} do + resources :labels, constraints: { id: /\d+/ } do collection do post :generate end end - resources :issues, constraints: {id: /\d+/}, except: [:destroy] do + resources :issues, constraints: { id: /\d+/ }, except: [:destroy] do collection do post :bulk_update end @@ -355,7 +355,7 @@ Gitlab::Application.routes.draw do end end - resources :notes, only: [:index, :create, :destroy, :update], constraints: {id: /\d+/} do + resources :notes, only: [:index, :create, :destroy, :update], constraints: { id: /\d+/ } do member do delete :delete_attachment end @@ -364,7 +364,7 @@ Gitlab::Application.routes.draw do end end - get ':id' => 'namespaces#show', constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} + get ':id' => 'namespaces#show', constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ } root to: 'dashboard#show' end diff --git a/lib/api/api.rb b/lib/api/api.rb index cb46f477ff9..60858a39407 100644 --- a/lib/api/api.rb +++ b/lib/api/api.rb @@ -6,7 +6,7 @@ module API version 'v3', using: :path rescue_from ActiveRecord::RecordNotFound do - rack_response({'message' => '404 Not found'}.to_json, 404) + rack_response({ 'message' => '404 Not found' }.to_json, 404) end rescue_from :all do |exception| @@ -19,7 +19,7 @@ module API message << " " << trace.join("\n ") API.logger.add Logger::FATAL, message - rack_response({'message' => '500 Internal Server Error'}, 500) + rack_response({ 'message' => '500 Internal Server Error' }, 500) end format :json diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb index 28765b142f6..be3d053efca 100644 --- a/lib/api/api_guard.rb +++ b/lib/api/api_guard.rb @@ -146,7 +146,7 @@ module APIGuard Rack::OAuth2::Server::Resource::Bearer::Forbidden.new( :insufficient_scope, Rack::OAuth2::Server::Resource::ErrorMethods::DEFAULT_DESCRIPTION[:insufficient_scope], - { scope: e.scopes}) + { scope: e.scopes }) end response.finish diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 62c26ef76ce..1ded63d136f 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -173,7 +173,7 @@ module API end def render_api_error!(message, status) - error!({'message' => message}, status) + error!({ 'message' => message }, status) end private diff --git a/lib/api/project_members.rb b/lib/api/project_members.rb index 8e32f124ea5..1e890f9e199 100644 --- a/lib/api/project_members.rb +++ b/lib/api/project_members.rb @@ -106,7 +106,7 @@ module API unless team_member.nil? team_member.destroy else - {message: "Access revoked", id: params[:user_id].to_i} + { message: "Access revoked", id: params[:user_id].to_i } end end end diff --git a/lib/gitlab/backend/grack_auth.rb b/lib/gitlab/backend/grack_auth.rb index 2e393f753e8..3f207c56631 100644 --- a/lib/gitlab/backend/grack_auth.rb +++ b/lib/gitlab/backend/grack_auth.rb @@ -34,7 +34,7 @@ module Grack def auth! if @auth.provided? return bad_request unless @auth.basic? - + # Authentication with username and password login, password = @auth.credentials @@ -80,11 +80,11 @@ module Grack def authenticate_user(login, password) user = Gitlab::Auth.new.find(login, password) - + unless user user = oauth_access_token_check(login, password) end - + return user if user.present? # At this point, we know the credentials were wrong. We let Rack::Attack @@ -154,7 +154,7 @@ module Grack end def render_not_found - [404, {"Content-Type" => "text/plain"}, ["Not Found"]] + [404, { "Content-Type" => "text/plain" }, ["Not Found"]] end end end diff --git a/lib/gitlab/git_access_status.rb b/lib/gitlab/git_access_status.rb index 3d451ecebee..5a806ff6e0d 100644 --- a/lib/gitlab/git_access_status.rb +++ b/lib/gitlab/git_access_status.rb @@ -9,7 +9,7 @@ module Gitlab end def to_json - {status: @status, message: @message}.to_json + { status: @status, message: @message }.to_json end end -end \ No newline at end of file +end diff --git a/lib/gitlab/satellite/action.rb b/lib/gitlab/satellite/action.rb index be45cb5c98e..4890ccf21e6 100644 --- a/lib/gitlab/satellite/action.rb +++ b/lib/gitlab/satellite/action.rb @@ -44,7 +44,7 @@ module Gitlab end def default_options(options = {}) - {raise: true, timeout: true}.merge(options) + { raise: true, timeout: true }.merge(options) end def handle_exception(exception) diff --git a/lib/gitlab/satellite/files/delete_file_action.rb b/lib/gitlab/satellite/files/delete_file_action.rb index 30462999aa3..0d37b9dea85 100644 --- a/lib/gitlab/satellite/files/delete_file_action.rb +++ b/lib/gitlab/satellite/files/delete_file_action.rb @@ -13,7 +13,7 @@ module Gitlab prepare_satellite!(repo) # create target branch in satellite at the corresponding commit from bare repo - repo.git.checkout({raise: true, timeout: true, b: true}, ref, "origin/#{ref}") + repo.git.checkout({ raise: true, timeout: true, b: true }, ref, "origin/#{ref}") # update the file in the satellite's working dir file_path_in_satellite = File.join(repo.working_dir, file_path) @@ -36,7 +36,7 @@ module Gitlab # push commit back to bare repo # will raise CommandFailed when push fails - repo.git.push({raise: true, timeout: true}, :origin, ref) + repo.git.push({ raise: true, timeout: true }, :origin, ref) # everything worked true diff --git a/lib/gitlab/satellite/files/edit_file_action.rb b/lib/gitlab/satellite/files/edit_file_action.rb index cbdf70f7d12..2834b722b27 100644 --- a/lib/gitlab/satellite/files/edit_file_action.rb +++ b/lib/gitlab/satellite/files/edit_file_action.rb @@ -15,7 +15,7 @@ module Gitlab prepare_satellite!(repo) # create target branch in satellite at the corresponding commit from bare repo - repo.git.checkout({raise: true, timeout: true, b: true}, ref, "origin/#{ref}") + repo.git.checkout({ raise: true, timeout: true, b: true }, ref, "origin/#{ref}") # update the file in the satellite's working dir file_path_in_satellite = File.join(repo.working_dir, file_path) @@ -36,7 +36,7 @@ module Gitlab # push commit back to bare repo # will raise CommandFailed when push fails - repo.git.push({raise: true, timeout: true}, :origin, ref) + repo.git.push({ raise: true, timeout: true }, :origin, ref) # everything worked true diff --git a/lib/gitlab/satellite/files/new_file_action.rb b/lib/gitlab/satellite/files/new_file_action.rb index 5b657c7aba2..69f7ffa94e4 100644 --- a/lib/gitlab/satellite/files/new_file_action.rb +++ b/lib/gitlab/satellite/files/new_file_action.rb @@ -19,7 +19,7 @@ module Gitlab # skip this step if we want to add first file to empty repo Satellite::PARKING_BRANCH else - repo.git.checkout({raise: true, timeout: true, b: true}, ref, "origin/#{ref}") + repo.git.checkout({ raise: true, timeout: true, b: true }, ref, "origin/#{ref}") ref end @@ -47,7 +47,7 @@ module Gitlab # push commit back to bare repo # will raise CommandFailed when push fails - repo.git.push({raise: true, timeout: true}, :origin, "#{current_ref}:#{ref}") + repo.git.push({ raise: true, timeout: true }, :origin, "#{current_ref}:#{ref}") # everything worked true diff --git a/lib/gitlab/satellite/merge_action.rb b/lib/gitlab/satellite/merge_action.rb index e9141f735aa..25122666f5e 100644 --- a/lib/gitlab/satellite/merge_action.rb +++ b/lib/gitlab/satellite/merge_action.rb @@ -86,7 +86,7 @@ module Gitlab in_locked_and_timed_satellite do |merge_repo| prepare_satellite!(merge_repo) update_satellite_source_and_target!(merge_repo) - patch = merge_repo.git.format_patch(default_options({stdout: true}), "origin/#{merge_request.target_branch}..source/#{merge_request.source_branch}") + patch = merge_repo.git.format_patch(default_options({ stdout: true }), "origin/#{merge_request.target_branch}..source/#{merge_request.source_branch}") end rescue Grit::Git::CommandFailed => ex handle_exception(ex) @@ -128,7 +128,7 @@ module Gitlab # merge the source branch into the satellite # will raise CommandFailed when merge fails - repo.git.merge(default_options({no_ff: true}), "-m#{message}", "source/#{merge_request.source_branch}") + repo.git.merge(default_options({ no_ff: true }), "-m#{message}", "source/#{merge_request.source_branch}") rescue Grit::Git::CommandFailed => ex handle_exception(ex) end @@ -137,7 +137,7 @@ module Gitlab def update_satellite_source_and_target!(repo) repo.remote_add('source', merge_request.source_project.repository.path_to_repo) repo.remote_fetch('source') - repo.git.checkout(default_options({b: true}), merge_request.target_branch, "origin/#{merge_request.target_branch}") + repo.git.checkout(default_options({ b: true }), merge_request.target_branch, "origin/#{merge_request.target_branch}") rescue Grit::Git::CommandFailed => ex handle_exception(ex) end diff --git a/lib/gitlab/satellite/satellite.rb b/lib/gitlab/satellite/satellite.rb index 1de84309d15..62d1bb364d3 100644 --- a/lib/gitlab/satellite/satellite.rb +++ b/lib/gitlab/satellite/satellite.rb @@ -98,13 +98,13 @@ module Gitlab if heads.include? PARKING_BRANCH repo.git.checkout({}, PARKING_BRANCH) else - repo.git.checkout(default_options({b: true}), PARKING_BRANCH) + repo.git.checkout(default_options({ b: true }), PARKING_BRANCH) end # remove the parking branch from the list of heads ... heads.delete(PARKING_BRANCH) # ... and delete all others - heads.each { |head| repo.git.branch(default_options({D: true}), head) } + heads.each { |head| repo.git.branch(default_options({ D: true }), head) } end # Deletes all remotes except origin @@ -126,7 +126,7 @@ module Gitlab end def default_options(options = {}) - {raise: true, timeout: true}.merge(options) + { raise: true, timeout: true }.merge(options) end # Create directory for storing diff --git a/lib/gitlab/upgrader.rb b/lib/gitlab/upgrader.rb index 74b049b5143..0570c2fbeb5 100644 --- a/lib/gitlab/upgrader.rb +++ b/lib/gitlab/upgrader.rb @@ -62,7 +62,7 @@ module Gitlab end def env - {'RAILS_ENV' => 'production'} + { 'RAILS_ENV' => 'production' } end def upgrade -- cgit v1.2.1 From aaae5e6f5ebc61f724e901f26e928f5e3bd9eb88 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 20:55:05 -0800 Subject: Rubocop: Style/AccessorMethodName enabled --- .rubocop.yml | 2 +- app/services/projects/image_service.rb | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 17494974d14..ffc20fec4b2 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -1,7 +1,7 @@ Style/AccessModifierIndentation: Description: Check indentation of private/protected visibility modifiers. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-public-private-protected' - Enabled: false + Enabled: true Style/AccessorMethodName: Description: Check the naming of accessor methods for get_/set_. diff --git a/app/services/projects/image_service.rb b/app/services/projects/image_service.rb index c79ddddd972..7ca7e82c4a3 100644 --- a/app/services/projects/image_service.rb +++ b/app/services/projects/image_service.rb @@ -14,14 +14,14 @@ module Projects uploader.store!(image) link = { 'alt' => File.basename(alt, '.*'), - 'url' => File.join(@root_url, uploader.url) + 'url' => File.join(@root_url, uploader.url) } else link = nil end end - protected + protected def upload_path base_dir = FileUploader.generate_dir -- cgit v1.2.1 From 9fbdbf8b3fff72ae37a320e7e9fac3b9224e3c53 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 20:57:10 -0800 Subject: Rubocop: Style/Alias enabled --- .rubocop.yml | 2 +- app/models/wiki_page.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index ffc20fec4b2..c80c9bf907a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -10,7 +10,7 @@ Style/AccessorMethodName: Style/Alias: Description: 'Use alias_method instead of alias.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#alias-method' - Enabled: false + Enabled: true Style/AlignArray: Description: >- diff --git a/app/models/wiki_page.rb b/app/models/wiki_page.rb index b9ab6702c53..32981a0e664 100644 --- a/app/models/wiki_page.rb +++ b/app/models/wiki_page.rb @@ -43,7 +43,7 @@ class WikiPage @attributes[:slug] end - alias :to_param :slug + alias_method :to_param, :slug # The formatted title of this page. def title -- cgit v1.2.1 From c427bf08e41342957632289e084604f53e65e353 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 20:58:28 -0800 Subject: Rubocop: Style/AlignArray enabled --- .rubocop.yml | 2 +- lib/gitlab/diff/parser.rb | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c80c9bf907a..46634eb2337 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -17,7 +17,7 @@ Style/AlignArray: Align the elements of an array literal if they span more than one line. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#align-multiline-arrays' - Enabled: false + Enabled: true Style/AlignHash: Description: >- diff --git a/lib/gitlab/diff/parser.rb b/lib/gitlab/diff/parser.rb index f7c1f20d762..0242e09a515 100644 --- a/lib/gitlab/diff/parser.rb +++ b/lib/gitlab/diff/parser.rb @@ -4,7 +4,7 @@ module Gitlab include Enumerable def parse(lines) - @lines = lines, + @lines = lines lines_obj = [] line_obj_index = 0 line_old = 1 -- cgit v1.2.1 From cc39bca3fa71930421f1c46844b4d02d5ff93e8b Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:15:44 -0800 Subject: Rubocop: Style/AlignHash enabled --- .rubocop.yml | 2 +- app/controllers/projects/blob_controller.rb | 3 +-- app/helpers/application_helper.rb | 4 ++-- app/models/application_setting.rb | 3 ++- app/models/namespace.rb | 21 +++++++++++++-------- app/models/project.rb | 18 +++++++++++------- app/models/project_services/bamboo_service.rb | 18 ++++++++++++------ app/models/project_services/teamcity_service.rb | 15 +++++++++------ app/models/snippet.rb | 8 +++++--- app/models/user.rb | 10 ++++++---- config/routes.rb | 10 ++++------ lib/gitlab/ldap/adapter.rb | 6 ++++-- 12 files changed, 70 insertions(+), 48 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 46634eb2337..3c64374772a 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -23,7 +23,7 @@ Style/AlignHash: Description: >- Align the elements of a hash literal if they span more than one line. - Enabled: false + Enabled: true Style/AlignParameters: Description: >- diff --git a/app/controllers/projects/blob_controller.rb b/app/controllers/projects/blob_controller.rb index b471d57f698..dccb96ba1d1 100644 --- a/app/controllers/projects/blob_controller.rb +++ b/app/controllers/projects/blob_controller.rb @@ -59,8 +59,7 @@ class Projects::BlobController < Projects::ApplicationController def preview @content = params[:content] - diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', - include_diff_info: true) + diffy = Diffy::Diff.new(@blob.data, @content, diff: '-U 3', include_diff_info: true) @diff_lines = Gitlab::Diff::Parser.new.parse(diffy.diff.scan(/.*\n/)) render layout: false diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index d00f1aac2d6..7417261a847 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -75,9 +75,9 @@ module ApplicationHelper options[:class] ||= '' options[:class] << ' identicon' bg_key = project.id % 7 + style = "background-color: ##{ allowed_colors.values[bg_key] }; color: #555" - content_tag(:div, class: options[:class], - style: "background-color: ##{ allowed_colors.values[bg_key] }; color: #555") do + content_tag(:div, class: options[:class], style: style) do project.name[0, 1].upcase end end diff --git a/app/models/application_setting.rb b/app/models/application_setting.rb index 45ae79a75cc..0b3d430add0 100644 --- a/app/models/application_setting.rb +++ b/app/models/application_setting.rb @@ -14,7 +14,8 @@ # class ApplicationSetting < ActiveRecord::Base - validates :home_page_url, allow_blank: true, + validates :home_page_url, + allow_blank: true, format: { with: URI::regexp(%w(http https)), message: "should be a valid url" }, if: :home_page_url_column_exist diff --git a/app/models/namespace.rb b/app/models/namespace.rb index ea4b48fdd7f..e7fd3024750 100644 --- a/app/models/namespace.rb +++ b/app/models/namespace.rb @@ -20,15 +20,20 @@ class Namespace < ActiveRecord::Base belongs_to :owner, class_name: "User" validates :owner, presence: true, unless: ->(n) { n.type == "Group" } - validates :name, presence: true, uniqueness: true, - length: { within: 0..255 }, - format: { with: Gitlab::Regex.name_regex, - message: Gitlab::Regex.name_regex_message } + validates :name, + presence: true, uniqueness: true, + length: { within: 0..255 }, + format: { with: Gitlab::Regex.name_regex, + message: Gitlab::Regex.name_regex_message } + validates :description, length: { within: 0..255 } - validates :path, uniqueness: { case_sensitive: false }, presence: true, length: { within: 1..255 }, - exclusion: { in: Gitlab::Blacklist.path }, - format: { with: Gitlab::Regex.path_regex, - message: Gitlab::Regex.path_regex_message } + validates :path, + uniqueness: { case_sensitive: false }, + presence: true, + length: { within: 1..255 }, + exclusion: { in: Gitlab::Blacklist.path }, + format: { with: Gitlab::Regex.path_regex, + message: Gitlab::Regex.path_regex_message } delegate :name, to: :owner, allow_nil: true, prefix: true diff --git a/app/models/project.rb b/app/models/project.rb index f314ed9bd25..cfe40553ab5 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -108,13 +108,17 @@ class Project < ActiveRecord::Base # Validations validates :creator, presence: true, on: :create validates :description, length: { maximum: 2000 }, allow_blank: true - validates :name, presence: true, length: { within: 0..255 }, - format: { with: Gitlab::Regex.project_name_regex, - message: Gitlab::Regex.project_regex_message } - validates :path, presence: true, length: { within: 0..255 }, - exclusion: { in: Gitlab::Blacklist.path }, - format: { with: Gitlab::Regex.path_regex, - message: Gitlab::Regex.path_regex_message } + validates :name, + presence: true, + length: { within: 0..255 }, + format: { with: Gitlab::Regex.project_name_regex, + message: Gitlab::Regex.project_regex_message } + validates :path, + presence: true, + length: { within: 0..255 }, + exclusion: { in: Gitlab::Blacklist.path }, + format: { with: Gitlab::Regex.path_regex, + message: Gitlab::Regex.path_regex_message } validates :issues_enabled, :merge_requests_enabled, :wiki_enabled, inclusion: { in: [true, false] } validates :visibility_level, diff --git a/app/models/project_services/bamboo_service.rb b/app/models/project_services/bamboo_service.rb index 16e1b83da4b..745609e5911 100644 --- a/app/models/project_services/bamboo_service.rb +++ b/app/models/project_services/bamboo_service.rb @@ -17,13 +17,19 @@ class BambooService < CiService prop_accessor :bamboo_url, :build_key, :username, :password - validates :bamboo_url, presence: true, - format: { with: URI::regexp }, if: :activated? + validates :bamboo_url, + presence: true, + format: { with: URI::regexp }, + if: :activated? validates :build_key, presence: true, if: :activated? - validates :username, presence: true, - if: ->(service) { service.password? }, if: :activated? - validates :password, presence: true, - if: ->(service) { service.username? }, if: :activated? + validates :username, + presence: true, + if: ->(service) { service.password? }, + if: :activated? + validates :password, + presence: true, + if: ->(service) { service.username? }, + if: :activated? attr_accessor :response diff --git a/app/models/project_services/teamcity_service.rb b/app/models/project_services/teamcity_service.rb index dca718b5e8c..287f5c0e84e 100644 --- a/app/models/project_services/teamcity_service.rb +++ b/app/models/project_services/teamcity_service.rb @@ -17,13 +17,16 @@ class TeamcityService < CiService prop_accessor :teamcity_url, :build_type, :username, :password - validates :teamcity_url, presence: true, - format: { with: URI::regexp }, if: :activated? + validates :teamcity_url, + presence: true, + format: { with: URI::regexp }, if: :activated? validates :build_type, presence: true, if: :activated? - validates :username, presence: true, - if: ->(service) { service.password? }, if: :activated? - validates :password, presence: true, - if: ->(service) { service.username? }, if: :activated? + validates :username, + presence: true, + if: ->(service) { service.password? }, if: :activated? + validates :password, + presence: true, + if: ->(service) { service.username? }, if: :activated? attr_accessor :response diff --git a/app/models/snippet.rb b/app/models/snippet.rb index 9aba42a0622..a3222d29892 100644 --- a/app/models/snippet.rb +++ b/app/models/snippet.rb @@ -29,9 +29,11 @@ class Snippet < ActiveRecord::Base validates :author, presence: true validates :title, presence: true, length: { within: 0..255 } - validates :file_name, presence: true, length: { within: 0..255 }, - format: { with: Gitlab::Regex.path_regex, - message: Gitlab::Regex.path_regex_message } + validates :file_name, + presence: true, + length: { within: 0..255 }, + format: { with: Gitlab::Regex.path_regex, + message: Gitlab::Regex.path_regex_message } validates :content, presence: true validates :visibility_level, inclusion: { in: Gitlab::VisibilityLevel.values } diff --git a/app/models/user.rb b/app/models/user.rb index 27724b3ccba..552a37c9533 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -116,10 +116,12 @@ class User < ActiveRecord::Base validates :email, presence: true, email: { strict_mode: true }, uniqueness: true validates :bio, length: { maximum: 255 }, allow_blank: true validates :projects_limit, presence: true, numericality: { greater_than_or_equal_to: 0 } - validates :username, presence: true, uniqueness: { case_sensitive: false }, - exclusion: { in: Gitlab::Blacklist.path }, - format: { with: Gitlab::Regex.username_regex, - message: Gitlab::Regex.username_regex_message } + validates :username, + presence: true, + uniqueness: { case_sensitive: false }, + exclusion: { in: Gitlab::Blacklist.path }, + format: { with: Gitlab::Regex.username_regex, + message: Gitlab::Regex.username_regex_message } validates :notification_level, inclusion: { in: Notification.notification_levels }, presence: true validate :namespace_uniq, if: ->(user) { user.username_changed? } diff --git a/config/routes.rb b/config/routes.rb index a83c112a882..a2d782cf633 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -294,12 +294,10 @@ Gitlab::Application.routes.draw do member do # tree viewer logs 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, - path: /.*/ - } + get 'logs_tree/:path' => 'refs#logs_tree', as: :logs_file, constraints: { + id: Gitlab::Regex.git_reference_regex, + path: /.*/ + } end end diff --git a/lib/gitlab/ldap/adapter.rb b/lib/gitlab/ldap/adapter.rb index 256cdb4c2f1..577a890a7d9 100644 --- a/lib/gitlab/ldap/adapter.rb +++ b/lib/gitlab/ldap/adapter.rb @@ -63,8 +63,10 @@ module Gitlab end def dn_matches_filter?(dn, filter) - ldap_search(base: dn, filter: filter, - scope: Net::LDAP::SearchScope_BaseObject, attributes: %w{dn}).any? + ldap_search(base: dn, + filter: filter, + scope: Net::LDAP::SearchScope_BaseObject, + attributes: %w{dn}).any? end def ldap_search(*args) -- cgit v1.2.1 From 6579c336f96b00bb7897f7cbf2056286c1781281 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:20:34 -0800 Subject: Rubocop: Ascii restrictions --- .rubocop.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 3c64374772a..c3f3d7bca66 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -45,12 +45,12 @@ Style/ArrayJoin: Style/AsciiComments: Description: 'Use only ascii symbols in comments.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-comments' - Enabled: false + Enabled: true Style/AsciiIdentifiers: Description: 'Use only ascii symbols in identifiers.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#english-identifiers' - Enabled: false + Enabled: true Style/Attr: Description: 'Checks for uses of Module#attr.' -- cgit v1.2.1 From da884aabc7674c68eee23699efb357bc94aef8d3 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:22:57 -0800 Subject: Avoid using {...} for multi-line blocks --- .rubocop.yml | 4 ++-- lib/api/api_guard.rb | 4 ++-- lib/api/internal.rb | 4 +--- lib/api/namespaces.rb | 4 ++-- lib/api/system_hooks.rb | 4 ++-- 5 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c3f3d7bca66..319efe7e0dc 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -74,7 +74,7 @@ Style/BlockComments: Style/BlockEndNewline: Description: 'Put end statement of multiline block on its own line.' - Enabled: false + Enabled: true Style/Blocks: Description: >- @@ -82,7 +82,7 @@ Style/Blocks: always ugly). Prefer {...} over do...end for single-line blocks. StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#single-line-blocks' - Enabled: false + Enabled: true Style/BracesAroundHashParameters: Description: 'Enforce braces style around hash parameters.' diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb index be3d053efca..cb20bf0720d 100644 --- a/lib/api/api_guard.rb +++ b/lib/api/api_guard.rb @@ -120,7 +120,7 @@ module APIGuard end def oauth2_bearer_token_error_handler - Proc.new {|e| + Proc.new do |e| response = case e when MissingTokenError Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new @@ -150,7 +150,7 @@ module APIGuard end response.finish - } + end end end diff --git a/lib/api/internal.rb b/lib/api/internal.rb index a999cff09c0..7a89a26facc 100644 --- a/lib/api/internal.rb +++ b/lib/api/internal.rb @@ -1,9 +1,7 @@ module API # Internal access API class Internal < Grape::API - before { - authenticate_by_gitlab_shell_token! - } + before { authenticate_by_gitlab_shell_token! } namespace 'internal' do # Check if git command is allowed to project diff --git a/lib/api/namespaces.rb b/lib/api/namespaces.rb index f9f2ed90ccc..b90ed6af5fb 100644 --- a/lib/api/namespaces.rb +++ b/lib/api/namespaces.rb @@ -1,10 +1,10 @@ module API # namespaces API class Namespaces < Grape::API - before { + before do authenticate! authenticated_as_admin! - } + end resource :namespaces do # Get a namespaces list diff --git a/lib/api/system_hooks.rb b/lib/api/system_hooks.rb index 3e239c5afe7..518964db50d 100644 --- a/lib/api/system_hooks.rb +++ b/lib/api/system_hooks.rb @@ -1,10 +1,10 @@ module API # Hooks API class SystemHooks < Grape::API - before { + before do authenticate! authenticated_as_admin! - } + end resource :hooks do # Get the list of system hooks -- cgit v1.2.1 From 368e9a0862dd7d58b009956e8f1ac51d2a549cda Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:26:40 -0800 Subject: Rubocop: Style/CaseIndentation enabled --- .rubocop.yml | 2 +- app/finders/notes_finder.rb | 25 +++++++++++++------------ lib/api/api_guard.rb | 7 ++----- 3 files changed, 16 insertions(+), 18 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 319efe7e0dc..923ea00a106 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -96,7 +96,7 @@ Style/CaseEquality: Style/CaseIndentation: Description: 'Indentation of when in a case/when/[else/]end.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#indent-when-to-case' - Enabled: false + Enabled: true Style/CharacterLiteral: Description: 'Checks for uses of character literals.' diff --git a/app/finders/notes_finder.rb b/app/finders/notes_finder.rb index bef82d7f0fd..6fe15b41060 100644 --- a/app/finders/notes_finder.rb +++ b/app/finders/notes_finder.rb @@ -7,18 +7,19 @@ class NotesFinder # Default to 0 to remain compatible with old clients last_fetched_at = Time.at(params.fetch(:last_fetched_at, 0).to_i) - notes = case target_type - when "commit" - project.notes.for_commit_id(target_id).not_inline.fresh - when "issue" - project.issues.find(target_id).notes.inc_author.fresh - when "merge_request" - project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh - when "snippet", "project_snippet" - project.snippets.find(target_id).notes.fresh - else - raise 'invalid target_type' - end + notes = + case target_type + when "commit" + project.notes.for_commit_id(target_id).not_inline.fresh + when "issue" + project.issues.find(target_id).notes.inc_author.fresh + when "merge_request" + project.merge_requests.find(target_id).mr_and_commit_notes.inc_author.fresh + when "snippet", "project_snippet" + project.snippets.find(target_id).notes.fresh + else + raise 'invalid target_type' + end # Use overlapping intervals to avoid worrying about race conditions notes.where('updated_at > ?', last_fetched_at - FETCH_OVERLAP) diff --git a/lib/api/api_guard.rb b/lib/api/api_guard.rb index cb20bf0720d..b9994fcefda 100644 --- a/lib/api/api_guard.rb +++ b/lib/api/api_guard.rb @@ -47,16 +47,12 @@ module APIGuard case validate_access_token(access_token, scopes) when Oauth2::AccessTokenValidationService::INSUFFICIENT_SCOPE raise InsufficientScopeError.new(scopes) - when Oauth2::AccessTokenValidationService::EXPIRED raise ExpiredError - when Oauth2::AccessTokenValidationService::REVOKED raise RevokedError - when Oauth2::AccessTokenValidationService::VALID @current_user = User.find(access_token.resource_owner_id) - end end end @@ -121,7 +117,8 @@ module APIGuard def oauth2_bearer_token_error_handler Proc.new do |e| - response = case e + response = + case e when MissingTokenError Rack::OAuth2::Server::Resource::Bearer::Unauthorized.new -- cgit v1.2.1 From 7558fe98759ec28c2fd97ae10cb1610a1a6c38cd Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:31:03 -0800 Subject: More rubocop rules enable --- .rubocop.yml | 9 +++++---- lib/email_validator.rb | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 923ea00a106..c1a5d06770f 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -60,7 +60,7 @@ Style/Attr: Style/BeginBlock: Description: 'Avoid the use of BEGIN blocks.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-BEGIN-blocks' - Enabled: false + Enabled: true Style/BarePercentLiterals: Description: 'Checks if usage of %() or %Q() matches configuration.' @@ -101,12 +101,12 @@ Style/CaseIndentation: Style/CharacterLiteral: Description: 'Checks for uses of character literals.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-character-literals' - Enabled: false + Enabled: true Style/ClassAndModuleCamelCase: Description: 'Use CamelCase for classes and modules.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#camelcase-classes' - Enabled: false + Enabled: true Style/ClassAndModuleChildren: Description: 'Checks style of children classes and modules.' @@ -124,7 +124,7 @@ Style/ClassMethods: Style/ClassVars: Description: 'Avoid the use of class variables.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#no-class-vars' - Enabled: false + Enabled: true Style/ColonMethodCall: Description: 'Do not use :: for method call.' @@ -1000,3 +1000,4 @@ AllCops: - 'bin/**/*' - 'lib/backup/**/*' - 'lib/tasks/**/*' + - 'lib/email_validator.rb' diff --git a/lib/email_validator.rb b/lib/email_validator.rb index 0a67ebcd795..f509f0a5843 100644 --- a/lib/email_validator.rb +++ b/lib/email_validator.rb @@ -1,5 +1,5 @@ # Based on https://github.com/balexand/email_validator -# +# # Extended to use only strict mode with following allowed characters: # ' - apostrophe # -- cgit v1.2.1 From 7d48205c1a472c07969e4dc43965fa3090b84376 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:34:16 -0800 Subject: Rubocop: comment indentation --- .rubocop.yml | 2 +- app/helpers/notes_helper.rb | 2 +- config/initializers/carrierwave.rb | 18 +++++++++++++----- lib/gitlab/git_access.rb | 2 +- 4 files changed, 16 insertions(+), 8 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index c1a5d06770f..369e55abcdb 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -140,7 +140,7 @@ Style/CommentAnnotation: Style/CommentIndentation: Description: 'Indentation of comments.' - Enabled: false + Enabled: true Style/ConstantName: Description: 'Constants should use SCREAMING_SNAKE_CASE.' diff --git a/app/helpers/notes_helper.rb b/app/helpers/notes_helper.rb index d41d5617396..8edcb8e6a80 100644 --- a/app/helpers/notes_helper.rb +++ b/app/helpers/notes_helper.rb @@ -1,5 +1,5 @@ module NotesHelper - # Helps to distinguish e.g. commit notes in mr notes list + # Helps to distinguish e.g. commit notes in mr notes list def note_for_main_target?(note) (@noteable.class.name == note.noteable_type && !note.for_diff_line?) end diff --git a/config/initializers/carrierwave.rb b/config/initializers/carrierwave.rb index 667f198667c..bfb8656df55 100644 --- a/config/initializers/carrierwave.rb +++ b/config/initializers/carrierwave.rb @@ -12,11 +12,19 @@ if File.exists?(aws_file) aws_secret_access_key: AWS_CONFIG['secret_access_key'], # required region: AWS_CONFIG['region'], # optional, defaults to 'us-east-1' } - config.fog_directory = AWS_CONFIG['bucket'] # required - config.fog_public = false # optional, defaults to true - config.fog_attributes = { 'Cache-Control'=>'max-age=315576000' } # optional, defaults to {} - config.fog_authenticated_url_expiration = 1 << 29 # optional time (in seconds) that authenticated urls will be valid. - # when fog_public is false and provider is AWS or Google, defaults to 600 + + # required + config.fog_directory = AWS_CONFIG['bucket'] + + # optional, defaults to true + config.fog_public = false + + # optional, defaults to {} + config.fog_attributes = { 'Cache-Control'=>'max-age=315576000' } + + # optional time (in seconds) that authenticated urls will be valid. + # when fog_public is false and provider is AWS or Google, defaults to 600 + config.fog_authenticated_url_expiration = 1 << 29 end # Mocking Fog requests, based on: https://github.com/carrierwaveuploader/carrierwave/wiki/How-to%3A-Test-Fog-based-uploaders diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index ea96d04c5ab..0530923b202 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -113,8 +113,8 @@ module Gitlab # we dont allow force push to protected branch if forced_push?(project, oldrev, newrev) :force_push_code_to_protected_branches - # and we dont allow remove of protected branch elsif newrev == Gitlab::Git::BLANK_SHA + # and we dont allow remove of protected branch :remove_protected_branches elsif project.developers_can_push_to_protected_branch?(branch_name) :push_code -- cgit v1.2.1 From 647ff6240ef5e8256a44b126aa7573812d5e70b7 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:38:50 -0800 Subject: Rubocop: Style/ElseAlignment enabled --- .rubocop.yml | 4 ++-- app/controllers/projects/refs_controller.rb | 8 ++++---- app/helpers/commits_helper.rb | 13 +++++++------ app/models/commit.rb | 11 ++++++----- app/services/projects/participants_service.rb | 11 ++++++----- config/initializers/acts_as_taggable_on_patch.rb | 11 ++++++----- 6 files changed, 31 insertions(+), 27 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 369e55abcdb..c14303ab1f8 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -145,7 +145,7 @@ Style/CommentIndentation: Style/ConstantName: Description: 'Constants should use SCREAMING_SNAKE_CASE.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#screaming-snake-case' - Enabled: false + Enabled: true Style/DefWithParentheses: Description: 'Use def with parentheses when there are arguments.' @@ -177,7 +177,7 @@ Style/EachWithObject: Style/ElseAlignment: Description: 'Align elses and elsifs correctly.' - Enabled: false + Enabled: true Style/EmptyElse: Description: 'Avoid empty else-clauses.' diff --git a/app/controllers/projects/refs_controller.rb b/app/controllers/projects/refs_controller.rb index cede0ebe0ae..b80472f8eb4 100644 --- a/app/controllers/projects/refs_controller.rb +++ b/app/controllers/projects/refs_controller.rb @@ -31,10 +31,10 @@ class Projects::RefsController < Projects::ApplicationController def logs_tree @offset = if params[:offset].present? - params[:offset].to_i - else - 0 - end + params[:offset].to_i + else + 0 + end @limit = 25 diff --git a/app/helpers/commits_helper.rb b/app/helpers/commits_helper.rb index 1a322ac048f..b4ba14160ed 100644 --- a/app/helpers/commits_helper.rb +++ b/app/helpers/commits_helper.rb @@ -112,12 +112,13 @@ module CommitsHelper person_name = user.nil? ? source_name : user.name person_email = user.nil? ? source_email : user.email - text = if options[:avatar] - avatar = image_tag(avatar_icon(person_email, options[:size]), class: "avatar #{"s#{options[:size]}" if options[:size]}", width: options[:size], alt: "") - %Q{#{avatar} #{person_name}} - else - person_name - end + text = + if options[:avatar] + avatar = image_tag(avatar_icon(person_email, options[:size]), class: "avatar #{"s#{options[:size]}" if options[:size]}", width: options[:size], alt: "") + %Q{#{avatar} #{person_name}} + else + person_name + end options = { class: "commit-#{options[:source]}-link has_tooltip", diff --git a/app/models/commit.rb b/app/models/commit.rb index baccf286740..e0461809e10 100644 --- a/app/models/commit.rb +++ b/app/models/commit.rb @@ -88,11 +88,12 @@ class Commit # cut off, ellipses (`&hellp;`) are prepended to the commit message. def description title_end = safe_message.index("\n") - @description ||= if (!title_end && safe_message.length > 100) || (title_end && title_end > 100) - "…".html_safe << safe_message[80..-1] - else - safe_message.split("\n", 2)[1].try(:chomp) - end + @description ||= + if (!title_end && safe_message.length > 100) || (title_end && title_end > 100) + "…".html_safe << safe_message[80..-1] + else + safe_message.split("\n", 2)[1].try(:chomp) + end end def description? diff --git a/app/services/projects/participants_service.rb b/app/services/projects/participants_service.rb index c4d2c0963b7..e3b33de8d02 100644 --- a/app/services/projects/participants_service.rb +++ b/app/services/projects/participants_service.rb @@ -5,11 +5,12 @@ module Projects end def execute(note_type, note_id) - participating = if note_type && note_id - participants_in(note_type, note_id) - else - [] - end + participating = + if note_type && note_id + participants_in(note_type, note_id) + else + [] + end team_members = sorted(@project.team.members) participants = all_members + team_members + participating participants.uniq diff --git a/config/initializers/acts_as_taggable_on_patch.rb b/config/initializers/acts_as_taggable_on_patch.rb index baa77fde392..e7a7728636d 100644 --- a/config/initializers/acts_as_taggable_on_patch.rb +++ b/config/initializers/acts_as_taggable_on_patch.rb @@ -42,11 +42,12 @@ module ActsAsTaggableOn::Taggable elsif options.delete(:any) # get tags, drop out if nothing returned (we need at least one) - tags = if options.delete(:wild) - ActsAsTaggableOn::Tag.named_like_any(tag_list) - else - ActsAsTaggableOn::Tag.named_any(tag_list) - end + tags = + if options.delete(:wild) + ActsAsTaggableOn::Tag.named_like_any(tag_list) + else + ActsAsTaggableOn::Tag.named_any(tag_list) + end return empty_result unless tags.length > 0 -- cgit v1.2.1 From 615bb941358389a1fdfec34abc6af8b61db75580 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:41:38 -0800 Subject: Rubocop: Dont allow puts or print to stdout --- .rubocop.yml | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/.rubocop.yml b/.rubocop.yml index c14303ab1f8..1b62416f74c 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -970,7 +970,7 @@ Rails/HasAndBelongsToMany: Rails/Output: Description: 'Checks for calls to puts, print, etc.' - Enabled: false + Enabled: true Rails/ReadWriteAttribute: Description: >- @@ -991,6 +991,7 @@ Rails/Validation: # # AllCops: + RunRailsCops: true Exclude: - 'spec/**/*' - 'features/**/*' @@ -1001,3 +1002,5 @@ AllCops: - 'lib/backup/**/*' - 'lib/tasks/**/*' - 'lib/email_validator.rb' + - 'lib/gitlab/upgrader.rb' + - 'lib/gitlab/seeder.rb' -- cgit v1.2.1 From d04344373b899c1e54948ca46478f7b907a576d2 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:53:27 -0800 Subject: Rubocop: no trailing newlines --- .rubocop.yml | 6 +++--- app/controllers/namespaces_controller.rb | 1 - app/controllers/projects/raw_controller.rb | 1 - app/helpers/projects_helper.rb | 1 - app/services/oauth2/access_token_validation_service.rb | 2 +- config/initializers/7_omniauth.rb | 2 +- config/initializers/gitlab_shell_secret_token.rb | 2 +- lib/gitlab/backend/shell_adapter.rb | 1 - lib/gitlab/force_push_check.rb | 1 - 9 files changed, 6 insertions(+), 11 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 1b62416f74c..965a52c7552 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -657,7 +657,7 @@ Style/Tab: Style/TrailingBlankLines: Description: 'Checks trailing blank lines and final newline.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#newline-eof' - Enabled: false + Enabled: true Style/TrailingComma: Description: 'Checks for trailing comma in parameter lists and literals.' @@ -909,7 +909,7 @@ Lint/StringConversionInInterpolation: Lint/UnderscorePrefixedVariableName: Description: 'Do not use prefix `_` for a variable that is used.' - Enabled: false + Enabled: true Lint/UnusedBlockArgument: Description: 'Checks for unused block arguments.' @@ -966,7 +966,7 @@ Rails/Delegate: Rails/HasAndBelongsToMany: Description: 'Prefer has_many :through to has_and_belongs_to_many.' - Enabled: false + Enabled: true Rails/Output: Description: 'Checks for calls to puts, print, etc.' diff --git a/app/controllers/namespaces_controller.rb b/app/controllers/namespaces_controller.rb index c59a2401cef..b7a9d8c1291 100644 --- a/app/controllers/namespaces_controller.rb +++ b/app/controllers/namespaces_controller.rb @@ -15,4 +15,3 @@ class NamespacesController < ApplicationController end end end - diff --git a/app/controllers/projects/raw_controller.rb b/app/controllers/projects/raw_controller.rb index 84888265dc1..c4ddc32e8c3 100644 --- a/app/controllers/projects/raw_controller.rb +++ b/app/controllers/projects/raw_controller.rb @@ -35,4 +35,3 @@ class Projects::RawController < Projects::ApplicationController end end end - diff --git a/app/helpers/projects_helper.rb b/app/helpers/projects_helper.rb index 687b087e683..5cec6ae99d8 100644 --- a/app/helpers/projects_helper.rb +++ b/app/helpers/projects_helper.rb @@ -254,4 +254,3 @@ module ProjectsHelper enabled_oauth_providers.include?(:github) end end - diff --git a/app/services/oauth2/access_token_validation_service.rb b/app/services/oauth2/access_token_validation_service.rb index 5a3b94129f1..6194f6ce91e 100644 --- a/app/services/oauth2/access_token_validation_service.rb +++ b/app/services/oauth2/access_token_validation_service.rb @@ -38,4 +38,4 @@ module Oauth2::AccessTokenValidationService end end end -end \ No newline at end of file +end diff --git a/config/initializers/7_omniauth.rb b/config/initializers/7_omniauth.rb index 18759f0cfb0..8f6c5673103 100644 --- a/config/initializers/7_omniauth.rb +++ b/config/initializers/7_omniauth.rb @@ -9,4 +9,4 @@ if Gitlab::LDAP::Config.enabled? server = Gitlab.config.ldap.servers.values.first alias_method server['provider_name'], :ldap end -end \ No newline at end of file +end diff --git a/config/initializers/gitlab_shell_secret_token.rb b/config/initializers/gitlab_shell_secret_token.rb index 8d2b771e535..e7c9f0ba7c2 100644 --- a/config/initializers/gitlab_shell_secret_token.rb +++ b/config/initializers/gitlab_shell_secret_token.rb @@ -16,4 +16,4 @@ end if File.exist?(Gitlab.config.gitlab_shell.path) && !File.exist?(gitlab_shell_symlink) FileUtils.symlink(secret_file, gitlab_shell_symlink) -end \ No newline at end of file +end diff --git a/lib/gitlab/backend/shell_adapter.rb b/lib/gitlab/backend/shell_adapter.rb index f247f4593d7..fbe2a7a0d72 100644 --- a/lib/gitlab/backend/shell_adapter.rb +++ b/lib/gitlab/backend/shell_adapter.rb @@ -9,4 +9,3 @@ module Gitlab end end end - diff --git a/lib/gitlab/force_push_check.rb b/lib/gitlab/force_push_check.rb index 6ba2c3ad00a..eae9773a067 100644 --- a/lib/gitlab/force_push_check.rb +++ b/lib/gitlab/force_push_check.rb @@ -12,4 +12,3 @@ module Gitlab end end end - -- cgit v1.2.1 From 61cc6a9244f316f684cd887febd9dae1030a04b0 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Mon, 2 Feb 2015 21:59:28 -0800 Subject: Rubocop: indentation fixes Yay!!! --- .rubocop.yml | 4 ++-- app/controllers/projects/wikis_controller.rb | 20 ++++++++++---------- app/finders/snippets_finder.rb | 2 +- app/helpers/application_helper.rb | 2 +- app/helpers/tab_helper.rb | 2 +- config/initializers/acts_as_taggable_on_patch.rb | 24 ++++++++++++------------ lib/gitlab/diff/parser.rb | 2 +- lib/gitlab/git_access.rb | 10 +++++----- 8 files changed, 33 insertions(+), 33 deletions(-) diff --git a/.rubocop.yml b/.rubocop.yml index 965a52c7552..a4b51008194 100644 --- a/.rubocop.yml +++ b/.rubocop.yml @@ -283,12 +283,12 @@ Style/IfWithSemicolon: Style/IndentationConsistency: Description: 'Keep indentation straight.' - Enabled: false + Enabled: true Style/IndentationWidth: Description: 'Use 2 spaces for indentation.' StyleGuide: 'https://github.com/bbatsov/ruby-style-guide#spaces-indentation' - Enabled: false + Enabled: true Style/IndentArray: Description: >- diff --git a/app/controllers/projects/wikis_controller.rb b/app/controllers/projects/wikis_controller.rb index 0e03956e738..0145207bf6f 100644 --- a/app/controllers/projects/wikis_controller.rb +++ b/app/controllers/projects/wikis_controller.rb @@ -16,16 +16,16 @@ class Projects::WikisController < Projects::ApplicationController if @page render 'show' elsif file = @project_wiki.find_file(params[:id], params[:version_id]) - if file.on_disk? - send_file file.on_disk_path, disposition: 'inline' - else - send_data( - file.raw_data, - type: file.mime_type, - disposition: 'inline', - filename: file.name - ) - end + if file.on_disk? + send_file file.on_disk_path, disposition: 'inline' + else + send_data( + file.raw_data, + type: file.mime_type, + disposition: 'inline', + filename: file.name + ) + end else return render('empty') unless can?(current_user, :write_wiki, @project) @page = WikiPage.new(@project_wiki) diff --git a/app/finders/snippets_finder.rb b/app/finders/snippets_finder.rb index 4b0c69f2d2f..07b5759443b 100644 --- a/app/finders/snippets_finder.rb +++ b/app/finders/snippets_finder.rb @@ -40,7 +40,7 @@ class SnippetsFinder when 'are_public' then snippets.are_public else - snippets + snippets end else snippets.public_and_internal diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 7417261a847..1fbb44ee442 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -78,7 +78,7 @@ module ApplicationHelper style = "background-color: ##{ allowed_colors.values[bg_key] }; color: #555" content_tag(:div, class: options[:class], style: style) do - project.name[0, 1].upcase + project.name[0, 1].upcase end end diff --git a/app/helpers/tab_helper.rb b/app/helpers/tab_helper.rb index 639fc98c222..2142db29925 100644 --- a/app/helpers/tab_helper.rb +++ b/app/helpers/tab_helper.rb @@ -90,7 +90,7 @@ module TabHelper return "active" if current_page?(controller: "/projects", action: :edit, id: @project) if ['services', 'hooks', 'deploy_keys', 'team_members', 'protected_branches'].include? controller.controller_name - "active" + "active" end end diff --git a/config/initializers/acts_as_taggable_on_patch.rb b/config/initializers/acts_as_taggable_on_patch.rb index e7a7728636d..0d535cb5cac 100644 --- a/config/initializers/acts_as_taggable_on_patch.rb +++ b/config/initializers/acts_as_taggable_on_patch.rb @@ -69,12 +69,12 @@ module ActsAsTaggableOn::Taggable select_clause = "DISTINCT #{table_name}.*" unless context and tag_types.one? if owned_by - tagging_join << " AND " + - sanitize_sql([ - "#{taggings_alias}.tagger_id = ? AND #{taggings_alias}.tagger_type = ?", - owned_by.id, - owned_by.class.base_class.to_s - ]) + tagging_join << " AND " + + sanitize_sql([ + "#{taggings_alias}.tagger_id = ? AND #{taggings_alias}.tagger_type = ?", + owned_by.id, + owned_by.class.base_class.to_s + ]) end joins << tagging_join @@ -93,12 +93,12 @@ module ActsAsTaggableOn::Taggable tagging_join << " AND " + sanitize_sql(["#{taggings_alias}.context = ?", context.to_s]) if context if owned_by - tagging_join << " AND " + - sanitize_sql([ - "#{taggings_alias}.tagger_id = ? AND #{taggings_alias}.tagger_type = ?", - owned_by.id, - owned_by.class.base_class.to_s - ]) + tagging_join << " AND " + + sanitize_sql([ + "#{taggings_alias}.tagger_id = ? AND #{taggings_alias}.tagger_type = ?", + owned_by.id, + owned_by.class.base_class.to_s + ]) end joins << tagging_join diff --git a/lib/gitlab/diff/parser.rb b/lib/gitlab/diff/parser.rb index 0242e09a515..887ed76b36c 100644 --- a/lib/gitlab/diff/parser.rb +++ b/lib/gitlab/diff/parser.rb @@ -74,7 +74,7 @@ module Gitlab def html_escape(str) replacements = { '&' => '&', '>' => '>', '<' => '<', '"' => '"', "'" => ''' } - str.gsub(/[&"'><]/, replacements) + str.gsub(/[&"'><]/, replacements) end end end diff --git a/lib/gitlab/git_access.rb b/lib/gitlab/git_access.rb index 0530923b202..6444cec7eb5 100644 --- a/lib/gitlab/git_access.rb +++ b/lib/gitlab/git_access.rb @@ -112,14 +112,14 @@ module Gitlab def protected_branch_action(project, oldrev, newrev, branch_name) # we dont allow force push to protected branch if forced_push?(project, oldrev, newrev) - :force_push_code_to_protected_branches + :force_push_code_to_protected_branches elsif newrev == Gitlab::Git::BLANK_SHA - # and we dont allow remove of protected branch - :remove_protected_branches + # and we dont allow remove of protected branch + :remove_protected_branches elsif project.developers_can_push_to_protected_branch?(branch_name) - :push_code + :push_code else - :push_code_to_protected_branches + :push_code_to_protected_branches end end -- cgit v1.2.1 From ae5743e9c1d32f905aa1c64bce34e20379c85322 Mon Sep 17 00:00:00 2001 From: Jeroen van Baarsen Date: Tue, 3 Feb 2015 10:44:41 +0100 Subject: Made diff colors a little less In Your Face Signed-off-by: Jeroen van Baarsen --- app/assets/stylesheets/sections/diff.scss | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/app/assets/stylesheets/sections/diff.scss b/app/assets/stylesheets/sections/diff.scss index da50dbe4715..f47ea329827 100644 --- a/app/assets/stylesheets/sections/diff.scss +++ b/app/assets/stylesheets/sections/diff.scss @@ -40,12 +40,12 @@ font-size: $code_font_size; .old { span.idiff { - background-color: #F99; + background-color: #f8cbcb; } } .new { span.idiff { - background-color: #8F8; + background-color: #a6f3a6; } } .unfold { @@ -84,7 +84,7 @@ padding: 0px; border: none; background: #F5F5F5; - color: #666; + color: rgba(0,0,0,0.3); padding: 0px 5px; border-right: 1px solid #ccc; text-align: right; @@ -96,7 +96,7 @@ float: left; width: 35px; font-weight: normal; - color: #666; + color: rgba(0,0,0,0.3); &:hover { text-decoration: underline; } @@ -114,13 +114,13 @@ .line_holder { &.old .old_line, &.old .new_line { - background: #FCC; - border-color: #E7BABA; + background: #ffdddd; + border-color: #f1c0c0; } &.new .old_line, &.new .new_line { - background: #CFC; - border-color: #B9ECB9; + background: #dbffdb; + border-color: #c1e9c1; } } .line_content { @@ -129,10 +129,10 @@ padding: 0px 0.5em; border: none; &.new { - background: #CFD; + background: #eaffea; } &.old { - background: #FDD; + background: #ffecec; } &.matched { color: #ccc; -- cgit v1.2.1 From 0e896aa9e90be3cb7765239860a9970996685998 Mon Sep 17 00:00:00 2001 From: Robert Schilling Date: Tue, 3 Feb 2015 11:44:55 +0100 Subject: Update gitlab-shell to 2.4.2 for 7.7 install/update guide closes #8718, closes #8721 --- doc/install/installation.md | 2 +- doc/update/7.6-to-7.7.md | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/doc/install/installation.md b/doc/install/installation.md index b080e8f062b..bfdebaf8466 100644 --- a/doc/install/installation.md +++ b/doc/install/installation.md @@ -278,7 +278,7 @@ We recommend using a PostgreSQL database. For MySQL check [MySQL setup guide](da GitLab Shell is an SSH access and repository management software developed specially for GitLab. # Run the installation task for gitlab-shell (replace `REDIS_URL` if needed): - sudo -u git -H bundle exec rake gitlab:shell:install[v2.4.1] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production + sudo -u git -H bundle exec rake gitlab:shell:install[v2.4.2] REDIS_URL=unix:/var/run/redis/redis.sock RAILS_ENV=production # By default, the gitlab-shell config is generated from your main GitLab config. # You can review (and modify) the gitlab-shell config as follows: diff --git a/doc/update/7.6-to-7.7.md b/doc/update/7.6-to-7.7.md index 51084576f33..831958d0b8b 100644 --- a/doc/update/7.6-to-7.7.md +++ b/doc/update/7.6-to-7.7.md @@ -37,7 +37,7 @@ sudo -u git -H git checkout 7-7-stable-ee ```bash cd /home/git/gitlab-shell sudo -u git -H git fetch -sudo -u git -H git checkout v2.4.1 +sudo -u git -H git checkout v2.4.2 ``` ### 4. Install libs, migrations, etc. -- cgit v1.2.1 From 4e97f26649a7756bef843fca74e3c58eadd117e1 Mon Sep 17 00:00:00 2001 From: jubianchi Date: Fri, 30 Jan 2015 10:46:08 +0100 Subject: Acces groups with their path in API --- CHANGELOG | 2 +- doc/api/groups.md | 10 +++++----- lib/api/group_members.rb | 16 ---------------- lib/api/groups.rb | 16 ---------------- lib/api/helpers.rb | 25 +++++++++++++++++++++++-- spec/requests/api/groups_spec.rb | 18 ++++++++++++++++++ 6 files changed, 47 insertions(+), 40 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index aa7daa11947..2f9b995f9e1 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -53,7 +53,7 @@ v 7.8.0 - Add a new API function that retrieves all issues assigned to a single milestone (Justin Whear and Hannes Rosenögger) - - - - + - API: Access groups with their path (Julien Bianchi) - - - diff --git a/doc/api/groups.md b/doc/api/groups.md index 9217c7a7f24..9f01b550641 100644 --- a/doc/api/groups.md +++ b/doc/api/groups.md @@ -32,7 +32,7 @@ GET /groups/:id Parameters: -- `id` (required) - The ID of a group +- `id` (required) - The ID or path of a group ## New group @@ -58,7 +58,7 @@ POST /groups/:id/projects/:project_id Parameters: -- `id` (required) - The ID of a group +- `id` (required) - The ID or path of a group - `project_id` (required) - The ID of a project ## Remove group @@ -71,7 +71,7 @@ DELETE /groups/:id Parameters: -- `id` (required) - The ID of a user group +- `id` (required) - The ID or path of a user group ## Search for group @@ -148,7 +148,7 @@ POST /groups/:id/members Parameters: -- `id` (required) - The ID of a group +- `id` (required) - The ID or path of a group - `user_id` (required) - The ID of a user to add - `access_level` (required) - Project access level @@ -162,5 +162,5 @@ DELETE /groups/:id/members/:user_id Parameters: -- `id` (required) - The ID of a user group +- `id` (required) - The ID or path of a user group - `user_id` (required) - The ID of a group member diff --git a/lib/api/group_members.rb b/lib/api/group_members.rb index d596517c816..4373070083a 100644 --- a/lib/api/group_members.rb +++ b/lib/api/group_members.rb @@ -3,22 +3,6 @@ module API before { authenticate! } resource :groups do - helpers do - def find_group(id) - group = Group.find(id) - - if can?(current_user, :read_group, group) - group - else - render_api_error!("403 Forbidden - #{current_user.username} lacks sufficient access to #{group.name}", 403) - end - end - - def validate_access_level?(level) - Gitlab::Access.options_with_owner.values.include? level.to_i - end - end - # Get a list of group members viewable by the authenticated user. # # Example Request: diff --git a/lib/api/groups.rb b/lib/api/groups.rb index 730dfad52c8..384a28e41f5 100644 --- a/lib/api/groups.rb +++ b/lib/api/groups.rb @@ -4,22 +4,6 @@ module API before { authenticate! } resource :groups do - helpers do - def find_group(id) - group = Group.find(id) - - if can?(current_user, :read_group, group) - group - else - render_api_error!("403 Forbidden - #{current_user.username} lacks sufficient access to #{group.name}", 403) - end - end - - def validate_access_level?(level) - Gitlab::Access.options_with_owner.values.include? level.to_i - end - end - # Get a groups list # # Example Request: diff --git a/lib/api/helpers.rb b/lib/api/helpers.rb index 62c26ef76ce..96249ea8cfe 100644 --- a/lib/api/helpers.rb +++ b/lib/api/helpers.rb @@ -55,6 +55,21 @@ module API end end + def find_group(id) + begin + group = Group.find(id) + rescue ActiveRecord::RecordNotFound + group = Group.find_by!(path: id) + end + + if can?(current_user, :read_group, group) + group + else + forbidden!("#{current_user.username} lacks sufficient "\ + "access to #{group.name}") + end + end + def paginate(relation) per_page = params[:per_page].to_i paginated = relation.page(params[:page]).per(per_page) @@ -135,10 +150,16 @@ module API errors end + def validate_access_level?(level) + Gitlab::Access.options_with_owner.values.include? level.to_i + end + # error helpers - def forbidden! - render_api_error!('403 Forbidden', 403) + def forbidden!(reason = nil) + message = ['403 Forbidden'] + message << " - #{reason}" if reason + render_api_error!(message.join(' '), 403) end def bad_request!(attribute) diff --git a/spec/requests/api/groups_spec.rb b/spec/requests/api/groups_spec.rb index 95f82463367..8465d765294 100644 --- a/spec/requests/api/groups_spec.rb +++ b/spec/requests/api/groups_spec.rb @@ -73,6 +73,24 @@ describe API::API, api: true do response.status.should == 404 end end + + context 'when using group path in URL' do + it 'should return any existing group' do + get api("/groups/#{group1.path}", admin) + response.status.should == 200 + json_response['name'] == group2.name + end + + it 'should not return a non existing group' do + get api('/groups/unknown', admin) + response.status.should == 404 + end + + it 'should not return a group not attached to user1' do + get api("/groups/#{group2.path}", user1) + response.status.should == 403 + end + end end describe "POST /groups" do -- cgit v1.2.1 From 97d4ac40477788c1c43d2f32baefd1df1ceeb9f4 Mon Sep 17 00:00:00 2001 From: Jason Blanchard Date: Fri, 30 Jan 2015 23:21:31 -0500 Subject: Adds link to milestone and keeping resource context on smaller viewports for issues and merge requests --- CHANGELOG | 2 +- app/views/projects/issues/_discussion.html.haml | 2 +- app/views/projects/issues/_issue_context.html.haml | 18 ++++++++---------- app/views/projects/issues/update.js.haml | 7 +++++++ .../projects/merge_requests/_discussion.html.haml | 4 ++-- .../projects/merge_requests/show/_context.html.haml | 18 +++++++++--------- app/views/projects/merge_requests/update.js.haml | 6 ++++++ spec/features/issues_spec.rb | 5 +++-- 8 files changed, 37 insertions(+), 25 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 2db5beb0022..906315502c7 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -54,7 +54,7 @@ v 7.8.0 - - - - - + - Added link to milestone and keeping resource context on smaller viewports for issues and merge requests (Jason Blanchard) - - - API: Add support for editing an existing project (Mika Mäenpää and Hannes Rosenögger) diff --git a/app/views/projects/issues/_discussion.html.haml b/app/views/projects/issues/_discussion.html.haml index b5d6a16a1e1..e04e1985f1f 100644 --- a/app/views/projects/issues/_discussion.html.haml +++ b/app/views/projects/issues/_discussion.html.haml @@ -13,7 +13,7 @@ = link_to_member(@project, participant, name: false, size: 24) .voting_notes#notes= render "projects/notes/notes_with_form" - .col-md-3.hidden-sm.hidden-xs + .col-md-3 %div .clearfix %span.slead.has_tooltip{:"data-original-title" => 'Cross-project reference'} diff --git a/app/views/projects/issues/_issue_context.html.haml b/app/views/projects/issues/_issue_context.html.haml index 98777a58f9d..3daa18ba346 100644 --- a/app/views/projects/issues/_issue_context.html.haml +++ b/app/views/projects/issues/_issue_context.html.haml @@ -2,23 +2,21 @@ %div.prepend-top-20 %p Assignee: - + - if issue.assignee + = link_to_member(@project, @issue.assignee) + - else + none - if can?(current_user, :modify_issue, @issue) = project_users_select_tag('issue[assignee_id]', placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: @issue.assignee_id) - - elsif issue.assignee - = link_to_member(@project, @issue.assignee) - - else - None %div.prepend-top-20 %p Milestone: + - if issue.milestone + #{link_to @issue.milestone.title, project_milestone_path(@project, @issue.milestone)} + - else + none - if can?(current_user, :modify_issue, @issue) = f.select(:milestone_id, milestone_options(@issue), { include_blank: "Select milestone" }, {class: 'select2 select2-compact js-select2 js-milestone'}) = hidden_field_tag :issue_context = f.submit class: 'btn' - - elsif issue.milestone - = link_to project_milestone_path(@project, @issue.milestone) do - = @issue.milestone.title - - else - None diff --git a/app/views/projects/issues/update.js.haml b/app/views/projects/issues/update.js.haml index 6e50667b084..7a5e0517556 100644 --- a/app/views/projects/issues/update.js.haml +++ b/app/views/projects/issues/update.js.haml @@ -3,8 +3,15 @@ :plain $("##{dom_id(@issue)}").fadeOut(); - elsif params[:issue_context] + $('.context').html("#{escape_javascript(render partial: 'issue_context', locals: { issue: @issue })}"); $('.context').effect('highlight'); - if @issue.milestone $('.milestone-nav-link').replaceWith("| Milestone #{escape_javascript(link_to @issue.milestone.title, project_milestone_path(@issue.project, @issue.milestone))}") - else $('.milestone-nav-link').html('') + + +$('select.select2').select2({width: 'resolve', dropdownAutoWidth: true}) +$('.edit-issue.inline-update input[type="submit"]').hide(); +new ProjectUsersSelect(); +new Issue(); diff --git a/app/views/projects/merge_requests/_discussion.html.haml b/app/views/projects/merge_requests/_discussion.html.haml index 64bae800785..f1f66569a9f 100644 --- a/app/views/projects/merge_requests/_discussion.html.haml +++ b/app/views/projects/merge_requests/_discussion.html.haml @@ -9,7 +9,7 @@ .col-md-9 = render "projects/merge_requests/show/participants" = render "projects/notes/notes_with_form" - .col-md-3.hidden-sm.hidden-xs + .col-md-3 .clearfix %span.slead.has_tooltip{:"data-original-title" => 'Cross-project reference'} = cross_project_reference(@project, @merge_request) @@ -18,7 +18,7 @@ %cite.cgray = render partial: 'projects/merge_requests/show/context', locals: { merge_request: @merge_request } %hr - .votes-holder.hidden-sm.hidden-xs + .votes-holder %h6 Votes #votes= render 'votes/votes_block', votable: @merge_request diff --git a/app/views/projects/merge_requests/show/_context.html.haml b/app/views/projects/merge_requests/show/_context.html.haml index 5b6e64f0657..21718ca2acf 100644 --- a/app/views/projects/merge_requests/show/_context.html.haml +++ b/app/views/projects/merge_requests/show/_context.html.haml @@ -2,22 +2,22 @@ %div.prepend-top-20 %p Assignee: - + - if @merge_request.assignee + = link_to_member(@project, @merge_request.assignee) + - else + none - if can?(current_user, :modify_merge_request, @merge_request) = project_users_select_tag('merge_request[assignee_id]', placeholder: 'Select assignee', class: 'custom-form-control js-select2 js-assignee', selected: @merge_request.assignee_id) - - elsif merge_request.assignee - = link_to_member(@project, @merge_request.assignee) - - else - None %div.prepend-top-20 %p Milestone: + - if @merge_request.milestone + %span.back-to-milestone + #{link_to @merge_request.milestone.title, project_milestone_path(@project, @merge_request.milestone)} + - else + none - if can?(current_user, :modify_merge_request, @merge_request) = f.select(:milestone_id, milestone_options(@merge_request), { include_blank: "Select milestone" }, {class: 'select2 select2-compact js-select2 js-milestone'}) = hidden_field_tag :merge_request_context = f.submit class: 'btn' - - elsif merge_request.milestone - = link_to merge_request.milestone.title, project_milestone_path - - else - None diff --git a/app/views/projects/merge_requests/update.js.haml b/app/views/projects/merge_requests/update.js.haml index 6f4c5dd7a3b..f5cc98c7fa4 100644 --- a/app/views/projects/merge_requests/update.js.haml +++ b/app/views/projects/merge_requests/update.js.haml @@ -1,2 +1,8 @@ - if params[:merge_request_context] + $('.context').html("#{escape_javascript(render partial: 'projects/merge_requests/show/context', locals: { issue: @issue })}"); $('.context').effect('highlight'); + + new ProjectUsersSelect(); + + $('select.select2').select2({width: 'resolve', dropdownAutoWidth: true}); + merge_request = new MergeRequest(); diff --git a/spec/features/issues_spec.rb b/spec/features/issues_spec.rb index 26607b0090c..e6fa376f3eb 100644 --- a/spec/features/issues_spec.rb +++ b/spec/features/issues_spec.rb @@ -65,7 +65,7 @@ describe "Issues", feature: true do click_button "Save changes" - page.should have_content "Assignee: Select assignee" + page.should have_content 'Assignee: none' issue.reload.assignee.should be_nil end end @@ -249,6 +249,7 @@ describe "Issues", feature: true do click_button 'Update Issue' page.should have_content "Milestone changed to #{milestone.title}" + page.should have_content "Milestone: #{milestone.title}" has_select?('issue_assignee_id', :selected => milestone.title) end end @@ -287,7 +288,7 @@ describe "Issues", feature: true do sleep 2 # wait for ajax stuff to complete first('.user-result').click - page.should have_content "Assignee: Unassigned" + page.should have_content 'Assignee: none' sleep 2 # wait for ajax stuff to complete issue.reload.assignee.should be_nil end -- cgit v1.2.1 From ee955d7a125f9d18ac7ae334542ae68dd8d5114c Mon Sep 17 00:00:00 2001 From: Jason Blanchard Date: Fri, 30 Jan 2015 14:23:35 -0500 Subject: Adds persistent collapse button for left side bar --- CHANGELOG | 1 + app/assets/javascripts/sidebar.js.coffee | 10 ++++++ app/assets/stylesheets/sections/nav_sidebar.scss | 39 +++++++++++++++++++++++- app/helpers/nav_helper.rb | 5 +++ app/views/layouts/_collapse_button.html.haml | 4 +++ app/views/layouts/_page.html.haml | 4 ++- spec/helpers/nav_helper_spec.rb | 25 +++++++++++++++ 7 files changed, 86 insertions(+), 2 deletions(-) create mode 100644 app/helpers/nav_helper.rb create mode 100644 app/views/layouts/_collapse_button.html.haml create mode 100644 spec/helpers/nav_helper_spec.rb diff --git a/CHANGELOG b/CHANGELOG index 2db5beb0022..427a2ee90e6 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -62,6 +62,7 @@ v 7.8.0 - - - Added support for firing system hooks on group create/destroy and adding/removing users to group (Boyan Tabakov) + - Added persistent collapse button for left side nav bar (Jason Blanchard) v 7.7.2 - Update GitLab Shell to version 2.4.2 that fixes a bug when developers can push to protected branch diff --git a/app/assets/javascripts/sidebar.js.coffee b/app/assets/javascripts/sidebar.js.coffee index c084d730d62..d1b165a2311 100644 --- a/app/assets/javascripts/sidebar.js.coffee +++ b/app/assets/javascripts/sidebar.js.coffee @@ -24,3 +24,13 @@ $ -> $(window).resize -> responsive_resize() return + +$(document).on("click", '.toggle-nav-collapse', (e) -> + e.preventDefault() + if $('.page-with-sidebar').hasClass('collapsed') + $('.page-with-sidebar').removeClass('collapsed') + $.cookie("collapsed_nav", "false", { path: '/' }) + else + $('.page-with-sidebar').addClass('collapsed') + $.cookie("collapsed_nav", "true", { path: '/' }) +) diff --git a/app/assets/stylesheets/sections/nav_sidebar.scss b/app/assets/stylesheets/sections/nav_sidebar.scss index a61c053b8a9..0c278aec3f5 100644 --- a/app/assets/stylesheets/sections/nav_sidebar.scss +++ b/app/assets/stylesheets/sections/nav_sidebar.scss @@ -110,7 +110,7 @@ .nav-sidebar { margin-top: 20px; - position: fixed; + position: relative; top: 45px; width: $sidebar_width; } @@ -150,6 +150,37 @@ } } +.collapse-nav { + position: relative; + top: 50px; + width: 230px; + text-align: right; + padding-right: 21px; +} + +.page-with-sidebar.collapsed { + + .collapse-nav { + width: 53px; + } + + padding-left: 50px; + + .sidebar-wrapper { + width: 52px; + overflow-x: hidden; + + .nav-sidebar { + width: 52px; + } + + .nav-sidebar li a > span { + display: none; + } + } +} + + @media (max-width: $screen-md-max) { @include folded-sidebar; } @@ -157,3 +188,9 @@ @media(min-width: $screen-md-max) { @include expanded-sidebar; } + +@media (max-width: $screen-md-max) { + .collapse-nav { + display: none; + } +} diff --git a/app/helpers/nav_helper.rb b/app/helpers/nav_helper.rb new file mode 100644 index 00000000000..2b03269800e --- /dev/null +++ b/app/helpers/nav_helper.rb @@ -0,0 +1,5 @@ +module NavHelper + def nav_menu_collapsed? + cookies[:collapsed_nav] == 'true' + end +end diff --git a/app/views/layouts/_collapse_button.html.haml b/app/views/layouts/_collapse_button.html.haml new file mode 100644 index 00000000000..52c19f1d99d --- /dev/null +++ b/app/views/layouts/_collapse_button.html.haml @@ -0,0 +1,4 @@ +- if nav_menu_collapsed? + = link_to icon('plus-square'), '#', class: 'toggle-nav-collapse' +- else + = link_to icon('minus-square'), '#', class: 'toggle-nav-collapse' diff --git a/app/views/layouts/_page.html.haml b/app/views/layouts/_page.html.haml index 1263f44eca9..e20aec89110 100644 --- a/app/views/layouts/_page.html.haml +++ b/app/views/layouts/_page.html.haml @@ -1,8 +1,10 @@ - if defined?(sidebar) - .page-with-sidebar + .page-with-sidebar{:class => ("collapsed" if nav_menu_collapsed?)} = render "layouts/broadcast" .sidebar-wrapper = render(sidebar) + .collapse-nav + = render :partial => 'layouts/collapse_button' .content-wrapper .container-fluid .content diff --git a/spec/helpers/nav_helper_spec.rb b/spec/helpers/nav_helper_spec.rb new file mode 100644 index 00000000000..e4d18d8bfc6 --- /dev/null +++ b/spec/helpers/nav_helper_spec.rb @@ -0,0 +1,25 @@ +require 'spec_helper' + +# Specs in this file have access to a helper object that includes +# the NavHelper. For example: +# +# describe NavHelper do +# describe "string concat" do +# it "concats two strings with spaces" do +# expect(helper.concat_strings("this","that")).to eq("this that") +# end +# end +# end +describe NavHelper do + describe '#nav_menu_collapsed?' do + it 'returns true when the nav is collapsed in the cookie' do + helper.request.cookies[:collapsed_nav] = 'true' + expect(helper.nav_menu_collapsed?).to eq true + end + + it 'returns false when the nav is not collapsed in the cookie' do + helper.request.cookies[:collapsed_nav] = 'false' + expect(helper.nav_menu_collapsed?).to eq false + end + end +end -- cgit v1.2.1 From b9d9ac82a9d650b659866ea26dcb4e7987f10381 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Mon, 2 Feb 2015 21:30:11 -0800 Subject: Commit page: async load branches info Conflicts: config/routes.rb --- app/controllers/projects/commit_controller.rb | 8 ++++++-- app/views/projects/commit/_commit_box.html.haml | 23 ++++++----------------- app/views/projects/commit/branches.html.haml | 16 ++++++++++++++++ config/routes.rb | 8 ++++++-- spec/controllers/commit_controller_spec.rb | 9 +++++++++ 5 files changed, 43 insertions(+), 21 deletions(-) create mode 100644 app/views/projects/commit/branches.html.haml diff --git a/app/controllers/projects/commit_controller.rb b/app/controllers/projects/commit_controller.rb index 470efbd2114..96a782bdf7a 100644 --- a/app/controllers/projects/commit_controller.rb +++ b/app/controllers/projects/commit_controller.rb @@ -11,8 +11,6 @@ class Projects::CommitController < Projects::ApplicationController return git_not_found! unless @commit @line_notes = @project.notes.for_commit_id(commit.id).inline - @branches = @project.repository.branch_names_contains(commit.id) - @tags = @project.repository.tag_names_contains(commit.id) @diffs = @commit.diffs @note = @project.build_commit_note(commit) @notes_count = @project.notes.for_commit_id(commit.id).count @@ -31,6 +29,12 @@ class Projects::CommitController < Projects::ApplicationController end end + def branches + @branches = @project.repository.branch_names_contains(commit.id) + @tags = @project.repository.tag_names_contains(commit.id) + render layout: false + end + def commit @commit ||= @project.repository.commit(params[:id]) end diff --git a/app/views/projects/commit/_commit_box.html.haml b/app/views/projects/commit/_commit_box.html.haml index b41fb1437f2..dd28a35d41d 100644 --- a/app/views/projects/commit/_commit_box.html.haml +++ b/app/views/projects/commit/_commit_box.html.haml @@ -37,23 +37,8 @@ - @commit.parents.each do |parent| = link_to parent.short_id, project_commit_path(@project, parent) -.commit-info-row - - if @branches.any? - %span - - branch = commit_default_branch(@project, @branches) - = link_to(project_tree_path(@project, branch)) do - %span.label.label-gray - %i.fa.fa-code-fork - = branch - - if @branches.any? || @tags.any? - = link_to("#", class: "js-details-expand") do - %span.label.label-gray - \... - %span.js-details-content.hide - - if @branches.any? - = commit_branches_links(@project, @branches) - - if @tags.any? - = commit_tags_links(@project, @tags) +.commit-info-row.branches + %i.fa.fa-spinner.fa-spin .commit-box %h3.commit-title @@ -61,3 +46,7 @@ - if @commit.description.present? %pre.commit-description = preserve(gfm(escape_once(@commit.description))) + +:coffeescript + $ -> + $(".commit-info-row.branches").load("#{branches_project_commit_path(@project, @commit.id)}") \ No newline at end of file diff --git a/app/views/projects/commit/branches.html.haml b/app/views/projects/commit/branches.html.haml new file mode 100644 index 00000000000..b01e806210c --- /dev/null +++ b/app/views/projects/commit/branches.html.haml @@ -0,0 +1,16 @@ +- if @branches.any? + %span + - branch = commit_default_branch(@project, @branches) + = link_to(project_tree_path(@project, branch)) do + %span.label.label-gray + %i.fa.fa-code-fork + = branch + - if @branches.any? || @tags.any? + = link_to("#", class: "js-details-expand") do + %span.label.label-gray + \... + %span.js-details-content.hide + - if @branches.any? + = commit_branches_links(@project, @branches) + - if @tags.any? + = commit_tags_links(@project, @tags) \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index a2d782cf633..512066e5d4e 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -228,8 +228,12 @@ Gitlab::Application.routes.draw do resources :raw, only: [:show], constraints: { id: /.+/ } resources :tree, only: [:show], constraints: { id: /.+/, format: /(html|js)/ } resource :avatar, only: [:show, :destroy] - resources :commit, only: [:show], constraints: { id: /[[:alnum:]]{6,40}/ } - resources :commits, only: [:show], constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ } + + resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} do + get :branches, on: :member + end + + resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} resources :compare, only: [:index, :create] resources :blame, only: [:show], constraints: { id: /.+/ } resources :network, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } diff --git a/spec/controllers/commit_controller_spec.rb b/spec/controllers/commit_controller_spec.rb index f5822157ea4..cd8b46d7672 100644 --- a/spec/controllers/commit_controller_spec.rb +++ b/spec/controllers/commit_controller_spec.rb @@ -70,4 +70,13 @@ describe Projects::CommitController do end end end + + describe "#branches" do + it "contains branch and tags information" do + get :branches, project_id: project.to_param, id: commit.id + + expect(assigns(:branches)).to include("master", "feature_conflict") + expect(assigns(:tags)).to include("v1.1.0") + end + end end -- cgit v1.2.1 From c8782e1a402f187573562ce8af9068898fd01673 Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 3 Feb 2015 09:22:56 -0800 Subject: code folding --- config/routes.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/config/routes.rb b/config/routes.rb index 512066e5d4e..f0abd876ecd 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -229,11 +229,11 @@ Gitlab::Application.routes.draw do resources :tree, only: [:show], constraints: { id: /.+/, format: /(html|js)/ } resource :avatar, only: [:show, :destroy] - resources :commit, only: [:show], constraints: {id: /[[:alnum:]]{6,40}/} do + resources :commit, only: [:show], constraints: { id: /[[:alnum:]]{6,40}/ } do get :branches, on: :member end - resources :commits, only: [:show], constraints: {id: /(?:[^.]|\.(?!atom$))+/, format: /atom/} + resources :commits, only: [:show], constraints: { id: /(?:[^.]|\.(?!atom$))+/, format: /atom/ } resources :compare, only: [:index, :create] resources :blame, only: [:show], constraints: { id: /.+/ } resources :network, only: [:show], constraints: { id: /(?:[^.]|\.(?!json$))+/, format: /json/ } -- cgit v1.2.1 From 19f39b4292a80942ff42d345afca957c04545b9b Mon Sep 17 00:00:00 2001 From: Valery Sizov Date: Tue, 3 Feb 2015 09:23:55 -0800 Subject: update changelog --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index aa7daa11947..b93c1567907 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -28,7 +28,7 @@ v 7.8.0 - Added Rubocop for code style checks - Fix commits pagination - - - + - Async load a branch information at the commit page - - - Add a commit calendar to the user profile (Hannes Rosenögger) -- cgit v1.2.1 From 68fbf1423fddcb7d49e408d05105ca6911e91122 Mon Sep 17 00:00:00 2001 From: Job van der Voort Date: Tue, 3 Feb 2015 11:05:20 -0800 Subject: improve english documentation --- doc/workflow/web_editor.md | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/doc/workflow/web_editor.md b/doc/workflow/web_editor.md index c83715deff7..bcadf5e8c0d 100644 --- a/doc/workflow/web_editor.md +++ b/doc/workflow/web_editor.md @@ -1,23 +1,26 @@ # GitLab Web Editor -In GitLab you can create new files and edit existing one using our web editor. -Its really useful if you dont have access to command line or you want to make a quick small fix. -You can access to web editor in several ways depends on context. -Lets start from newly created project. -Click on `Add a file` button to start web editor for creating first file. +In GitLab you can create new files and edit existing files using our web editor. +This is especially useful if you don't have access to a command line or you just want to do a quick fix. +You can easily access the web editor, depending on the context. +Let's start from newly created project. + +Click on `Add a file` +to create the first file and open it in the web editor. ![web editor 1](web_editor/empty_project.png) -Fill in file name, content, commit message and press commit button. -After this file will be saved to repository. +Fill in a file name, some content, a commit message and press the commit button. +The file will be saved to the repository. ![web editor 2](web_editor/new_file.png) -You can edit any text file in repository by pressing edit button when browsing file. +You can edit any text file in a repository by pressing the edit button, when +viewing the file. ![web editor 3](web_editor/show_file.png) -Edit of file is pretty same as creating new file. -Except you can see preview of your changes to file in separate tab +Editing a file is almost the same as creating a new file, +with as addition the ability to preview your changes in a separate tab. ![web editor 3](web_editor/edit_file.png) -- cgit v1.2.1 From e0d85078ba8b128ba6e0378ebd00a4e12d1e86ed Mon Sep 17 00:00:00 2001 From: Sytse Sijbrandij Date: Tue, 3 Feb 2015 11:23:59 -0800 Subject: Push can be multiple files. --- app/views/projects/empty.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/projects/empty.html.haml b/app/views/projects/empty.html.haml index 36628195b4e..d7dee2208de 100644 --- a/app/views/projects/empty.html.haml +++ b/app/views/projects/empty.html.haml @@ -10,7 +10,7 @@ You can = link_to project_new_blob_path(@project, 'master'), class: 'btn btn-new btn-lg' do add a file -  or push it via command line. +  or do a push via the command line. %h4 %strong Command line instructions -- cgit v1.2.1 From 254a63dcf7dcfe824eb0b7227e2cd63fac027f85 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 3 Feb 2015 13:11:33 -0800 Subject: Improve collapsing sidebar --- app/assets/javascripts/sidebar.js.coffee | 11 +++-- app/assets/stylesheets/sections/nav_sidebar.scss | 62 ++++++++---------------- app/helpers/application_helper.rb | 8 +++ app/views/layouts/_collapse_button.html.haml | 4 +- app/views/layouts/_page.html.haml | 4 +- 5 files changed, 41 insertions(+), 48 deletions(-) diff --git a/app/assets/javascripts/sidebar.js.coffee b/app/assets/javascripts/sidebar.js.coffee index d1b165a2311..5013bcdacd0 100644 --- a/app/assets/javascripts/sidebar.js.coffee +++ b/app/assets/javascripts/sidebar.js.coffee @@ -27,10 +27,15 @@ $(window).resize -> $(document).on("click", '.toggle-nav-collapse', (e) -> e.preventDefault() - if $('.page-with-sidebar').hasClass('collapsed') - $('.page-with-sidebar').removeClass('collapsed') + collapsed = 'page-sidebar-collapsed' + expanded = 'page-sidebar-expanded' + + if $('.page-with-sidebar').hasClass(collapsed) + $('.page-with-sidebar').removeClass(collapsed).addClass(expanded) + $('.toggle-nav-collapse i').removeClass('fa-angle-right').addClass('fa-angle-left') $.cookie("collapsed_nav", "false", { path: '/' }) else - $('.page-with-sidebar').addClass('collapsed') + $('.page-with-sidebar').removeClass(expanded).addClass(collapsed) + $('.toggle-nav-collapse i').removeClass('fa-angle-left').addClass('fa-angle-right') $.cookie("collapsed_nav", "true", { path: '/' }) ) diff --git a/app/assets/stylesheets/sections/nav_sidebar.scss b/app/assets/stylesheets/sections/nav_sidebar.scss index 0c278aec3f5..b35043821da 100644 --- a/app/assets/stylesheets/sections/nav_sidebar.scss +++ b/app/assets/stylesheets/sections/nav_sidebar.scss @@ -1,5 +1,3 @@ - - .page-with-sidebar { background: #F5F5F5; @@ -101,16 +99,14 @@ } @mixin expanded-sidebar { - .page-with-sidebar { - padding-left: $sidebar_width; - } + padding-left: $sidebar_width; .sidebar-wrapper { width: $sidebar_width; .nav-sidebar { margin-top: 20px; - position: relative; + position: fixed; top: 45px; width: $sidebar_width; } @@ -122,9 +118,7 @@ } @mixin folded-sidebar { - .page-with-sidebar { - padding-left: 50px; - } + padding-left: 50px; .sidebar-wrapper { width: 52px; @@ -150,47 +144,33 @@ } } -.collapse-nav { - position: relative; - top: 50px; - width: 230px; - text-align: right; - padding-right: 21px; +.collapse-nav a { + position: fixed; + bottom: 15px; + padding: 10px; + background: #DDD; } -.page-with-sidebar.collapsed { - - .collapse-nav { - width: 53px; +@media (max-width: $screen-md-max) { + .page-sidebar-collapsed { + @include folded-sidebar; } - padding-left: 50px; - - .sidebar-wrapper { - width: 52px; - overflow-x: hidden; - - .nav-sidebar { - width: 52px; - } - - .nav-sidebar li a > span { - display: none; - } + .page-sidebar-expanded { + @include folded-sidebar; } -} - -@media (max-width: $screen-md-max) { - @include folded-sidebar; + .collapse-nav { + display: none; + } } @media(min-width: $screen-md-max) { - @include expanded-sidebar; -} + .page-sidebar-collapsed { + @include folded-sidebar; + } -@media (max-width: $screen-md-max) { - .collapse-nav { - display: none; + .page-sidebar-expanded { + @include expanded-sidebar; } } diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 1fbb44ee442..e45f4650309 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -315,4 +315,12 @@ module ApplicationHelper profile_key_path(key) end end + + def nav_sidebar_class + if nav_menu_collapsed? + "page-sidebar-collapsed" + else + "page-sidebar-expanded" + end + end end diff --git a/app/views/layouts/_collapse_button.html.haml b/app/views/layouts/_collapse_button.html.haml index 52c19f1d99d..b3b338b55bb 100644 --- a/app/views/layouts/_collapse_button.html.haml +++ b/app/views/layouts/_collapse_button.html.haml @@ -1,4 +1,4 @@ - if nav_menu_collapsed? - = link_to icon('plus-square'), '#', class: 'toggle-nav-collapse' + = link_to icon('angle-right'), '#', class: 'toggle-nav-collapse' - else - = link_to icon('minus-square'), '#', class: 'toggle-nav-collapse' + = link_to icon('angle-left'), '#', class: 'toggle-nav-collapse' diff --git a/app/views/layouts/_page.html.haml b/app/views/layouts/_page.html.haml index e20aec89110..98a3d2278a3 100644 --- a/app/views/layouts/_page.html.haml +++ b/app/views/layouts/_page.html.haml @@ -1,10 +1,10 @@ - if defined?(sidebar) - .page-with-sidebar{:class => ("collapsed" if nav_menu_collapsed?)} + .page-with-sidebar{ class: nav_sidebar_class } = render "layouts/broadcast" .sidebar-wrapper = render(sidebar) .collapse-nav - = render :partial => 'layouts/collapse_button' + = render partial: 'layouts/collapse_button' .content-wrapper .container-fluid .content -- cgit v1.2.1 From a89d7adfa44767e71cfb9005e5a3eed6a91b4d84 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 3 Feb 2015 13:57:28 -0800 Subject: Rescue connection reset for web hooks --- app/models/hooks/web_hook.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/models/hooks/web_hook.rb b/app/models/hooks/web_hook.rb index 327cb585ffa..c8fa9c50918 100644 --- a/app/models/hooks/web_hook.rb +++ b/app/models/hooks/web_hook.rb @@ -48,7 +48,7 @@ class WebHook < ActiveRecord::Base verify: false, basic_auth: auth) end - rescue SocketError, Errno::ECONNREFUSED, Net::OpenTimeout => e + rescue SocketError, Errno::ECONNRESET, Errno::ECONNREFUSED, Net::OpenTimeout => e logger.error("WebHook Error => #{e}") false end -- cgit v1.2.1 From 704922c855a9741b5495db56ac266788a9c25c33 Mon Sep 17 00:00:00 2001 From: Dmitriy Zaporozhets Date: Tue, 3 Feb 2015 15:07:01 -0800 Subject: Mention web hook imporvements --- CHANGELOG | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CHANGELOG b/CHANGELOG index 93abec424d7..9ce9caa503f 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -60,7 +60,7 @@ v 7.8.0 - API: Add support for editing an existing project (Mika Mäenpää and Hannes Rosenögger) - - - - + - When test web hook - show error message instead of 500 error page if connection to hook url was reset - Added support for firing system hooks on group create/destroy and adding/removing users to group (Boyan Tabakov) - Added persistent collapse button for left side nav bar (Jason Blanchard) -- cgit v1.2.1