diff --git a/Gemfile b/Gemfile index 945f73564..4a1bc67d2 100644 --- a/Gemfile +++ b/Gemfile @@ -1,14 +1,14 @@ source 'https://rubygems.org' -gem 'rails', '4.0.13' +gem 'rails', '4.1.9' gem 'activeadmin', github: 'activeadmin' -gem 'pg', '~> 0.17.1' +gem 'pg' gem 'schema_plus', '~> 1.5' ######## gem 'protected_attributes' ######## -gem 'devise', '~> 3.3' +gem 'devise' gem 'omniauth' gem 'omniauth-facebook' gem 'omniauth-google-oauth2' @@ -17,27 +17,27 @@ gem 'omniauth-github' # gem 'cancan', '1.6.10' gem 'cancan', git: 'git://github.com/rosa-abf/cancan.git', tag: '1.6.10-abf' -gem 'ancestry', '~> 2.1' -gem 'paperclip', '~> 4.2' -gem 'resque', '~> 1.25' -gem 'resque-status', '~> 0.4' -gem 'resque_mailer', '~> 2.2' +gem 'ancestry' +gem 'paperclip' +gem 'resque' +gem 'resque-status' +gem 'resque_mailer' gem 'resque-scheduler', '~> 2.5.4' gem 'perform_later', git: 'git://github.com/KensoDev/perform_later.git' # should be after resque_mailer -gem 'russian', '~> 0.6.0' +gem 'russian' gem 'highline', '~> 1.6.20' -gem 'state_machine', '~> 1.2' -gem 'redis-rails', '~> 4.0' +gem 'state_machines-activerecord' +gem 'redis-rails' gem 'grack', git: 'git://github.com/rosa-abf/grack.git', require: 'git_http' gem 'grit', git: 'git://github.com/rosa-abf/grit.git', tag: '2.6.16' -gem 'charlock_holmes', '~> 0.7' +gem 'charlock_holmes' gem 'github-linguist', '3.1.5', require: 'linguist' -gem 'diff-display', '~> 0.0.1' +gem 'diff-display' # Wiki -gem "gollum-lib", '~> 3.0' -gem "redcarpet", '~> 3.1' +gem 'gollum-lib', '~> 3.0' +gem 'redcarpet', '~> 3.1' gem 'creole' gem 'rdiscount' # gem 'org-ruby' @@ -45,37 +45,37 @@ gem 'RedCloth' gem 'wikicloth' gem 'newrelic_rpm' -gem 'whenever', '~> 0.9.0', require: false +gem 'whenever', require: false -gem 'jbuilder', '~> 2.2' +gem 'jbuilder' gem 'rails3-jquery-autocomplete' -gem 'sprockets', '2.11.0' -gem 'will_paginate', '~> 3.0' -gem 'meta-tags', '~> 2.0', require: 'meta_tags' -gem "haml-rails", '~> 0.5' -gem 'jquery-rails', '~> 2.3' +gem 'sprockets' +gem 'will_paginate' +gem 'meta-tags', require: 'meta_tags' +gem 'haml-rails' +gem 'jquery-rails' gem 'jquery-migrate-rails' -gem 'ruby-haml-js', '~> 0.0.5' +gem 'ruby-haml-js' gem 'slim' -gem 'simple_form', '3.1.0.rc2' -gem 'friendly_id', '~> 5.0' +gem 'simple_form' +gem 'friendly_id' gem 'rack-throttle', '~> 0.3.0' -gem 'rest-client', '~> 1.7' +gem 'rest-client' gem 'ohm', '~> 1.3.2' # Ohm 2 breaks the compatibility with previous versions. gem 'ohm-expire', '~> 0.1.3' -gem 'ffi', '~> 1.9.3' +gem 'ffi' -gem 'attr_encrypted', '~> 1.3' -gem "gemoji", "~> 2.1" +gem 'attr_encrypted' +gem 'gemoji' # AngularJS related stuff gem 'underscore-rails' -gem 'angularjs-rails', '~> 1.2.15' +gem 'angularjs-rails' gem 'ng-rails-csrf' gem 'momentjs-rails' -gem 'angular-i18n', '0.1.2' +gem 'angular-i18n' gem 'js-routes' gem 'soundmanager-rails' gem 'angular-ui-bootstrap-rails' @@ -84,23 +84,23 @@ gem 'ngmin-rails' gem 'time_diff' -gem 'sass-rails', '~> 4.0' -gem 'coffee-rails', '~> 4.1' -gem 'bootstrap-sass', '~> 3.3' -gem 'font-awesome-rails', '~> 4.2' -gem 'zeroclipboard-rails', '~> 0.1.0' +gem 'sass-rails' +gem 'coffee-rails' +gem 'bootstrap-sass' +gem 'font-awesome-rails' +gem 'zeroclipboard-rails' -gem 'compass-rails', '~> 2.0' -gem 'uglifier', '~> 2.5' -gem 'therubyracer', '~> 0.12.1', platforms: [:mri, :rbx] -gem 'therubyrhino', '~> 2.0', platforms: :jruby +gem 'compass-rails' +gem 'uglifier' +gem 'therubyracer', platforms: [:mri, :rbx] +gem 'therubyrhino', platforms: :jruby gem 'sitemap_generator' gem 'codemirror-rails', '~> 4.5' group :production do - gem "airbrake", '~> 3.1' + gem 'airbrake' #gem 'bluepill', '~> 0.0.60', require: false gem 'puma' end diff --git a/Gemfile.lock b/Gemfile.lock index b54544055..f49e52c08 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -10,7 +10,7 @@ GIT GIT remote: git://github.com/activeadmin/activeadmin.git - revision: ed1fbca8c64af827616c58f274d7be256ca513b6 + revision: e27ccba8a7ea1f7f3085748decec1f6911f6d5d2 specs: activeadmin (1.0.0.pre) arbre (~> 1.0, >= 1.0.2) @@ -53,32 +53,34 @@ GEM remote: https://rubygems.org/ specs: RedCloth (4.2.9) - actionmailer (4.0.13) - actionpack (= 4.0.13) + actionmailer (4.1.9) + actionpack (= 4.1.9) + actionview (= 4.1.9) mail (~> 2.5, >= 2.5.4) - actionpack (4.0.13) - activesupport (= 4.0.13) - builder (~> 3.1.0) - erubis (~> 2.7.0) + actionpack (4.1.9) + actionview (= 4.1.9) + activesupport (= 4.1.9) rack (~> 1.5.2) rack-test (~> 0.6.2) - activemodel (4.0.13) - activesupport (= 4.0.13) - builder (~> 3.1.0) - activerecord (4.0.13) - activemodel (= 4.0.13) - activerecord-deprecated_finders (~> 1.0.2) - activesupport (= 4.0.13) - arel (~> 4.0.0) - activerecord-deprecated_finders (1.0.3) - activesupport (4.0.13) + actionview (4.1.9) + activesupport (= 4.1.9) + builder (~> 3.1) + erubis (~> 2.7.0) + activemodel (4.1.9) + activesupport (= 4.1.9) + builder (~> 3.1) + activerecord (4.1.9) + activemodel (= 4.1.9) + activesupport (= 4.1.9) + arel (~> 5.0.0) + activesupport (4.1.9) i18n (~> 0.6, >= 0.6.9) - minitest (~> 4.2) - multi_json (~> 1.3) + json (~> 1.7, >= 1.7.7) + minitest (~> 5.1) thread_safe (~> 0.1) - tzinfo (~> 0.3.37) + tzinfo (~> 1.1) addressable (2.3.7) - airbrake (3.2.1) + airbrake (4.1.0) builder multi_json ancestry (2.1.0) @@ -89,13 +91,13 @@ GEM sprockets tilt angular-ui-bootstrap-rails (0.12.0) - angularjs-rails (1.2.26) + angularjs-rails (1.3.14) arbre (1.0.3) activesupport (>= 3.0.0) - arel (4.0.2) + arel (5.0.1.20140414130214) attr_encrypted (1.3.3) encryptor (>= 1.3.0) - autoprefixer-rails (5.1.5) + autoprefixer-rails (5.1.7) execjs json bcrypt (3.1.10) @@ -108,10 +110,10 @@ GEM bootstrap-sass (3.3.3) autoprefixer-rails (>= 5.0.0.1) sass (>= 3.2.19) - bourbon (4.2.0) + bourbon (4.2.1) sass (~> 3.4) thor - builder (3.1.4) + builder (3.2.2) callsite (0.0.11) cape (1.8.0) capistrano (2.15.5) @@ -126,9 +128,9 @@ GEM chunky_png (1.3.4) climate_control (0.0.3) activesupport (>= 3.0) - cocaine (0.5.5) + cocaine (0.5.7) climate_control (>= 0.0.3, < 1.0) - codemirror-rails (4.8) + codemirror-rails (4.13) railties (>= 3.0, < 5) coderay (1.1.0) coffee-rails (4.1.0) @@ -203,7 +205,7 @@ GEM diff-lcs (~> 1.1) mime-types (~> 1.15) posix-spawn (~> 0.3) - gli (2.12.2) + gli (2.13.0) gollum-lib (3.0.0) github-markup (~> 1.1.0) gitlab-grit (~> 2.6.5) @@ -237,11 +239,11 @@ GEM has_scope (~> 0.6.0.rc) railties (>= 3.2, < 5) responders - jbuilder (2.2.7) + jbuilder (2.2.9) activesupport (>= 3.0.0, < 5) multi_json (~> 1.2) jquery-migrate-rails (1.2.1) - jquery-rails (2.3.0) + jquery-rails (3.1.2) railties (>= 3.0, < 5.0) thor (>= 0.14, < 2.0) jquery-ui-rails (5.0.3) @@ -250,7 +252,7 @@ GEM railties (>= 3.2) sprockets-rails json (1.8.2) - jwt (1.2.1) + jwt (1.3.0) kaminari (0.16.3) actionpack (>= 3.0.0) activesupport (>= 3.0.0) @@ -280,12 +282,12 @@ GEM railties (>= 3.0.0, < 5.0.0) mime-types (1.25.1) mini_portile (0.6.2) - minitest (4.7.5) + minitest (5.5.1) mock_redis (0.14.0) momentjs-rails (2.9.0) railties (>= 3.1) mono_logger (1.1.0) - multi_json (1.10.1) + multi_json (1.11.0) multi_xml (0.5.5) multipart-post (2.0.0) nest (1.1.2) @@ -297,7 +299,7 @@ GEM net-ssh (2.9.2) net-ssh-gateway (1.2.0) net-ssh (>= 2.6.5) - netrc (0.10.2) + netrc (0.10.3) newrelic_rpm (3.10.0.279) ng-rails-csrf (0.1.0) ngmin-rails (0.4.0) @@ -319,7 +321,7 @@ GEM omniauth (1.2.2) hashie (>= 1.2, < 4) rack (~> 1.0) - omniauth-facebook (2.0.0) + omniauth-facebook (2.0.1) omniauth-oauth2 (~> 1.2) omniauth-github (1.1.2) omniauth (~> 1.0) @@ -338,7 +340,7 @@ GEM activesupport (>= 3.0.0) cocaine (~> 0.5.3) mime-types - pg (0.17.1) + pg (0.18.1) polyamorous (1.1.0) activerecord (>= 3.0) posix-spawn (0.3.10) @@ -358,21 +360,23 @@ GEM rack (>= 1.0) rack-throttle (0.3.0) rack (>= 1.0.0) - rails (4.0.13) - actionmailer (= 4.0.13) - actionpack (= 4.0.13) - activerecord (= 4.0.13) - activesupport (= 4.0.13) + rails (4.1.9) + actionmailer (= 4.1.9) + actionpack (= 4.1.9) + actionview (= 4.1.9) + activemodel (= 4.1.9) + activerecord (= 4.1.9) + activesupport (= 4.1.9) bundler (>= 1.3.0, < 2.0) - railties (= 4.0.13) + railties (= 4.1.9) sprockets-rails (~> 2.0) rails3-generators (1.0.0) railties (>= 3.0.0) rails3-jquery-autocomplete (1.0.15) rails (>= 3.2) - railties (4.0.13) - actionpack (= 4.0.13) - activesupport (= 4.0.13) + railties (4.1.9) + actionpack (= 4.1.9) + activesupport (= 4.1.9) rake (>= 0.8.7) thor (>= 0.18.1, < 2.0) rake (10.4.2) @@ -424,28 +428,28 @@ GEM resque (~> 1.19) resque_mailer (2.2.7) actionmailer (>= 3.0) - rest-client (1.7.2) + rest-client (1.7.3) mime-types (>= 1.16, < 3.0) netrc (~> 0.7) rouge (1.3.4) rr (1.1.2) - rspec-core (3.2.0) + rspec-core (3.2.1) rspec-support (~> 3.2.0) rspec-expectations (3.2.0) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.2.0) - rspec-mocks (3.2.0) + rspec-mocks (3.2.1) diff-lcs (>= 1.2.0, < 2.0) rspec-support (~> 3.2.0) - rspec-rails (3.2.0) - actionpack (>= 3.0, <= 4.2) - activesupport (>= 3.0, <= 4.2) - railties (>= 3.0, <= 4.2) + rspec-rails (3.2.1) + actionpack (>= 3.0, < 4.3) + activesupport (>= 3.0, < 4.3) + railties (>= 3.0, < 4.3) rspec-core (~> 3.2.0) rspec-expectations (~> 3.2.0) rspec-mocks (~> 3.2.0) rspec-support (~> 3.2.0) - rspec-support (3.2.1) + rspec-support (3.2.2) ruby-haml-js (0.0.5) execjs sprockets (>= 2.0.0) @@ -461,17 +465,19 @@ GEM safe_yaml (1.0.4) sanitize (2.1.0) nokogiri (>= 1.4.4) - sass (3.4.12) - sass-rails (4.0.1) + sass (3.4.13) + sass-rails (5.0.1) railties (>= 4.0.0, < 5.0) - sass (>= 3.1.10) - sprockets-rails (~> 2.0.0) + sass (~> 3.1) + sprockets (>= 2.8, < 4.0) + sprockets-rails (>= 2.0, < 4.0) + tilt (~> 1.1) schema_plus (1.8.7) activerecord (>= 3.2, < 4.3) valuable scrivener (0.0.3) sexp_processor (4.4.5) - shotgun (0.9) + shotgun (0.9.1) rack (>= 1.0) shoulda (3.5.0) shoulda-context (~> 1.0, >= 1.0.1) @@ -479,7 +485,7 @@ GEM shoulda-context (1.2.1) shoulda-matchers (2.8.0) activesupport (>= 3.0.0) - simple_form (3.1.0.rc2) + simple_form (3.1.0) actionpack (~> 4.0) activemodel (~> 4.0) sinatra (1.4.5) @@ -497,17 +503,23 @@ GEM temple (~> 0.7.3) tilt (>= 1.3.3, < 2.1) soundmanager-rails (1.0.1) - sprockets (2.11.0) + sprockets (2.12.3) hike (~> 1.2) multi_json (~> 1.0) rack (~> 1.0) tilt (~> 1.1, != 1.3.0) - sprockets-rails (2.0.1) + sprockets-rails (2.2.4) actionpack (>= 3.0) activesupport (>= 3.0) - sprockets (~> 2.8) + sprockets (>= 2.8, < 4.0) sqlite3 (1.3.10) - state_machine (1.2.0) + state_machines (0.2.2) + state_machines-activemodel (0.1.2) + activemodel (~> 4.1) + state_machines (~> 0.2.0) + state_machines-activerecord (0.2.0) + activerecord (~> 4.1) + state_machines-activemodel (~> 0.1.0) stringex (2.5.2) temple (0.7.5) test_after_commit (0.4.0) @@ -525,15 +537,16 @@ GEM time_diff (0.3.0) activesupport i18n - timecop (0.7.1) + timecop (0.7.3) tmp_cache (0.1.1) twitter-text (1.11.0) unf (~> 0.1.0) - tzinfo (0.3.43) - uglifier (2.7.0) + tzinfo (1.2.2) + thread_safe (~> 0.1) + uglifier (2.7.1) execjs (>= 0.3.0) json (>= 1.8.0) - underscore-rails (1.7.0) + underscore-rails (1.8.2) unf (0.1.4) unf_ext unf_ext (0.0.6) @@ -563,46 +576,46 @@ PLATFORMS DEPENDENCIES RedCloth activeadmin! - airbrake (~> 3.1) - ancestry (~> 2.1) - angular-i18n (= 0.1.2) + airbrake + ancestry + angular-i18n angular-rails-templates angular-ui-bootstrap-rails - angularjs-rails (~> 1.2.15) - attr_encrypted (~> 1.3) + angularjs-rails + attr_encrypted better_errors binding_of_caller - bootstrap-sass (~> 3.3) + bootstrap-sass cancan! cape capistrano capistrano_colors - charlock_holmes (~> 0.7) + charlock_holmes codemirror-rails (~> 4.5) - coffee-rails (~> 4.1) - compass-rails (~> 2.0) + coffee-rails + compass-rails creole - devise (~> 3.3) - diff-display (~> 0.0.1) + devise + diff-display factory_girl_rails - ffi (~> 1.9.3) - font-awesome-rails (~> 4.2) - friendly_id (~> 5.0) - gemoji (~> 2.1) + ffi + font-awesome-rails + friendly_id + gemoji github-linguist (= 3.1.5) gollum-lib (~> 3.0) grack! grit! - haml-rails (~> 0.5) + haml-rails highline (~> 1.6.20) hirb - jbuilder (~> 2.2) + jbuilder jquery-migrate-rails - jquery-rails (~> 2.3) + jquery-rails js-routes localeapp mailcatcher - meta-tags (~> 2.0) + meta-tags meta_request mock_redis momentjs-rails @@ -615,50 +628,50 @@ DEPENDENCIES omniauth-facebook omniauth-github omniauth-google-oauth2 - paperclip (~> 4.2) + paperclip perform_later! - pg (~> 0.17.1) + pg protected_attributes puma rack-throttle (~> 0.3.0) - rails (= 4.0.13) + rails (= 4.1.9) rails3-generators rails3-jquery-autocomplete rake rdiscount redcarpet (~> 3.1) - redis-rails (~> 4.0) - resque (~> 1.25) + redis-rails + resque resque-scheduler (~> 2.5.4) - resque-status (~> 0.4) - resque_mailer (~> 2.2) - rest-client (~> 1.7) + resque-status + resque_mailer + rest-client rr rspec-rails - ruby-haml-js (~> 0.0.5) - russian (~> 0.6.0) + ruby-haml-js + russian rvm-capistrano - sass-rails (~> 4.0) + sass-rails schema_plus (~> 1.5) shotgun shoulda shoulda-matchers - simple_form (= 3.1.0.rc2) + simple_form sitemap_generator skype slim soundmanager-rails - sprockets (= 2.11.0) - state_machine (~> 1.2) + sprockets + state_machines-activerecord test_after_commit - therubyracer (~> 0.12.1) - therubyrhino (~> 2.0) + therubyracer + therubyrhino time_diff timecop - uglifier (~> 2.5) + uglifier underscore-rails webmock - whenever (~> 0.9.0) + whenever wikicloth - will_paginate (~> 3.0) - zeroclipboard-rails (~> 0.1.0) + will_paginate + zeroclipboard-rails diff --git a/app/assets/stylesheets/active_admin.css.scss b/app/assets/stylesheets/active_admin.scss similarity index 100% rename from app/assets/stylesheets/active_admin.css.scss rename to app/assets/stylesheets/active_admin.scss diff --git a/app/assets/stylesheets/custom_bootstrap.css.sass b/app/assets/stylesheets/custom_bootstrap.sass similarity index 100% rename from app/assets/stylesheets/custom_bootstrap.css.sass rename to app/assets/stylesheets/custom_bootstrap.sass diff --git a/app/assets/stylesheets/new_application.css.scss b/app/assets/stylesheets/new_application.scss similarity index 100% rename from app/assets/stylesheets/new_application.css.scss rename to app/assets/stylesheets/new_application.scss diff --git a/app/assets/stylesheets/views/blame.css.sass b/app/assets/stylesheets/views/blame.sass similarity index 100% rename from app/assets/stylesheets/views/blame.css.sass rename to app/assets/stylesheets/views/blame.sass diff --git a/app/assets/stylesheets/views/diff.css.sass b/app/assets/stylesheets/views/diff.sass similarity index 100% rename from app/assets/stylesheets/views/diff.css.sass rename to app/assets/stylesheets/views/diff.sass diff --git a/app/assets/stylesheets/views/error_pages.css.sass b/app/assets/stylesheets/views/error_pages.sass similarity index 100% rename from app/assets/stylesheets/views/error_pages.css.sass rename to app/assets/stylesheets/views/error_pages.sass diff --git a/app/assets/stylesheets/views/shared/log.css.sass b/app/assets/stylesheets/views/shared/log.sass similarity index 100% rename from app/assets/stylesheets/views/shared/log.css.sass rename to app/assets/stylesheets/views/shared/log.sass diff --git a/app/assets/stylesheets/views/statistics.css.sass b/app/assets/stylesheets/views/statistics.sass similarity index 100% rename from app/assets/stylesheets/views/statistics.css.sass rename to app/assets/stylesheets/views/statistics.sass diff --git a/app/controllers/advisories_controller.rb b/app/controllers/advisories_controller.rb index 3e2388636..fff0df8a5 100644 --- a/app/controllers/advisories_controller.rb +++ b/app/controllers/advisories_controller.rb @@ -1,6 +1,6 @@ class AdvisoriesController < ApplicationController - before_filter :authenticate_user! - skip_before_filter :authenticate_user! if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user! if APP_CONFIG['anonymous_access'] load_resource find_by: :advisory_id authorize_resource diff --git a/app/controllers/api/v1/advisories_controller.rb b/app/controllers/api/v1/advisories_controller.rb index 0d555dbf6..6688036ab 100644 --- a/app/controllers/api/v1/advisories_controller.rb +++ b/app/controllers/api/v1/advisories_controller.rb @@ -1,8 +1,8 @@ class Api::V1::AdvisoriesController < Api::V1::BaseController - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] load_resource :advisory, find_by: :advisory_id - before_filter :find_and_authorize_build_list, only: [:create, :update] + before_action :find_and_authorize_build_list, only: [:create, :update] authorize_resource :build_list, only: [:create, :update] def index diff --git a/app/controllers/api/v1/arches_controller.rb b/app/controllers/api/v1/arches_controller.rb index 28bc61caf..3968bad77 100644 --- a/app/controllers/api/v1/arches_controller.rb +++ b/app/controllers/api/v1/arches_controller.rb @@ -1,5 +1,5 @@ class Api::V1::ArchesController < Api::V1::BaseController - before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] + before_action :authenticate_user! unless APP_CONFIG['anonymous_access'] def index @arches = Arch.order(:id).paginate(paginate_params) diff --git a/app/controllers/api/v1/build_lists_controller.rb b/app/controllers/api/v1/build_lists_controller.rb index a87a7c717..8d1a1a67c 100644 --- a/app/controllers/api/v1/build_lists_controller.rb +++ b/app/controllers/api/v1/build_lists_controller.rb @@ -1,6 +1,6 @@ class Api::V1::BuildListsController < Api::V1::BaseController - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:show, :index] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:show, :index] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :build_list, only: [:show, :create, :cancel, :publish, :reject_publish, :create_container, :publish_into_testing, :rerun_tests] diff --git a/app/controllers/api/v1/groups_controller.rb b/app/controllers/api/v1/groups_controller.rb index 076b485d4..4ca344a1b 100644 --- a/app/controllers/api/v1/groups_controller.rb +++ b/app/controllers/api/v1/groups_controller.rb @@ -1,7 +1,7 @@ class Api::V1::GroupsController < Api::V1::BaseController - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access'] load_and_authorize_resource def index diff --git a/app/controllers/api/v1/issues_controller.rb b/app/controllers/api/v1/issues_controller.rb index fa90360b2..55d612e90 100644 --- a/app/controllers/api/v1/issues_controller.rb +++ b/app/controllers/api/v1/issues_controller.rb @@ -1,6 +1,6 @@ class Api::V1::IssuesController < Api::V1::BaseController - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:index, :group_index, :show] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:index, :group_index, :show] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :group, only: :group_index, find_by: :id, parent: false load_and_authorize_resource :project diff --git a/app/controllers/api/v1/jobs_controller.rb b/app/controllers/api/v1/jobs_controller.rb index bbb663609..915c19c18 100644 --- a/app/controllers/api/v1/jobs_controller.rb +++ b/app/controllers/api/v1/jobs_controller.rb @@ -4,7 +4,7 @@ class Api::V1::JobsController < Api::V1::BaseController QUEUES = %w(rpm_worker_observer) QUEUE_CLASSES = %w(AbfWorker::RpmWorkerObserver) - before_filter :authenticate_user! + before_action :authenticate_user! def shift @build_list = BuildList.next_build(arch_ids, platform_ids) if current_user.system? diff --git a/app/controllers/api/v1/maintainers_controller.rb b/app/controllers/api/v1/maintainers_controller.rb index 13170768e..a5045dbb8 100644 --- a/app/controllers/api/v1/maintainers_controller.rb +++ b/app/controllers/api/v1/maintainers_controller.rb @@ -1,5 +1,5 @@ class Api::V1::MaintainersController < Api::V1::BaseController - before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] + before_action :authenticate_user! unless APP_CONFIG['anonymous_access'] load_and_authorize_resource :platform def index diff --git a/app/controllers/api/v1/platforms_controller.rb b/app/controllers/api/v1/platforms_controller.rb index 6b070a1e2..1aeea6556 100644 --- a/app/controllers/api/v1/platforms_controller.rb +++ b/app/controllers/api/v1/platforms_controller.rb @@ -1,7 +1,7 @@ class Api::V1::PlatformsController < Api::V1::BaseController - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: :allowed - skip_before_filter :authenticate_user!, only: [:show, :platforms_for_build, :members] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: :allowed + skip_before_action :authenticate_user!, only: [:show, :platforms_for_build, :members] if APP_CONFIG['anonymous_access'] load_and_authorize_resource except: :allowed def allowed diff --git a/app/controllers/api/v1/product_build_lists_controller.rb b/app/controllers/api/v1/product_build_lists_controller.rb index b581a43e0..b05e06fe2 100644 --- a/app/controllers/api/v1/product_build_lists_controller.rb +++ b/app/controllers/api/v1/product_build_lists_controller.rb @@ -1,6 +1,6 @@ class Api::V1::ProductBuildListsController < Api::V1::BaseController - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :product, only: :index load_and_authorize_resource diff --git a/app/controllers/api/v1/products_controller.rb b/app/controllers/api/v1/products_controller.rb index 605781c73..3e51a3dbf 100644 --- a/app/controllers/api/v1/products_controller.rb +++ b/app/controllers/api/v1/products_controller.rb @@ -1,6 +1,6 @@ class Api::V1::ProductsController < Api::V1::BaseController - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] load_and_authorize_resource diff --git a/app/controllers/api/v1/projects_controller.rb b/app/controllers/api/v1/projects_controller.rb index 205dfea96..541121b9d 100644 --- a/app/controllers/api/v1/projects_controller.rb +++ b/app/controllers/api/v1/projects_controller.rb @@ -1,7 +1,7 @@ class Api::V1::ProjectsController < Api::V1::BaseController - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:get_id, :show, :refs_list] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:get_id, :show, :refs_list] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :project diff --git a/app/controllers/api/v1/pull_requests_controller.rb b/app/controllers/api/v1/pull_requests_controller.rb index a67ff04a3..1e68b6234 100644 --- a/app/controllers/api/v1/pull_requests_controller.rb +++ b/app/controllers/api/v1/pull_requests_controller.rb @@ -1,8 +1,8 @@ class Api::V1::PullRequestsController < Api::V1::BaseController respond_to :json - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:show, :index, :group_index, :commits, :files] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:show, :index, :group_index, :commits, :files] if APP_CONFIG['anonymous_access'] load_resource :group, only: :group_index, find_by: :id, parent: false load_resource :project diff --git a/app/controllers/api/v1/repositories_controller.rb b/app/controllers/api/v1/repositories_controller.rb index 353cdb447..389b958d9 100644 --- a/app/controllers/api/v1/repositories_controller.rb +++ b/app/controllers/api/v1/repositories_controller.rb @@ -1,8 +1,8 @@ class Api::V1::RepositoriesController < Api::V1::BaseController respond_to :csv, only: :packages - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:show, :projects] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:show, :projects] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :repository, through: :platform, shallow: true diff --git a/app/controllers/api/v1/search_controller.rb b/app/controllers/api/v1/search_controller.rb index ad9a1bfc3..ff27a2f24 100644 --- a/app/controllers/api/v1/search_controller.rb +++ b/app/controllers/api/v1/search_controller.rb @@ -1,5 +1,5 @@ class Api::V1::SearchController < Api::V1::BaseController - before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] + before_action :authenticate_user! unless APP_CONFIG['anonymous_access'] def index search = Search.new(params[:query], current_ability, paginate_params) diff --git a/app/controllers/api/v1/users_controller.rb b/app/controllers/api/v1/users_controller.rb index 12cd893a5..6dee2793b 100644 --- a/app/controllers/api/v1/users_controller.rb +++ b/app/controllers/api/v1/users_controller.rb @@ -1,9 +1,9 @@ class Api::V1::UsersController < Api::V1::BaseController - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:show] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :user, only: :show - before_filter :set_current_user, except: :show + before_action :set_current_user, except: :show def show @user = User.opened.find params[:id] # dont show system users diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index ef09b5d33..c30360a5f 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -9,12 +9,12 @@ class ApplicationController < ActionController::Base layout :layout_by_resource # Hack to prevent token auth on all pages except atom feed: - prepend_before_filter -> { redirect_to(new_user_session_path) if params[:token] && params[:token].is_a?(String) && params[:format] != 'atom'} + prepend_before_action -> { redirect_to(new_user_session_path) if params[:token] && params[:token].is_a?(String) && params[:format] != 'atom'} - before_filter :set_locale - before_filter -> { EventLog.current_controller = self }, + before_action :set_locale + before_action -> { EventLog.current_controller = self }, only: [:create, :destroy, :open_id, :cancel, :publish, :change_visibility] # :update - after_filter -> { EventLog.current_controller = nil } + after_action -> { EventLog.current_controller = nil } helper_method :get_owner diff --git a/app/controllers/autocompletes_controller.rb b/app/controllers/autocompletes_controller.rb index 2cebbc752..e6ec9bbc9 100644 --- a/app/controllers/autocompletes_controller.rb +++ b/app/controllers/autocompletes_controller.rb @@ -1,5 +1,5 @@ class AutocompletesController < ApplicationController - before_filter :authenticate_user! + before_action :authenticate_user! def autocomplete_user_uname results = User.opened.search(params[:query]).search_order.limit(5) diff --git a/app/controllers/groups/base_controller.rb b/app/controllers/groups/base_controller.rb index 7428bfbe4..8ae7d9344 100644 --- a/app/controllers/groups/base_controller.rb +++ b/app/controllers/groups/base_controller.rb @@ -1,6 +1,6 @@ class Groups::BaseController < ApplicationController - before_filter :authenticate_user! - before_filter :find_group + before_action :authenticate_user! + before_action :find_group protected diff --git a/app/controllers/groups/members_controller.rb b/app/controllers/groups/members_controller.rb index 01492a1e9..e70119a9c 100644 --- a/app/controllers/groups/members_controller.rb +++ b/app/controllers/groups/members_controller.rb @@ -1,5 +1,5 @@ class Groups::MembersController < Groups::BaseController - before_filter -> { authorize! :manage_members, @group } + before_action -> { authorize! :manage_members, @group } def index @members = @group.members.order(:uname) - [@group.owner] diff --git a/app/controllers/groups/profile_controller.rb b/app/controllers/groups/profile_controller.rb index 549bd1fe1..5c5d7b40b 100644 --- a/app/controllers/groups/profile_controller.rb +++ b/app/controllers/groups/profile_controller.rb @@ -3,7 +3,7 @@ class Groups::ProfileController < Groups::BaseController include PaginateHelper load_and_authorize_resource class: Group, instance_name: 'group' - skip_before_filter :authenticate_user!, only: :show if APP_CONFIG['anonymous_access'] + skip_before_action :authenticate_user!, only: :show if APP_CONFIG['anonymous_access'] def index @groups = current_user.groups.paginate(page: params[:group_page]) # accessible_by(current_ability) diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 39495990d..8f7450022 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -1,5 +1,5 @@ class HomeController < ApplicationController - before_filter :authenticate_user!, only: [:activity, :issues, :pull_requests] + before_action :authenticate_user!, only: [:activity, :issues, :pull_requests] def root render 'pages/tour/abf-tour-project-description-1' diff --git a/app/controllers/platforms/contents_controller.rb b/app/controllers/platforms/contents_controller.rb index 183a06f27..ee4a8e796 100644 --- a/app/controllers/platforms/contents_controller.rb +++ b/app/controllers/platforms/contents_controller.rb @@ -1,8 +1,8 @@ class Platforms::ContentsController < Platforms::BaseController include PaginateHelper - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: :index if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: :index if APP_CONFIG['anonymous_access'] load_and_authorize_resource :platform diff --git a/app/controllers/platforms/key_pairs_controller.rb b/app/controllers/platforms/key_pairs_controller.rb index f381f6e14..22522e6f0 100644 --- a/app/controllers/platforms/key_pairs_controller.rb +++ b/app/controllers/platforms/key_pairs_controller.rb @@ -1,5 +1,5 @@ class Platforms::KeyPairsController < Platforms::BaseController - before_filter :authenticate_user! + before_action :authenticate_user! load_and_authorize_resource :platform load_and_authorize_resource only: [:create, :destroy] diff --git a/app/controllers/platforms/maintainers_controller.rb b/app/controllers/platforms/maintainers_controller.rb index 8a3af467c..ba6f70eb6 100644 --- a/app/controllers/platforms/maintainers_controller.rb +++ b/app/controllers/platforms/maintainers_controller.rb @@ -1,6 +1,6 @@ class Platforms::MaintainersController < ApplicationController - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:index] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:index] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :platform def index diff --git a/app/controllers/platforms/mass_builds_controller.rb b/app/controllers/platforms/mass_builds_controller.rb index b09330b09..70daee366 100644 --- a/app/controllers/platforms/mass_builds_controller.rb +++ b/app/controllers/platforms/mass_builds_controller.rb @@ -1,8 +1,8 @@ class Platforms::MassBuildsController < Platforms::BaseController include DatatableHelper - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:index, :get_list] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:index, :get_list] if APP_CONFIG['anonymous_access'] load_resource :platform load_and_authorize_resource :through => :platform, :shallow => true diff --git a/app/controllers/platforms/platforms_controller.rb b/app/controllers/platforms/platforms_controller.rb index 9ff1a2060..8762c11c2 100644 --- a/app/controllers/platforms/platforms_controller.rb +++ b/app/controllers/platforms/platforms_controller.rb @@ -1,8 +1,8 @@ class Platforms::PlatformsController < Platforms::BaseController include FileStoreHelper - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:advisories, :members, :show] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:advisories, :members, :show] if APP_CONFIG['anonymous_access'] load_and_authorize_resource def index diff --git a/app/controllers/platforms/product_build_lists_controller.rb b/app/controllers/platforms/product_build_lists_controller.rb index 1198f674e..61a0241f0 100644 --- a/app/controllers/platforms/product_build_lists_controller.rb +++ b/app/controllers/platforms/product_build_lists_controller.rb @@ -1,9 +1,9 @@ class Platforms::ProductBuildListsController < Platforms::BaseController include FileStoreHelper - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:index, :show, :log] if APP_CONFIG['anonymous_access'] - before_filter :redirect_to_full_path_if_short_url, only: [:show, :update] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:index, :show, :log] if APP_CONFIG['anonymous_access'] + before_action :redirect_to_full_path_if_short_url, only: [:show, :update] load_and_authorize_resource :platform, except: :index load_and_authorize_resource :product, through: :platform, except: :index load_and_authorize_resource :product_build_list, through: :product, except: :index diff --git a/app/controllers/platforms/products_controller.rb b/app/controllers/platforms/products_controller.rb index e42b7a8c7..42eec8516 100644 --- a/app/controllers/platforms/products_controller.rb +++ b/app/controllers/platforms/products_controller.rb @@ -1,8 +1,8 @@ class Platforms::ProductsController < Platforms::BaseController include GitHelper - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :platform load_and_authorize_resource :product, through: :platform, except: :autocomplete_project diff --git a/app/controllers/platforms/repositories_controller.rb b/app/controllers/platforms/repositories_controller.rb index 3691b3308..d0a820b3e 100644 --- a/app/controllers/platforms/repositories_controller.rb +++ b/app/controllers/platforms/repositories_controller.rb @@ -4,12 +4,12 @@ class Platforms::RepositoriesController < Platforms::BaseController include RepositoriesHelper include PaginateHelper - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:index, :show, :projects_list] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:index, :show, :projects_list] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :platform load_and_authorize_resource :repository, through: :platform, shallow: true - before_filter :set_members, only: [:edit, :update] + before_action :set_members, only: [:edit, :update] def index @repositories = Repository.custom_sort(@repositories).paginate(page: current_page) diff --git a/app/controllers/platforms/tokens_controller.rb b/app/controllers/platforms/tokens_controller.rb index 636f626a3..49a58a722 100644 --- a/app/controllers/platforms/tokens_controller.rb +++ b/app/controllers/platforms/tokens_controller.rb @@ -1,5 +1,5 @@ class Platforms::TokensController < Platforms::BaseController - before_filter :authenticate_user! + before_action :authenticate_user! load_resource :platform load_and_authorize_resource :through => :platform, :shallow => true diff --git a/app/controllers/projects/base_controller.rb b/app/controllers/projects/base_controller.rb index 9157a8a10..626823400 100644 --- a/app/controllers/projects/base_controller.rb +++ b/app/controllers/projects/base_controller.rb @@ -1,6 +1,6 @@ class Projects::BaseController < ApplicationController - prepend_before_filter :find_project - before_filter :init_statistics + prepend_before_action :find_project + before_action :init_statistics protected diff --git a/app/controllers/projects/build_lists_controller.rb b/app/controllers/projects/build_lists_controller.rb index fae8c0822..983ef4d14 100644 --- a/app/controllers/projects/build_lists_controller.rb +++ b/app/controllers/projects/build_lists_controller.rb @@ -4,17 +4,17 @@ class Projects::BuildListsController < Projects::BaseController NESTED_ACTIONS = [:index, :new, :create] - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:show, :index, :log] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:show, :index, :log] if APP_CONFIG['anonymous_access'] - before_filter :find_build_list, only: [:show, :publish, :cancel, :update, :log, :create_container, :dependent_projects] + before_action :find_build_list, only: [:show, :publish, :cancel, :update, :log, :create_container, :dependent_projects] load_and_authorize_resource :project, only: [:new, :create] load_resource :project, only: :index, parent: false load_and_authorize_resource :build_list, through: :project, only: NESTED_ACTIONS, shallow: true load_and_authorize_resource except: NESTED_ACTIONS - before_filter :create_from_build_list, only: :new + before_action :create_from_build_list, only: :new def index authorize!(:show, @project) if @project diff --git a/app/controllers/projects/collaborators_controller.rb b/app/controllers/projects/collaborators_controller.rb index 5edae3e4d..be9a89c1f 100644 --- a/app/controllers/projects/collaborators_controller.rb +++ b/app/controllers/projects/collaborators_controller.rb @@ -1,12 +1,12 @@ class Projects::CollaboratorsController < Projects::BaseController respond_to :html, :json - before_filter :authenticate_user! + before_action :authenticate_user! load_resource :project - before_filter :authorize_collaborators + before_action :authorize_collaborators - before_filter :find_users - before_filter :find_groups + before_action :find_users + before_action :find_groups def index @collaborators = Collaborator.find_by_project(@project) diff --git a/app/controllers/projects/comments_controller.rb b/app/controllers/projects/comments_controller.rb index d4c1dc767..851ddf7d9 100644 --- a/app/controllers/projects/comments_controller.rb +++ b/app/controllers/projects/comments_controller.rb @@ -1,8 +1,8 @@ class Projects::CommentsController < Projects::BaseController - before_filter :authenticate_user! + before_action :authenticate_user! load_and_authorize_resource :project - before_filter :find_commentable - before_filter :find_or_build_comment + before_action :find_commentable + before_action :find_or_build_comment load_and_authorize_resource new: :new_line include CommentsHelper diff --git a/app/controllers/projects/commit_subscribes_controller.rb b/app/controllers/projects/commit_subscribes_controller.rb index 55e4fabce..28d61ac5c 100644 --- a/app/controllers/projects/commit_subscribes_controller.rb +++ b/app/controllers/projects/commit_subscribes_controller.rb @@ -1,8 +1,8 @@ class Projects::CommitSubscribesController < Projects::BaseController - before_filter :authenticate_user! + before_action :authenticate_user! load_and_authorize_resource :project - before_filter :find_commit + before_action :find_commit def create if Subscribe.subscribe_to_commit(@options) diff --git a/app/controllers/projects/git/base_controller.rb b/app/controllers/projects/git/base_controller.rb index 203c746ed..a52145470 100644 --- a/app/controllers/projects/git/base_controller.rb +++ b/app/controllers/projects/git/base_controller.rb @@ -1,13 +1,13 @@ class Projects::Git::BaseController < Projects::BaseController - before_filter :authenticate_user! + before_action :authenticate_user! if APP_CONFIG['anonymous_access'] - skip_before_filter :authenticate_user!, only: %i(show index blame raw archive diff tags branches) - before_filter :authenticate_user, only: %i(show index blame raw archive diff tags branches) + skip_before_action :authenticate_user!, only: %i(show index blame raw archive diff tags branches) + before_action :authenticate_user, only: %i(show index blame raw archive diff tags branches) end load_and_authorize_resource :project - before_filter :set_treeish_and_path - before_filter :set_branch_and_tree + before_action :set_treeish_and_path + before_action :set_branch_and_tree protected diff --git a/app/controllers/projects/git/blobs_controller.rb b/app/controllers/projects/git/blobs_controller.rb index a8c6c16f1..76d199b88 100644 --- a/app/controllers/projects/git/blobs_controller.rb +++ b/app/controllers/projects/git/blobs_controller.rb @@ -1,6 +1,6 @@ class Projects::Git::BlobsController < Projects::Git::BaseController - before_filter :set_blob - before_filter -> {authorize! :write, @project}, only: [:edit, :update] + before_action :set_blob + before_action -> {authorize! :write, @project}, only: [:edit, :update] def show end diff --git a/app/controllers/projects/git/trees_controller.rb b/app/controllers/projects/git/trees_controller.rb index 99e0f69f3..3d7dfcf69 100644 --- a/app/controllers/projects/git/trees_controller.rb +++ b/app/controllers/projects/git/trees_controller.rb @@ -1,11 +1,12 @@ class Projects::Git::TreesController < Projects::Git::BaseController - before_filter -> { redirect_to_project }, only: :show - skip_before_filter :set_branch_and_tree, :set_treeish_and_path, only: :archive - before_filter -> { raise Grit::NoSuchPathError if params[:treeish] != @branch.try(:name) }, only: [:branch, :destroy] + skip_before_action :set_branch_and_tree, only: :archive + skip_before_action :set_treeish_and_path, only: :archive + before_action :redirect_to_project, only: :show + before_action :resolve_treeish, only: [:branch, :destroy] - skip_authorize_resource :project, only: [:destroy, :restore_branch, :create] - before_filter -> { authorize!(:write, @project) }, only: [:destroy, :restore_branch, :create] + skip_authorize_resource :project, only: [:destroy, :restore_branch, :create] + before_action -> { authorize!(:write, @project) }, only: [:destroy, :restore_branch, :create] def show unless request.xhr? @@ -81,6 +82,10 @@ class Projects::Git::TreesController < Projects::Git::BaseController protected + def resolve_treeish + raise Grit::NoSuchPathError if params[:treeish] != @branch.try(:name) + end + def redirect_to_project if params[:treeish] == @project.resolve_default_branch && params[:path].blank? && !request.xhr? redirect_to @project diff --git a/app/controllers/projects/hooks_controller.rb b/app/controllers/projects/hooks_controller.rb index 1192a4b7e..d580e7c08 100644 --- a/app/controllers/projects/hooks_controller.rb +++ b/app/controllers/projects/hooks_controller.rb @@ -1,5 +1,5 @@ class Projects::HooksController < Projects::BaseController - before_filter :authenticate_user! + before_action :authenticate_user! load_and_authorize_resource :project load_and_authorize_resource :hook, through: :project diff --git a/app/controllers/projects/issues_controller.rb b/app/controllers/projects/issues_controller.rb index d8b00d7b8..6c4df4003 100644 --- a/app/controllers/projects/issues_controller.rb +++ b/app/controllers/projects/issues_controller.rb @@ -1,11 +1,11 @@ class Projects::IssuesController < Projects::BaseController NON_RESTFUL_ACTION = [:create_label, :update_label, :destroy_label] - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] load_resource :project load_and_authorize_resource :issue, through: :project, find_by: :serial_id, only: [:show, :edit, :update, :destroy, :new, :create, :index] - before_filter :load_and_authorize_label, only: NON_RESTFUL_ACTION - before_filter :find_collaborators, only: [:new, :create, :show, :search_collaborators] + before_action :load_and_authorize_label, only: NON_RESTFUL_ACTION + before_action :find_collaborators, only: [:new, :create, :show, :search_collaborators] layout false, only: [:update, :search_collaborators] diff --git a/app/controllers/projects/projects_controller.rb b/app/controllers/projects/projects_controller.rb index 03eab4223..819ad8e7f 100644 --- a/app/controllers/projects/projects_controller.rb +++ b/app/controllers/projects/projects_controller.rb @@ -2,9 +2,9 @@ class Projects::ProjectsController < Projects::BaseController include DatatableHelper include ProjectsHelper - before_filter :authenticate_user! + before_action :authenticate_user! load_and_authorize_resource id_param: :name_with_owner # to force member actions load - before_filter :who_owns, only: [:new, :create, :mass_import, :run_mass_import] + before_action :who_owns, only: [:new, :create, :mass_import, :run_mass_import] def index @projects = Project.accessible_by(current_ability, :membered).search(params[:search]) diff --git a/app/controllers/projects/pull_requests_controller.rb b/app/controllers/projects/pull_requests_controller.rb index 9f1c865c0..dd71e5ddc 100644 --- a/app/controllers/projects/pull_requests_controller.rb +++ b/app/controllers/projects/pull_requests_controller.rb @@ -1,11 +1,11 @@ class Projects::PullRequestsController < Projects::BaseController - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:index, :show] if APP_CONFIG['anonymous_access'] load_and_authorize_resource :project load_resource :issue, through: :project, find_by: :serial_id, parent: false, except: [:index, :autocomplete_to_project] load_and_authorize_resource instance_name: :pull, through: :issue, singleton: true, except: [:index, :autocomplete_to_project] - before_filter :find_collaborators, only: [:new, :create, :show] + before_action :find_collaborators, only: [:new, :create, :show] def new to_project = find_destination_project(false) diff --git a/app/controllers/projects/subscribes_controller.rb b/app/controllers/projects/subscribes_controller.rb index 992af9d0f..ac66411a3 100644 --- a/app/controllers/projects/subscribes_controller.rb +++ b/app/controllers/projects/subscribes_controller.rb @@ -1,5 +1,5 @@ class Projects::SubscribesController < Projects::BaseController - before_filter :authenticate_user! + before_action :authenticate_user! load_and_authorize_resource :project load_and_authorize_resource :issue, through: :project, find_by: :serial_id diff --git a/app/controllers/projects/wiki_controller.rb b/app/controllers/projects/wiki_controller.rb index bf8e462a6..3a6c08cc3 100644 --- a/app/controllers/projects/wiki_controller.rb +++ b/app/controllers/projects/wiki_controller.rb @@ -4,13 +4,13 @@ require 'cgi' class Projects::WikiController < Projects::BaseController WIKI_OPTIONS = {} - before_filter :authenticate_user! - skip_before_filter :authenticate_user!, only: [:show, :index, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages] if APP_CONFIG['anonymous_access'] + before_action :authenticate_user! + skip_before_action :authenticate_user!, only: [:show, :index, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages] if APP_CONFIG['anonymous_access'] load_resource :project - before_filter :authorize_read_actions, only: [:index, :show, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages] - before_filter :authorize_write_actions, only: [:edit, :update, :new, :create, :destroy, :revert, :revert_wiki, :preview] - before_filter :get_wiki + before_action :authorize_read_actions, only: [:index, :show, :git, :compare, :compare_wiki, :history, :wiki_history, :search, :pages] + before_action :authorize_write_actions, only: [:edit, :update, :new, :create, :destroy, :revert, :revert_wiki, :preview] + before_action :get_wiki def index @name = 'Home' diff --git a/app/controllers/search_controller.rb b/app/controllers/search_controller.rb index 12b452097..2291cddb6 100644 --- a/app/controllers/search_controller.rb +++ b/app/controllers/search_controller.rb @@ -1,7 +1,7 @@ class SearchController < ApplicationController include PaginateHelper - before_filter :authenticate_user! unless APP_CONFIG['anonymous_access'] + before_action :authenticate_user! unless APP_CONFIG['anonymous_access'] # load_and_authorize_resource def index diff --git a/app/controllers/users/base_controller.rb b/app/controllers/users/base_controller.rb index 1a8e47d92..c195b7706 100644 --- a/app/controllers/users/base_controller.rb +++ b/app/controllers/users/base_controller.rb @@ -1,6 +1,6 @@ class Users::BaseController < ApplicationController - before_filter :authenticate_user! - before_filter :find_user + before_action :authenticate_user! + before_action :find_user protected diff --git a/app/controllers/users/omniauth_callbacks_controller.rb b/app/controllers/users/omniauth_callbacks_controller.rb index 38fab90d6..ec02acebf 100644 --- a/app/controllers/users/omniauth_callbacks_controller.rb +++ b/app/controllers/users/omniauth_callbacks_controller.rb @@ -32,7 +32,7 @@ class Users::OmniauthCallbacksController < Devise::OmniauthCallbacksController def find_for_ouath(auth, resource=nil) provider, uid = auth['provider'], auth['uid'] - authentication = Authentication.find_or_initialize_by_provider_and_uid(provider, uid) + authentication = Authentication.find_or_initialize_by(provider: provider, uid: uid) if authentication.new_record? if user_signed_in? # New authentication method for current_user authentication.user = current_user diff --git a/app/controllers/users/profile_controller.rb b/app/controllers/users/profile_controller.rb index c2a68afa1..c3470371b 100644 --- a/app/controllers/users/profile_controller.rb +++ b/app/controllers/users/profile_controller.rb @@ -1,7 +1,7 @@ class Users::ProfileController < Users::BaseController include PaginateHelper - skip_before_filter :authenticate_user!, only: :show if APP_CONFIG['anonymous_access'] + skip_before_action :authenticate_user!, only: :show if APP_CONFIG['anonymous_access'] def show respond_to do |format| diff --git a/app/controllers/users/register_requests_controller.rb b/app/controllers/users/register_requests_controller.rb index ee79d8940..bbe23a47b 100644 --- a/app/controllers/users/register_requests_controller.rb +++ b/app/controllers/users/register_requests_controller.rb @@ -1,5 +1,5 @@ class Users::RegisterRequestsController < ApplicationController - before_filter :user_choose_locale + before_action :user_choose_locale layout 'invite' def new diff --git a/app/controllers/users/registrations_controller.rb b/app/controllers/users/registrations_controller.rb index 551232059..8bdf6807f 100644 --- a/app/controllers/users/registrations_controller.rb +++ b/app/controllers/users/registrations_controller.rb @@ -1,5 +1,5 @@ class Users::RegistrationsController < Devise::RegistrationsController - before_filter :update_sanitized_params, if: :devise_controller? + before_action :update_sanitized_params, if: :devise_controller? # POST /resource def create diff --git a/app/controllers/users/settings_controller.rb b/app/controllers/users/settings_controller.rb index 7a2724dfb..155bb64be 100644 --- a/app/controllers/users/settings_controller.rb +++ b/app/controllers/users/settings_controller.rb @@ -1,7 +1,7 @@ class Users::SettingsController < Users::BaseController include AvatarHelper - before_filter :set_current_user + before_action :set_current_user def profile if request.patch? diff --git a/app/controllers/users/ssh_keys_controller.rb b/app/controllers/users/ssh_keys_controller.rb index e5a4ec887..64c7575de 100644 --- a/app/controllers/users/ssh_keys_controller.rb +++ b/app/controllers/users/ssh_keys_controller.rb @@ -1,5 +1,5 @@ class Users::SshKeysController < Users::BaseController - before_filter :set_current_user + before_action :set_current_user def index @ssh_key = SshKey.new diff --git a/app/controllers/users/users_controller.rb b/app/controllers/users/users_controller.rb index f3aeaefc0..dd5b0c0e1 100644 --- a/app/controllers/users/users_controller.rb +++ b/app/controllers/users/users_controller.rb @@ -1,6 +1,6 @@ class Users::UsersController < Users::BaseController - skip_before_filter :authenticate_user!, only: [:allowed, :check, :discover] - before_filter :find_user_by_key, only: [:allowed, :discover] + skip_before_action :authenticate_user!, only: [:allowed, :check, :discover] + before_action :find_user_by_key, only: [:allowed, :discover] def allowed project = Project.find_by_owner_and_name! params[:project] diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 52e719ba1..a48fa5e0b 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -93,7 +93,7 @@ module ApplicationHelper end def alert_class(type) - case type.to_s + case type when 'error', 'alert' 'alert-danger' when 'notice' diff --git a/app/views/users/register_requests/new.html.haml b/app/views/users/register_requests/new.html.haml index c2d385d0b..fc808c9f6 100644 --- a/app/views/users/register_requests/new.html.haml +++ b/app/views/users/register_requests/new.html.haml @@ -4,7 +4,7 @@ - if flash.present? .flash - flash.each do |key, value| - .message{ title: key.to_s.humanize, class: (key == :alert ? "error" : key) } + .message{ title: key.to_s.humanize, class: (key == 'alert' ? "error" : key) } %p= value - form_for(@register_request, html: { class: "form login" }) do |f| .group.wat-cf diff --git a/config/initializers/cookies_serializer.rb b/config/initializers/cookies_serializer.rb new file mode 100644 index 000000000..54516e3f2 --- /dev/null +++ b/config/initializers/cookies_serializer.rb @@ -0,0 +1,3 @@ +# Be sure to restart your server when you modify this file. + +Rails.application.config.action_dispatch.cookies_serializer = :hybrid diff --git a/config/initializers/ransack.rb b/config/initializers/ransack.rb new file mode 100644 index 000000000..8c5059bb0 --- /dev/null +++ b/config/initializers/ransack.rb @@ -0,0 +1,2 @@ +# See: https://github.com/activerecord-hackery/ransack/commit/5c7bb9eaf315a85246a0087c76dff9e5847072a3 +Ransack::Adapters::ActiveRecord::Base.class_eval('remove_method :search') \ No newline at end of file diff --git a/config/routes.rb b/config/routes.rb index 777f8d425..cf5d28b50 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -297,7 +297,7 @@ Rosa::Application.routes.draw do get :mass_import end end - scope ':name_with_owner', constraints: { name_with_owner: Project::OWNER_AND_NAME_REGEXP } do # project + scope '*name_with_owner', constraints: { name_with_owner: Project::OWNER_AND_NAME_REGEXP } do # project scope as: 'project' do resources :wiki do collection do @@ -369,7 +369,7 @@ Rosa::Application.routes.draw do constraints Rosa::Constraints::Treeish do # Tree get '/' => "git/trees#show", as: :project - get '/tree/:treeish' => "git/trees#show", as: :tree, format: false + get '/tree/*treeish' => "git/trees#show", as: :tree, format: false # Tags get '/tags' => "git/trees#tags", as: :tags # Branches diff --git a/spec/controllers/api/v1/issues_controller_spec.rb b/spec/controllers/api/v1/issues_controller_spec.rb index 26a0918fc..84f9c915f 100644 --- a/spec/controllers/api/v1/issues_controller_spec.rb +++ b/spec/controllers/api/v1/issues_controller_spec.rb @@ -35,127 +35,139 @@ describe Api::V1::IssuesController, type: :controller do context 'read and accessible abilities' do context 'for user' do - before(:each) do + before do http_login(@issue.user) end it 'can show issue in own project' do get :show, project_id: @project.id, id: @issue.serial_id, format: :json - response.should be_success + expect(response).to be_success end it 'should render right template for show action' do get :show, project_id: @project.id, id: @issue.serial_id, format: :json - response.should render_template('api/v1/issues/show') + expect(response).to render_template('api/v1/issues/show') end it 'can show issue in open project' do get :show, project_id: @open_project.id, id: @open_issue.serial_id, format: :json - response.should be_success + expect(response).to be_success end it 'can show issue in own hidden project' do get :show, project_id: @own_hidden_project.id, id: @own_hidden_issue.serial_id, format: :json - response.should be_success + expect(response).to be_success end it "can't show issue in hidden project" do get :show, project_id: @hidden_project.id, id: @hidden_issue.serial_id, format: :json - response.status.should == 403 + expect(response.code).to eq '403' end it 'should return three issues' do get :all_index, filter: 'all', format: :json - assigns[:issues].should include(@issue) - assigns[:issues].should include(@own_hidden_issue) - assigns[:issues].should include(@membered_issue) + expect(assigns[:issues]).to include(@issue) + expect(assigns[:issues]).to include(@own_hidden_issue) + expect(assigns[:issues]).to include(@membered_issue) end it 'should render right template for all index action' do get :all_index, format: :json - response.should render_template('api/v1/issues/index') + expect(response).to render_template('api/v1/issues/index') end it 'should return only assigned issue' do get :user_index, format: :json - assigns[:issues].should include(@own_hidden_issue) + expect(assigns[:issues]).to include(@own_hidden_issue) expect(assigns[:issues].count).to eq 1 end it 'should render right template for user index action' do get :user_index, format: :json - response.should render_template('api/v1/issues/index') + expect(response).to render_template('api/v1/issues/index') end it 'should return 404' do get :show, project_id: @project.id, id: 999999, format: :json - response.status.should == 404 + expect(response.code).to eq '404' end it 'should redirect to pull request page' do - get :show, project_id: @project.id, id: @pull.serial_id, format: :json - response.should redirect_to(api_v1_project_pull_request_path(@project.id, @pull.serial_id)) + get :show, project_id: @project.id, id: @pull.reload.serial_id, format: :json + expect(response).to redirect_to(api_v1_project_pull_request_path(@project.id, @pull.serial_id)) end end context 'for anonymous user' do it 'can show issue in open project', anonymous_access: true do get :show, project_id: @project.id, id: @issue.serial_id, format: :json - response.should be_success + expect(response).to be_success end it "can't show issue in hidden project", anonymous_access: true do get :show, project_id: @hidden_project.id, id: @hidden_issue.serial_id, format: :json - response.status.should == 403 + expect(response.code).to eq '403' end it 'should not return any issues' do get :all_index, filter: 'all', format: :json - response.status.should == 401 + expect(response.code).to eq '401' end end end context 'create accessibility' do context 'for user' do - before(:each) do + before do http_login(@issue.user) end it 'can create issue in own project' do - lambda { post :create, @create_params}.should change{ Issue.count }.by(1) + expect do + post :create, @create_params + end.to change(Issue, :count).by(1) end it 'can create issue in own hidden project' do - lambda { post :create, @create_params.merge(project_id: @own_hidden_project.id)}.should change{ Issue.count }.by(1) + expect do + post :create, @create_params.merge(project_id: @own_hidden_project.id) + end.to change(Issue, :count).by(1) end it 'can create issue in open project' do - lambda { post :create, @create_params.merge(project_id: @open_project.id)}.should change{ Issue.count }.by(1) + expect do + post :create, @create_params.merge(project_id: @open_project.id) + end.to change(Issue, :count).by(1) end it "can't create issue in hidden project" do - lambda { post :create, @create_params.merge(project_id: @hidden_project.id)}.should change{ Issue.count }.by(0) + expect do + post :create, @create_params.merge(project_id: @hidden_project.id) + end.to change(Issue, :count).by(0) end it 'can assignee issue in own project' do post :create, @create_params.deep_merge(project_id: @own_hidden_project.id, issue: {assignee_id: @issue.user.id}) - @own_hidden_project.issues.order(:id).last.assignee.id.should == @issue.user.id + expect(@own_hidden_project.issues.order(:id).last.assignee.id).to eq @issue.user.id end it "can't assignee issue in open project" do post :create, @create_params.deep_merge(project_id: @open_project.id, issue: {assignee_id: @issue.user.id}) - @open_project.issues.order(:id).last.assignee.should be_nil + expect(@open_project.issues.order(:id).last.assignee).to be_nil end end context 'for anonymous user' do it "can't create issue in project", anonymous_access: true do - lambda { post :create, @create_params}.should change{ Issue.count }.by(0) + expect do + post :create, @create_params + end.to change(Issue, :count).by(0) end it "can't create issue in hidden project", anonymous_access: true do - lambda { post :create, @create_params.merge(project_id: @hidden_project.id)}.should change{ Issue.count }.by(0) + expect do + post :create, @create_params.merge(project_id: @hidden_project.id) + end.to change(Issue, :count).by(0) end end end @@ -168,47 +180,44 @@ describe Api::V1::IssuesController, type: :controller do it 'can update issue in own project' do put :update, @update_params - @issue.reload.title.should == 'new title' + expect(@issue.reload.title).to eq 'new title' end it 'can update issue in own hidden project' do put :update, @update_params.merge(project_id: @own_hidden_project.id, id: @own_hidden_issue.serial_id) - @own_hidden_issue.reload.title.should == 'new title' + expect(@own_hidden_issue.reload.title).to eq 'new title' end it "can't update issue in open project" do put :update, @update_params.merge(project_id: @open_project.id, id: @open_issue.serial_id) - @open_issue.reload.title.should_not == 'new title' + expect(@open_issue.reload.title).to_not eq 'new title' end it "can't update issue in hidden project" do put :update, @update_params.merge(project_id: @hidden_project.id, id: @hidden_issue.serial_id) - @hidden_issue.reload.title.should_not == 'title' + expect(@hidden_issue.reload.title).to_not eq 'title' end it "can't assignee issue in open project" do post :create, @update_params.deep_merge(project_id: @open_project.id, issue: {assignee_id: @issue.user.id}) - @open_issue.reload.assignee.id.should_not == @issue.user.id + expect(@open_issue.reload.assignee.id).to_not eq @issue.user.id end it 'can assignee issue in own project' do post :create, @update_params.deep_merge(issue: {assignee_id: @issue.user.id}) - @issue.reload.assignee.id.should_not == @issue.user.id + expect(@issue.reload.assignee.id).to_not eq @issue.user.id end end context 'for anonymous user' do - before(:each) do - @count = Issue.count - end it "can't update issue in project", anonymous_access: true do put :update, @update_params - response.status.should == 401 + expect(response.code).to eq '401' end it "can't update issue in hidden project", anonymous_access: true do put :update, @update_params.merge(project_id: @hidden_project.id, id: @hidden_issue.serial_id) - response.status.should == 401 + expect(response.code).to eq '401' end end end diff --git a/spec/controllers/projects/issues_controller_spec.rb b/spec/controllers/projects/issues_controller_spec.rb index 3da31bb84..dd1da75e0 100644 --- a/spec/controllers/projects/issues_controller_spec.rb +++ b/spec/controllers/projects/issues_controller_spec.rb @@ -40,12 +40,12 @@ end shared_examples_for 'issue user with project guest rights' do it 'should be able to perform index action' do get :index, name_with_owner: @project.name_with_owner - response.should render_template(:index) + expect(response).to render_template(:index) end it 'should be able to perform show action' do get :show, name_with_owner: @project.name_with_owner, id: @issue.serial_id - response.should render_template(:show) + expect(response).to render_template(:show) end end @@ -54,16 +54,18 @@ shared_examples_for 'issue user with project reader rights' do it 'should be able to perform index action on hidden project' do @project.update_attributes(visibility: 'hidden') get :index, name_with_owner: @project.name_with_owner - response.should render_template(:index) + expect(response).to render_template(:index) end it 'should be able to perform create action' do post :create, @create_params - response.should redirect_to(project_issues_path(@project)) + expect(response).to redirect_to(project_issues_path(@project)) end it 'should create issue object into db' do - lambda{ post :create, @create_params }.should change{ Issue.count }.by(1) + expect do + post :create, @create_params + end.to change(Issue, :count).by(1) end end @@ -71,18 +73,20 @@ shared_examples_for 'issue user with project writer rights' do it 'should be able to perform index action on hidden project' do @project.update_attributes(visibility: 'hidden') get :index, name_with_owner: @project.name_with_owner - response.should render_template(:index) + expect(response).to render_template(:index) end it 'should create issue object into db' do - lambda{ post :create, @create_params }.should change{ Issue.count }.by(1) + expect do + post :create, @create_params + end.to change(Issue, :count).by(1) end context 'perform create action' do before { post :create, @create_params } it 'user should be assigned to issue' do - @project.issues.last.assignee_id.should_not be_nil + expect(@project.issues.last.assignee_id).to_not be_nil end it 'label should be attached to issue' do @@ -94,47 +98,49 @@ end shared_examples_for 'user with issue update rights' do it 'should be able to perform update action' do put :update, {id: @issue.serial_id}.merge(@update_params) - response.code.should eq('200') + expect(response).to be_success end it 'should update issue title' do put :update, {id: @issue.serial_id}.merge(@update_params) - @issue.reload.title.should == 'issue2' + expect(@issue.reload.title).to eq 'issue2' end end shared_examples_for 'user without issue update rights' do it 'should not be able to perform update action' do put :update, {id: @issue.serial_id}.merge(@update_params) - response.should redirect_to(forbidden_path) + expect(response).to redirect_to(forbidden_path) end it 'should not update issue title' do put :update, {id: @issue.serial_id}.merge(@update_params) - @issue.reload.title.should_not == 'issue2' + expect(@issue.reload.title).to_not eq 'issue2' end end # shared_examples_for 'user without issue destroy rights' do # it 'should not be able to perform destroy action' do # delete :destroy, id: @issue.serial_id, name_with_owner: @project.name_with_owner -# response.should redirect_to(controller.current_user ? forbidden_path : new_user_session_path) +# expect(response).to redirect_to(controller.current_user ? forbidden_path : new_user_session_path) # end # it 'should not reduce issues count' do -# lambda{ delete :destroy, id: @issue.serial_id, name_with_owner: @project.name_with_owner }.should_not change{ Issue.count } +# expect +# delete :destroy, id: @issue.serial_id, name_with_owner: @project.name_with_owner +# end.to change(Issue, :count).by(0) # end # end shared_examples_for 'project with issues turned off' do it 'should not be able to perform index action' do get :index, name_with_owner: @project_with_turned_off_issues.name_with_owner - response.should redirect_to(forbidden_path) + expect(response).to redirect_to(forbidden_path) end it 'should not be able to perform show action' do get :show, name_with_owner: @project_with_turned_off_issues.name_with_owner, id: @turned_of_issue.serial_id - response.should redirect_to(forbidden_path) + expect(response).to redirect_to(forbidden_path) end end @@ -142,7 +148,7 @@ describe Projects::IssuesController, type: :controller do include_context "issues controller" context 'for global admin user' do - before(:each) do + before do @user.role = "admin" @user.save end @@ -156,7 +162,7 @@ describe Projects::IssuesController, type: :controller do end context 'for project admin user' do - before(:each) do + before do create_relation(@project, @user, 'admin') end @@ -169,7 +175,7 @@ describe Projects::IssuesController, type: :controller do end context 'for project owner user' do - before(:each) do + before do @user = @project.owner set_session_for(@user) end @@ -183,7 +189,7 @@ describe Projects::IssuesController, type: :controller do end context 'for project reader user' do - before(:each) do + before do create_relation(@project, @user, 'reader') end @@ -197,7 +203,7 @@ describe Projects::IssuesController, type: :controller do before { post :create, @create_params } it 'user should not be assigned to issue' do - @project.issues.last.assignee_id.should be_nil + expect(@project.issues.last.assignee_id).to be_nil end it 'label should not be attached to issue' do @@ -207,26 +213,28 @@ describe Projects::IssuesController, type: :controller do # it 'should not be able to perform create action on project' do # post :create, @create_params - # response.should redirect_to(forbidden_path) + # expect(response).to redirect_to(forbidden_path) # end # it 'should not create issue object into db' do - # lambda{ post :create, @create_params }.should change{ Issue.count }.by(0) + # expect + # post :create, @create_params + # end.to change(Issue, :count).by(0) # end it 'should return 404' do get :show, name_with_owner: @project.name_with_owner, id: 999999 - render_template(file: "#{Rails.root}/public/404.html") + expect(response).to render_template(file: "#{Rails.root}/public/404.html") end it 'should redirect to pull request page' do - get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id - response.should redirect_to(project_pull_request_path(@project, @pull)) + get :show, name_with_owner: @project.name_with_owner, id: @pull.reload.serial_id + expect(response).to redirect_to(project_pull_request_path(@project, @pull)) end end context 'for project writer user' do - before(:each) do + before do create_relation(@project, @user, 'writer') end @@ -239,7 +247,7 @@ describe Projects::IssuesController, type: :controller do end context 'for issue assign user' do - before(:each) do + before do set_session_for(@issue_user) end @@ -250,7 +258,7 @@ describe Projects::IssuesController, type: :controller do context 'for guest' do - before(:each) do + before do set_session_for(User.new) end @@ -261,45 +269,47 @@ describe Projects::IssuesController, type: :controller do it 'should not be able to perform index action on hidden project' do @project.update_attributes(visibility: 'hidden') get :index, name_with_owner: @project.name_with_owner - response.should redirect_to(forbidden_path) + expect(response).to redirect_to(forbidden_path) end else it 'should not be able to perform index action' do get :index, name_with_owner: @project.name_with_owner - response.should redirect_to(new_user_session_path) + expect(response).to redirect_to(new_user_session_path) end it 'should not be able to perform show action' do get :show, name_with_owner: @project.name_with_owner, id: @issue.serial_id - response.should redirect_to(new_user_session_path) + expect(response).to redirect_to(new_user_session_path) end it 'should not be able to perform index action on hidden project' do @project.update_attributes(visibility: 'hidden') get :index, name_with_owner: @project.name_with_owner - response.should redirect_to(new_user_session_path) + expect(response).to redirect_to(new_user_session_path) end end it 'should not be able to perform create action' do post :create, @create_params - response.should redirect_to(new_user_session_path) + expect(response).to redirect_to(new_user_session_path) end it 'should not create issue object into db' do - lambda{ post :create, @create_params }.should_not change{ Issue.count } + expect do + post :create, @create_params + end.to change(Issue, :count).by(0) end #it_should_behave_like 'user without issue update rights' it 'should not be able to perform update action' do put :update, {id: @issue.serial_id}.merge(@update_params) - response.status.should == 401 + expect(response.code).to eq '401' end it 'should not update issue title' do put :update, {id: @issue.serial_id}.merge(@update_params) - @issue.reload.title.should_not == 'issue2' + expect(@issue.reload.title).to_not eq 'issue2' end # it_should_behave_like 'user without issue destroy rights' diff --git a/spec/controllers/projects/pull_requests_controller_spec.rb b/spec/controllers/projects/pull_requests_controller_spec.rb index 87050b4d0..b173730b6 100644 --- a/spec/controllers/projects/pull_requests_controller_spec.rb +++ b/spec/controllers/projects/pull_requests_controller_spec.rb @@ -21,7 +21,7 @@ shared_context "pull request controller" do to_project: @project.name_with_owner, name_with_owner: @project.name_with_owner } - @update_params = @create_params.merge(pull_request_action: 'close', id: @pull.serial_id) + @update_params = @create_params.merge(pull_request_action: 'close', id: @pull.reload.serial_id) @wrong_update_params = @create_params.merge( pull_request: { issue_attributes: { title: 'update', body: 'updating', id: @pull.issue.id }}, id: @pull.serial_id @@ -38,114 +38,124 @@ shared_examples_for 'pull request user with project guest rights' do it 'should be able to perform show action when pull request has been created' do @pull.check get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id - response.should render_template(:show) + expect(response).to render_template(:show) end end shared_examples_for 'pull request user with project reader rights' do it 'should be able to perform create action' do post :create, @create_params - response.should redirect_to(project_pull_request_path(@project, @project.pull_requests.last)) + expect(response).to redirect_to(project_pull_request_path(@project, @project.pull_requests.last)) end it 'should create pull request object into db' do - lambda{ post :create, @create_params }.should change{ PullRequest.joins(:issue). - where(issues: {title: 'create', body: 'creating'}).count }.by(1) + expect do + post :create, @create_params + end.to change { + PullRequest.joins(:issue).where(issues: {title: 'create', body: 'creating'}).count + }.by(1) end it "should not create same pull" do - post :create, @create_params.merge({pull_request: {issue_attributes: {title: 'same', body: 'creating'}, from_ref: 'non_conflicts', to_ref: 'master'}, to_project_id: @project.id}) - PullRequest.joins(:issue).where(issues: {title: 'same', body: 'creating'}).count.should == 0 + expect do + post :create, @create_params.merge({pull_request: {issue_attributes: {title: 'same', body: 'creating'}, from_ref: 'non_conflicts', to_ref: 'master'}, to_project_id: @project.id}) + end.to change(PullRequest, :count).by(0) end it "should not create already up-to-date pull" do - lambda{ + expect do post :create, @create_params.merge({pull_request: {issue_attributes: {title: 'already', body: 'creating'}, - to_ref: 'master', from_ref: 'master'}, to_project_id: @project.id}) }.should - change{ PullRequest.count }.by(0) + to_ref: 'master', from_ref: 'master'}, to_project_id: @project.id}) + end.to change(PullRequest, :count).by(0) end it "should create pull request to the same project" do @parent = FactoryGirl.create(:project) @project.update_attributes({parent_id: @parent}, without_protection: true) - lambda{ post :create, @create_params }.should change{ PullRequest.joins(:issue). - where(issues: {user_id: @user}, to_project_id: @project, from_project_id: @project).count }.by(1) + expect do + post :create, @create_params + end.to change { + PullRequest.joins(:issue).where(issues: {user_id: @user}, to_project_id: @project, from_project_id: @project).count + }.by(1) end it "should create pull request to the parent project" do @parent = FactoryGirl.create(:project_with_commit) @project.update_attributes({parent_id: @parent}, without_protection: true) - lambda{ post :create, @create_params.merge({to_project: @parent.name_with_owner}) }.should change{ PullRequest.joins(:issue). - where(issues: {user_id: @user}, to_project_id: @parent, from_project_id: @project).count }.by(1) + expect do + post :create, @create_params.merge({to_project: @parent.name_with_owner}) + end.to change { + PullRequest.joins(:issue).where(issues: {user_id: @user}, to_project_id: @parent, from_project_id: @project).count + }.by(1) end end shared_examples_for 'user with pull request update rights' do it 'should be able to perform update action' do put :update, @update_params - response.should be_success + expect(response).to be_success end it 'should be able to perform merge action' do @pull.check put :merge, @update_params - response.should be_success + expect(response).to be_success end let(:pull) { @project.pull_requests.find(@pull) } it 'should update pull request status' do put :update, @update_params - pull.status.should =='closed' + expect(pull.status).to eq 'closed' end it 'should not update pull request title' do put :update, @wrong_update_params - pull.issue.title.should =='test' + expect(pull.issue.title).to eq 'test' end it 'should not update pull request body' do put :update, @wrong_update_params - pull.issue.body.should =='testing' + expect(pull.issue.body).to eq 'testing' end it 'should not update pull request title direct' do put :update, @wrong_update_params - pull.issue.title.should_not =='update' + expect(pull.issue.title).to_not eq 'update' end it 'should not update pull request body direct' do put :update, @wrong_update_params - pull.issue.body.should_not =='updating' + expect(pull.issue.body).to_not eq 'updating' end end shared_examples_for 'user without pull request update rights' do it 'should not be able to perform update action' do put :update, @update_params - response.should redirect_to(controller.current_user ? forbidden_path : new_user_session_path) + expect(response).to redirect_to(controller.current_user ? forbidden_path : new_user_session_path) end let(:pull) { @project.pull_requests.find(@pull) } it 'should not update pull request status' do put :update, @update_params - pull.status.should_not =='closed' + expect(pull.status).to_not eq 'closed' end it 'should not update pull request title' do put :update, @wrong_update_params - pull.issue.title.should_not =='update' + expect(pull.issue.title).to_not eq 'update' end it 'should not update pull request body' do put :update, @wrong_update_params - pull.issue.body.should_not =='updating' + expect(pull.issue.body).to_not eq 'updating' end it 'should not be able to perform merge action' do @pull.check put :merge, @update_params - response.should_not be_success + expect(response).to_not be_success end end @@ -156,7 +166,7 @@ shared_examples_for 'pull request when project with issues turned off' do it 'should be able to perform show action when pull request has been created' do @pull.check get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id - response.should render_template(:show) + expect(response).to render_template(:show) end end @@ -210,12 +220,12 @@ describe Projects::PullRequestsController, type: :controller do it 'should return 404' do get :show, name_with_owner: @project.name_with_owner, id: 999999 - render_template(file: "#{Rails.root}/public/404.html") + expect(response).to render_template(file: "#{Rails.root}/public/404.html") end it 'should redirect to issue page' do get :show, name_with_owner: @project.name_with_owner, id: @issue.serial_id - response.should redirect_to(project_issue_path(@project, @issue)) + expect(response).to redirect_to(project_issue_path(@project, @issue)) end end @@ -256,24 +266,26 @@ describe Projects::PullRequestsController, type: :controller do it 'should not be able to perform show action' do @pull.check get :show, name_with_owner: @project.name_with_owner, id: @pull.serial_id - response.should redirect_to(new_user_session_path) + expect(response).to redirect_to(new_user_session_path) end end it 'should not be able to perform create action' do post :create, @create_params - response.should redirect_to(new_user_session_path) + expect(response).to redirect_to(new_user_session_path) end it 'should not create pull request object into db' do - lambda{ post :create, @create_params }.should_not change{ PullRequest.count } + expect do + post :create, @create_params + end.to change(PullRequest, :count).by(0) end it_should_behave_like 'user without pull request update rights' end context 'send email messages' do - before(:each) do + before do @project_reader = FactoryGirl.create :user create_relation(@project, @project_reader, 'reader') @project_admin = FactoryGirl.create :user @@ -286,19 +298,22 @@ describe Projects::PullRequestsController, type: :controller do end it 'should send two email messages to project admins' do - post :create, @create_params - ActionMailer::Base.deliveries.count.should == 2 + expect do + post :create, @create_params + end.to change(ActionMailer::Base.deliveries, :count).by(2) end it 'should send two email messages to admins and one to assignee' do - post :create, @create_params.deep_merge(issue: {assignee_id: @project_reader.id}) - ActionMailer::Base.deliveries.count.should == 3 + expect do + post :create, @create_params.deep_merge(issue: {assignee_id: @project_reader.id}) + end.to change(ActionMailer::Base.deliveries, :count).by(3) end it 'should not duplicate email message' do - post :create, @create_params.deep_merge(issue: {assignee_id: @project_admin.id}) - ActionMailer::Base.deliveries.count.should == 2 # send only to admins - ActionMailer::Base.deliveries.first.to != ActionMailer::Base.deliveries.last.to + expect do + post :create, @create_params.deep_merge(issue: {assignee_id: @project_admin.id}) + end.to change(ActionMailer::Base.deliveries, :count).by(2) # send only to admins + expect(ActionMailer::Base.deliveries.first.to).to_not eq ActionMailer::Base.deliveries.last.to end end end