diff --git a/Gemfile b/Gemfile index 5d75a2601..6b962805a 100644 --- a/Gemfile +++ b/Gemfile @@ -29,7 +29,7 @@ gem 'pivotal-tracker', '0.5.8' gem 'rails', '4.0.4' gem 'rake' gem 'xpath' -gem 'whenever', :require => false +gem 'whenever', require: false gem 'rails-backbone' gem 'coffee-rails', '~> 4.0.0' gem 'eco' diff --git a/Rakefile b/Rakefile index 9423720bf..b93f2a901 100644 --- a/Rakefile +++ b/Rakefile @@ -16,4 +16,4 @@ rescue LoadError STDERR.puts "Run `rake gems:install` to install delayed_job" end -task :default => [:jshint, "jasmine:compile_coffeescript", "jasmine:ci"] +task default: [:jshint, "jasmine:compile_coffeescript", "jasmine:ci"] diff --git a/Vagrantfile b/Vagrantfile index 94b410667..1f56a2f74 100644 --- a/Vagrantfile +++ b/Vagrantfile @@ -74,7 +74,7 @@ Vagrant::Config.run do |config| chef.add_recipe "teamcity" # You may also specify custom JSON attributes: - chef.json = { :mysql_password => "foo" } + chef.json = { mysql_password: "foo" } end # Enable provisioning with chef server, specifying the chef server URL, diff --git a/app/controllers/aggregate_projects_controller.rb b/app/controllers/aggregate_projects_controller.rb index c2c5f5965..2a272e41d 100644 --- a/app/controllers/aggregate_projects_controller.rb +++ b/app/controllers/aggregate_projects_controller.rb @@ -1,6 +1,6 @@ class AggregateProjectsController < ApplicationController - before_filter :authenticate_user!, :except => [:show, :status, :index] - before_filter :load_aggregate_project, :only => [:show, :edit, :update, :destroy] + before_filter :authenticate_user!, except: [:show, :status, :index] + before_filter :load_aggregate_project, only: [:show, :edit, :update, :destroy] respond_to :json, only: [:index, :show] diff --git a/app/controllers/home_controller.rb b/app/controllers/home_controller.rb index 35376c8a9..2c20d561e 100644 --- a/app/controllers/home_controller.rb +++ b/app/controllers/home_controller.rb @@ -3,9 +3,9 @@ class HomeController < ApplicationController skip_filter :authenticate_user! - respond_to :html, :only => [:styleguide] - respond_to :rss, :only => :builds - respond_to :json, :only => [:github_status, :heroku_status, :rubygems_status, :index] + respond_to :html, only: [:styleguide] + respond_to :rss, only: :builds + respond_to :json, only: [:github_status, :heroku_status, :rubygems_status, :index] def index if aggregate_project_id = params[:aggregate_project_id] diff --git a/app/controllers/omniauth_callbacks_controller.rb b/app/controllers/omniauth_callbacks_controller.rb index 6f4540b15..bc7f85972 100644 --- a/app/controllers/omniauth_callbacks_controller.rb +++ b/app/controllers/omniauth_callbacks_controller.rb @@ -3,8 +3,8 @@ def google_oauth2 @user = User.find_for_google_oauth2(request.env["omniauth.auth"], current_user) if @user.persisted? - flash[:notice] = I18n.t "devise.omniauth_callbacks.success", :kind => "Google" - sign_in_and_redirect @user, :event => :authentication + flash[:notice] = I18n.t "devise.omniauth_callbacks.success", kind: "Google" + sign_in_and_redirect @user, event: :authentication else session["devise.google_data"] = request.env["omniauth.auth"] redirect_to edit_configuration_url diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 054c75cad..12146f0cb 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,6 +1,6 @@ class ProjectsController < ApplicationController - skip_filter :authenticate_user!, :only => [:show, :status, :index] - before_filter :load_project, :only => [:edit, :update, :destroy] + skip_filter :authenticate_user!, only: [:show, :status, :index] + before_filter :load_project, only: [:edit, :update, :destroy] around_filter :scope_by_aggregate_project respond_to :json, only: [:index, :show] @@ -82,7 +82,7 @@ def validate_build_info project_updater = ProjectUpdater.new(payload_processor: PayloadProcessor.new(project_status_updater: status_updater)) log_entry = project_updater.update(project) - render :json => { + render json: { status: log_entry.status == 'successful', error_type: log_entry.error_type, error_text: log_entry.error_text.to_s[0,10000] diff --git a/app/controllers/versions_controller.rb b/app/controllers/versions_controller.rb index 5ca5209c6..f9d687c35 100644 --- a/app/controllers/versions_controller.rb +++ b/app/controllers/versions_controller.rb @@ -5,7 +5,7 @@ class VersionsController < ApplicationController VERSION_PATH = File.join(Rails.root, 'VERSION') def show - render :text => version + render text: version end private diff --git a/app/models/aggregate_project.rb b/app/models/aggregate_project.rb index db27cee86..763a47268 100644 --- a/app/models/aggregate_project.rb +++ b/app/models/aggregate_project.rb @@ -1,13 +1,13 @@ class AggregateProject < ActiveRecord::Base has_many :projects - before_destroy { |record| record.projects.update_all :aggregate_project_id => nil } + before_destroy { |record| record.projects.update_all aggregate_project_id: nil } scope :enabled, -> { where(enabled: true) } - scope :with_statuses, -> { joins(:projects => :statuses).uniq } + scope :with_statuses, -> { joins(projects: :statuses).uniq } scope :displayable, lambda { |tags=nil| scope = enabled.joins(:projects).select("DISTINCT aggregate_projects.*").order('code ASC') - return scope.tagged_with(tags, :any => true) if tags + return scope.tagged_with(tags, any: true) if tags scope } diff --git a/app/models/external_dependency.rb b/app/models/external_dependency.rb index 123971201..ce026cb21 100644 --- a/app/models/external_dependency.rb +++ b/app/models/external_dependency.rb @@ -3,13 +3,13 @@ class ExternalDependency class << self def get_or_fetch(name, threshold=30) name.downcase! - Rails.cache.fetch(name, :expires_in => threshold.seconds) { refresh_status(name) } + Rails.cache.fetch(name, expires_in: threshold.seconds) { refresh_status(name) } end def fetch_status(name) name.downcase! status = refresh_status(name) - Rails.cache.write(name, status, :expires_in => 30.seconds) + Rails.cache.write(name, status, expires_in: 30.seconds) status end diff --git a/app/models/project.rb b/app/models/project.rb index 8c78e4da5..ce70e8c47 100644 --- a/app/models/project.rb +++ b/app/models/project.rb @@ -35,7 +35,7 @@ class Project < ActiveRecord::Base scope :displayable, lambda { |tags| scope = enabled.order('code ASC') - return scope.tagged_with(tags, :any => true) if tags + return scope.tagged_with(tags, any: true) if tags scope } diff --git a/app/models/user.rb b/app/models/user.rb index 650bf7a1d..4075472dd 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -8,13 +8,13 @@ class User < ActiveRecord::Base validates :password, confirmation: true validates :login, presence: true, length: 2..40, uniqueness: true - validates_length_of :name, :maximum => 100 + validates_length_of :name, maximum: 100 validates :email, presence: true, length: 6..100, uniqueness: true def self.find_first_by_auth_conditions(warden_conditions) conditions = warden_conditions.dup if login = conditions.delete(:login) - where(conditions).where(["lower(login) = :value OR lower(email) = :value", { :value => login.downcase }]).first + where(conditions).where(["lower(login) = :value OR lower(email) = :value", { value: login.downcase }]).first else where(conditions).first end @@ -22,7 +22,7 @@ def self.find_first_by_auth_conditions(warden_conditions) def self.find_for_google_oauth2(access_token, signed_in_resource=nil) data = access_token.info - user = User.where(:email => data["email"]).first + user = User.where(email: data["email"]).first user || User.create!(name: data["name"], email: data["email"], login: data["email"].split('@').first, diff --git a/app/views/aggregate_projects/_form.html.haml b/app/views/aggregate_projects/_form.html.haml index 5fc1f7e17..fc504a226 100644 --- a/app/views/aggregate_projects/_form.html.haml +++ b/app/views/aggregate_projects/_form.html.haml @@ -15,7 +15,7 @@ .form-group = f.label :tag_list, "Tags", class: "col-sm-2 control-label" .col-sm-2 - = f.text_field :tag_list, :size=>40, class: "form-control" + = f.text_field :tag_list, size: 40, class: "form-control" %p.help-block (separate with commas) .row .col-sm-offset-2.col-sm-1 diff --git a/app/views/aggregate_projects/edit.html.haml b/app/views/aggregate_projects/edit.html.haml index 17590afe9..99be01c51 100644 --- a/app/views/aggregate_projects/edit.html.haml +++ b/app/views/aggregate_projects/edit.html.haml @@ -2,6 +2,6 @@ %h1 Edit Aggregate Project = error_messages_for :aggregate_project = form_for @aggregate_project do |f| - = render 'form', :f => f -%div{:style => "margin-left: 30px;"} + = render 'form', f: f +%div{style: "margin-left: 30px;"} = link_to 'Remove Aggregate Project -', aggregate_project_path, data: { confirm: 'Are you sure?' }, method: :delete, class: "button" diff --git a/app/views/aggregate_projects/new.html.haml b/app/views/aggregate_projects/new.html.haml index 576f9bd14..4315c3aa5 100644 --- a/app/views/aggregate_projects/new.html.haml +++ b/app/views/aggregate_projects/new.html.haml @@ -3,4 +3,4 @@ %hr = error_messages_for :aggregate_project = form_for(@aggregate_project, html: { class: "form-horizontal" }) do |f| - = render 'form', :f => f + = render 'form', f: f diff --git a/app/views/configuration/edit.html.haml b/app/views/configuration/edit.html.haml index 9e1674798..6e00f65b1 100644 --- a/app/views/configuration/edit.html.haml +++ b/app/views/configuration/edit.html.haml @@ -12,7 +12,7 @@ %hr %h4 Projects - = link_to 'Add Project +', new_project_path, :class => 'btn btn-primary btn-xs' + = link_to 'Add Project +', new_project_path, class: 'btn btn-primary btn-xs' %table.projects.table.table-striped.table-hover %thead @@ -29,18 +29,18 @@ %th Actions %tbody - @projects.each do |project| - %tr{:id => "project-#{project.id}", data: { tags: project.tag_list.inspect, "polling-status" => project_last_status_text(project)}} + %tr{id: "project-#{project.id}", data: { tags: project.tag_list.inspect, "polling-status" => project_last_status_text(project)}} %td= h project.code %td= h project.name %td - = content_tag 'span', :title=>"#{project.feed_url}#{project.has_auth? ? ' (under auth)' : ''}" do + = content_tag 'span', title: "#{project.feed_url}#{project.has_auth? ? ' (under auth)' : ''}" do = t("project_types.#{project.class.name.underscore}") = image_tag("icons/lock.png") if project.has_auth? %td.text-center - if project.enabled? ✓ - else - %span{:style => "color: #AA1224;"} ✕ + %span{style: "color: #AA1224;"} ✕ %td = project_last_status(project) %td.text-center= project.aggregate_project.present? ? project.aggregate_project.name : "" @@ -48,13 +48,13 @@ %td.age= project.updated_at.present? ? time_ago_in_words(project.updated_at) : "N/A" %td.webhooks.text-center= project.webhooks_enabled ? "✓" : "✕" %td.actions - = link_to 'Edit', edit_project_path(project), :class => "btn btn-xs btn-default" - = link_to 'Delete', project_path(project), :method => :delete, :data => { :confirm => 'Are you sure?' }, :class =>"btn btn-xs btn-default" + = link_to 'Edit', edit_project_path(project), class: "btn btn-xs btn-default" + = link_to 'Delete', project_path(project), method: :delete, data: { confirm: 'Are you sure?' }, class: "btn btn-xs btn-default" %hr %h4 Aggregate Projects - = link_to 'Add Aggregate Project +', new_aggregate_project_path, :class => "btn btn-primary btn-xs" + = link_to 'Add Aggregate Project +', new_aggregate_project_path, class: "btn btn-primary btn-xs" - unless @aggregate_projects.empty? %table.projects.table.table-striped.table-hover %thead @@ -67,16 +67,16 @@ %th Actions %tbody - for aggregate_project in @aggregate_projects - %tr{:id => "aggregate-project-#{aggregate_project.id}",data: { tags: aggregate_project.tag_list.inspect, "polling-status" => "" }} + %tr{id: "aggregate-project-#{aggregate_project.id}", data: { tags: aggregate_project.tag_list.inspect, "polling-status" => "" }} %td= h aggregate_project.name %td.text-center - if aggregate_project.enabled? ✓ - else - %span{:style => "color: #AA1224;"} ✕ + %span{style: "color: #AA1224;"} ✕ %td.tag_list= aggregate_project.tag_list %td.count= aggregate_project.projects.count %td.age= aggregate_project.updated_at.present? ? time_ago_in_words(aggregate_project.updated_at) : "N/A" %td.actions - = link_to 'Edit', edit_aggregate_project_path(aggregate_project), :class => "btn btn-xs btn-default" - = link_to 'Delete', aggregate_project_path(aggregate_project), :method => :delete, :class =>"btn btn-xs btn-default" + = link_to 'Edit', edit_aggregate_project_path(aggregate_project), class: "btn btn-xs btn-default" + = link_to 'Delete', aggregate_project_path(aggregate_project), method: :delete, class:"btn btn-xs btn-default" diff --git a/app/views/devise/sessions/new.html.haml b/app/views/devise/sessions/new.html.haml index bed6be66b..5de509ffe 100644 --- a/app/views/devise/sessions/new.html.haml +++ b/app/views/devise/sessions/new.html.haml @@ -1,6 +1,6 @@ %h1 Sign in %hr -= form_for(resource, :as => resource_name, :url => session_path(resource_name), html: { class: "form-horizontal" }) do |f| += form_for(resource, as: resource_name, url: session_path(resource_name), html: { class: "form-horizontal" }) do |f| .form-group = f.label :login, 'Login or Email', class: "col-sm-2 control-label" .col-sm-2 diff --git a/app/views/home/builds.rss.builder b/app/views/home/builds.rss.builder index c1ddca830..05a50217c 100644 --- a/app/views/home/builds.rss.builder +++ b/app/views/home/builds.rss.builder @@ -1,5 +1,5 @@ xml.instruct! -xml.rss :version => '2.0' do +xml.rss version: '2.0' do xml.channel do xml.title "Project Monitor" xml.link root_url diff --git a/app/views/layouts/application.html.haml b/app/views/layouts/application.html.haml index a3540c405..cf3b63438 100644 --- a/app/views/layouts/application.html.haml +++ b/app/views/layouts/application.html.haml @@ -33,7 +33,7 @@ %li = link_to "Log Out", destroy_user_session_path, method: :delete .container - %div{:class => "page #{params[:controller]} #{params[:action]}"} + %div{class: "page #{params[:controller]} #{params[:action]}"} - if flash[:error] .alert.alert-danger = flash[:error] diff --git a/app/views/layouts/home.html.haml b/app/views/layouts/home.html.haml index 707ea1a48..c2822b620 100644 --- a/app/views/layouts/home.html.haml +++ b/app/views/layouts/home.html.haml @@ -5,8 +5,8 @@ = stylesheet_link_tag "application" = javascript_include_tag "application" = csrf_meta_tag - %script{:src => "//fast.fonts.com/jsapi/14aea2b8-37b7-4a31-afb9-e44414bef419.js", :type => "text/javascript"} - %body{:class => "dashboard tiles_#{@tiles_count}", "data-tiles-count" => @tiles_count} + %script{src: "//fast.fonts.com/jsapi/14aea2b8-37b7-4a31-afb9-e44414bef419.js", type: "text/javascript"} + %body{class: "dashboard tiles_#{@tiles_count}", "data-tiles-count" => @tiles_count} = yield #footer .left diff --git a/app/views/payload_log_entries/index.html.haml b/app/views/payload_log_entries/index.html.haml index 699f66edc..8ed0ae92c 100644 --- a/app/views/payload_log_entries/index.html.haml +++ b/app/views/payload_log_entries/index.html.haml @@ -6,7 +6,7 @@ %th Message %th Backtrace - @payload_log_entries.each_with_index do |entry, index| - %tr{:class => cycle("odd", "even")} + %tr{class: cycle("odd", "even")} %td= entry.created_at %td= entry.status %td= entry.update_method diff --git a/app/views/projects/_build_setup.html.haml b/app/views/projects/_build_setup.html.haml index 030eedd1a..d7233fdbe 100644 --- a/app/views/projects/_build_setup.html.haml +++ b/app/views/projects/_build_setup.html.haml @@ -29,9 +29,9 @@ = f.label field, class: "col-sm-2 control-label" .col-sm-4 - if field == "tddium_project_name" - = f.text_field field, :disabled => !enabled, placeholder: "repo_name (branch_name)", class: "form-control" + = f.text_field field, disabled: !enabled, placeholder: "repo_name (branch_name)", class: "form-control" - else - = f.text_field field, :disabled => !enabled, class: "form-control" + = f.text_field field, disabled: !enabled, class: "form-control" %fieldset#polling .form-group.verify_ssl_field .col-sm-offset-2.col-sm-10 @@ -62,7 +62,7 @@ %span.label.label-success.success.hide OK %span.label.label-info.pending.hide Loading... %span.label.label-default.unconfigured.hide Unconfigured - %span.label.label-danger.failure.hide{ :title => project_latest_error(@project) } Error + %span.label.label-danger.failure.hide{ title: project_latest_error(@project) } Error %span.label.label-warning.empty_fields.hide Some Fields Empty   %input{ class: 'refresh btn btn-default btn-xs', type: 'button', value: 'Refresh' } diff --git a/app/views/projects/_form.html.haml b/app/views/projects/_form.html.haml index 8204997f4..368ece40d 100644 --- a/app/views/projects/_form.html.haml +++ b/app/views/projects/_form.html.haml @@ -25,7 +25,7 @@ .form-group = f.label :aggregate_project_id, "Aggregate Project", class: "col-sm-2 control-label" .col-sm-3 - = collection_select(:project, :aggregate_project_id, AggregateProject.all, :id, :name, {:prompt => false, :disabled => lambda { |ap| !ap.enabled? }, :include_blank => true}, class: "form-control") + = collection_select(:project, :aggregate_project_id, AggregateProject.all, :id, :name, {prompt: false, disabled: lambda { |ap| !ap.enabled? }, include_blank: true}, class: "form-control") .form-group :javascript autocomplete("#project_tag_list", #{ ActsAsTaggableOn::Tag.all.map(&:name) }); diff --git a/app/views/projects/edit.html.haml b/app/views/projects/edit.html.haml index a8de12065..9d7e351d9 100644 --- a/app/views/projects/edit.html.haml +++ b/app/views/projects/edit.html.haml @@ -4,5 +4,5 @@ = link_to '← Back to Projects'.html_safe, edit_configuration_path %h1 Edit Project = error_messages_for :project -= form_for(@project, :as => :project, :url => project_path(@project), :html => { :class => "form-horizontal" }) do |f| - = render 'form', :f => f += form_for(@project, as: :project, url: project_path(@project), html: { class: "form-horizontal" }) do |f| + = render 'form', f: f diff --git a/app/views/projects/new.html.haml b/app/views/projects/new.html.haml index 48c01d662..3dd67ea33 100644 --- a/app/views/projects/new.html.haml +++ b/app/views/projects/new.html.haml @@ -5,5 +5,5 @@ %h1 Add Project %hr = error_messages_for :project -= form_for(@project, :as => :project, :url => projects_path, :html => { :class => "form-horizontal" }) do |f| - = render 'form', :f => f += form_for(@project, as: :project, url: projects_path, html: { class: "form-horizontal" }) do |f| + = render 'form', f: f diff --git a/config/initializers/session_store.rb b/config/initializers/session_store.rb index 83f138f50..29d7d373c 100644 --- a/config/initializers/session_store.rb +++ b/config/initializers/session_store.rb @@ -1,6 +1,6 @@ # Be sure to restart your server when you modify this file. -ProjectMonitor::Application.config.session_store :cookie_store, :key => '_projectmonitor_session' +ProjectMonitor::Application.config.session_store :cookie_store, key: '_projectmonitor_session' # Use the database for sessions instead of the cookie-based default, # which shouldn't be used to store highly confidential information diff --git a/config/routes.rb b/config/routes.rb index 5205620e3..6de519d1f 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -1,5 +1,5 @@ ProjectMonitor::Application.routes.draw do - devise_for :users, :controllers => { :omniauth_callbacks => "omniauth_callbacks", :sessions => "sessions" } + devise_for :users, controllers: { omniauth_callbacks: "omniauth_callbacks", sessions: "sessions" } mount JasmineRails::Engine => "/specs" if defined?(JasmineRails) get 'builds' => "home#builds", format: :rss @@ -12,7 +12,7 @@ patch 'projects/validate_build_info' resource :configuration, only: [:show, :create, :edit], controller: "configuration" - resources :users, :only => [:new, :create] + resources :users, only: [:new, :create] resources :projects do resources :payload_log_entries, only: :index resource :status, only: :create, controller: "status" @@ -31,9 +31,9 @@ end authenticate :user do - get "/jobs" => DelayedJobWeb, :anchor => false + get "/jobs" => DelayedJobWeb, anchor: false end get 'styleguide' => 'home#styleguide' - root :to => 'home#index' + root to: 'home#index' end diff --git a/config/schedule.rb b/config/schedule.rb index b9c85e64e..b9a77a813 100644 --- a/config/schedule.rb +++ b/config/schedule.rb @@ -1,12 +1,12 @@ -every :day, :at => '3:00am' do - rake "truncate:payload_log_entries", :output => "log/payload_log_entries.log" - rake "truncate:project_statuses", :output => "log/project_statuses.log" - rake "dependency:truncate_old_statuses", :output => "log/dependency_statuses.log" +every :day, at: '3:00am' do + rake "truncate:payload_log_entries", output: "log/payload_log_entries.log" + rake "truncate:project_statuses", output: "log/project_statuses.log" + rake "dependency:truncate_old_statuses", output: "log/dependency_statuses.log" rake "projectmonitor:remove_unused_tags" end every 3.minutes do - rake "projectmonitor:fetch_statuses", :output => "log/fetch_statuses.log" + rake "projectmonitor:fetch_statuses", output: "log/fetch_statuses.log" end every 1.minute do diff --git a/db/seeds.rb b/db/seeds.rb index 664d8c74c..4b46ca3e4 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -3,5 +3,5 @@ # # Examples: # -# cities = City.create([{ :name => 'Chicago' }, { :name => 'Copenhagen' }]) -# Mayor.create(:name => 'Daley', :city => cities.first) +# cities = City.create([{ name: 'Chicago' }, { name: 'Copenhagen' }]) +# Mayor.create(name: 'Daley', city: cities.first) diff --git a/lib/tracker_histogram_bar.rb b/lib/tracker_histogram_bar.rb index 2f498764c..dadf382a4 100644 --- a/lib/tracker_histogram_bar.rb +++ b/lib/tracker_histogram_bar.rb @@ -7,7 +7,7 @@ def initialize(tracker_histogram, points_value, index) attr_reader :points_value - delegate :number_of_points_values, :maximum_points_value, :opacity_step, :to => :tracker_histogram + delegate :number_of_points_values, :maximum_points_value, :opacity_step, to: :tracker_histogram def height_percentage (points_value.to_f / maximum_points_value * 100).to_i + TrackerHistogram::ZERO_OFFSET diff --git a/spec/controllers/aggregate_projects_controller_spec.rb b/spec/controllers/aggregate_projects_controller_spec.rb index 2016fb073..2eaafebcb 100644 --- a/spec/controllers/aggregate_projects_controller_spec.rb +++ b/spec/controllers/aggregate_projects_controller_spec.rb @@ -21,7 +21,7 @@ describe "create" do context "when the aggregate project was successfully created" do - before { post :create, :aggregate_project => { :name => "new name" } } + before { post :create, aggregate_project: { name: "new name" } } it "should set the flash" do flash[:notice].should == 'Aggregate project was successfully created.' @@ -31,14 +31,14 @@ end context "when the aggregate project was not successfully created" do - before { post :create, :aggregate_project => { :name => nil } } + before { post :create, aggregate_project: { name: nil } } it { should render_template :new } end end describe "update" do context "when the aggregate project was successfully updated" do - before { put :update, :id => aggregate_projects(:internal_projects_aggregate), :aggregate_project => { :name => "new name" } } + before { put :update, id: aggregate_projects(:internal_projects_aggregate), aggregate_project: { name: "new name" } } it "should set the flash" do flash[:notice].should == 'Aggregate project was successfully updated.' @@ -48,13 +48,13 @@ end context "when the aggregate project was not successfully updated" do - before { put :update, :id => aggregate_projects(:internal_projects_aggregate), :aggregate_project => { :name => nil } } + before { put :update, id: aggregate_projects(:internal_projects_aggregate), aggregate_project: { name: nil } } it { should render_template :edit } end end describe "destroy" do - subject { delete :destroy, :id => aggregate_projects(:internal_projects_aggregate) } + subject { delete :destroy, id: aggregate_projects(:internal_projects_aggregate) } it "should destroy the aggregate project" do lambda { subject }.should change(AggregateProject, :count).by(-1) diff --git a/spec/controllers/projects_controller_spec.rb b/spec/controllers/projects_controller_spec.rb index eb5072d15..ac04f2d78 100644 --- a/spec/controllers/projects_controller_spec.rb +++ b/spec/controllers/projects_controller_spec.rb @@ -37,11 +37,11 @@ describe "#create" do context "when the project is valid" do def do_post - post :create, :project => { - :name => 'name', - :type => JenkinsProject.name, - :jenkins_base_url => 'http://www.example.com', - :jenkins_build_name => 'example' + post :create, project: { + name: 'name', + type: JenkinsProject.name, + jenkins_base_url: 'http://www.example.com', + jenkins_build_name: 'example' } end @@ -63,14 +63,14 @@ def do_post end context "when the project is invalid" do - before { post :create, :project => { :name => nil, :type => JenkinsProject.name} } + before { post :create, project: { name: nil, type: JenkinsProject.name} } it { should render_template :new } end end describe "#update" do context "when the project was successfully updated" do - before { put :update, :id => projects(:jenkins_project), :project => { :name => "new name" } } + before { put :update, id: projects(:jenkins_project), project: { name: "new name" } } it "should set the flash" do flash[:notice].should == 'Project was successfully updated.' @@ -80,7 +80,7 @@ def do_post end context "when the project was not successfully updated" do - before { put :update, :id => projects(:jenkins_project), :project => { :name => nil } } + before { put :update, id: projects(:jenkins_project), project: { name: nil } } it { should render_template :edit } end @@ -89,7 +89,7 @@ def do_post let(:project) { projects(:socialitis).tap {|p| p.auth_password = 'existing password'} } subject { project.auth_password } before do - put :update, :id => projects(:socialitis).id, :password_changed => changed, :project => {:auth_password => new_password } + put :update, id: projects(:socialitis).id, password_changed: changed, project: {auth_password: new_password } project.reload end @@ -152,7 +152,7 @@ def do_post end describe "#destroy" do - subject { delete :destroy, :id => projects(:jenkins_project) } + subject { delete :destroy, id: projects(:jenkins_project) } it "should destroy the project" do lambda { subject }.should change(JenkinsProject, :count).by(-1) diff --git a/spec/controllers/users_controller_spec.rb b/spec/controllers/users_controller_spec.rb index ca3440d8e..23d2f1996 100644 --- a/spec/controllers/users_controller_spec.rb +++ b/spec/controllers/users_controller_spec.rb @@ -18,8 +18,8 @@ it "creates a new user" do lambda { - post :create, :user => { :login => 'newuser', :email => 'newuser@example.com', - :password => 'password', :password_confirmation => 'password' } + post :create, user: { login: 'newuser', email: 'newuser@example.com', + password: 'password', password_confirmation: 'password' } response.should redirect_to(root_path) assigns(:user).should_not be_new_record assigns(:user).should be_valid @@ -29,8 +29,8 @@ it "should handle a bad user" do lambda { - post :create, :user => { :login => 'newuser', :email => 'newuser@example.com', - :password => 'password', :password_confirmation => 'notpassword' } + post :create, user: { login: 'newuser', email: 'newuser@example.com', + password: 'password', password_confirmation: 'notpassword' } response.should be_success assigns(:user).should_not be_valid }.should change(User, :count).by(0) @@ -38,7 +38,7 @@ end it "should generate params for users's new action from GET /users" do - {:get => "/users/new"}.should route_to(:controller => 'users', :action => 'new') - {:post => "/users"}.should route_to(:controller => 'users', :action => 'create') + {get: "/users/new"}.should route_to(controller: 'users', action: 'new') + {post: "/users"}.should route_to(controller: 'users', action: 'create') end end diff --git a/spec/controllers/versions_controller_spec.rb b/spec/controllers/versions_controller_spec.rb index 569f826fe..41b8d0bf2 100644 --- a/spec/controllers/versions_controller_spec.rb +++ b/spec/controllers/versions_controller_spec.rb @@ -7,7 +7,7 @@ context 'routing' do it 'should route GET /version to VersionsController#show' do - { get: '/version' }.should route_to(:controller => 'versions', :action => 'show') + { get: '/version' }.should route_to(controller: 'versions', action: 'show') end it 'should only check the VERSION file once' do diff --git a/spec/decorators/project_decorator_spec.rb b/spec/decorators/project_decorator_spec.rb index da6f89264..dc09d1288 100644 --- a/spec/decorators/project_decorator_spec.rb +++ b/spec/decorators/project_decorator_spec.rb @@ -5,7 +5,7 @@ let(:id) { "123" } subject { ProjectDecorator.new(project).css_id } - before { project.stub(:id => id)} + before { project.stub(id: id)} context "when Project" do let(:project) { CruiseControlProject.new } diff --git a/spec/features/projects_spec.rb b/spec/features/projects_spec.rb index ca0f032c2..38fa8ae90 100644 --- a/spec/features/projects_spec.rb +++ b/spec/features/projects_spec.rb @@ -12,17 +12,17 @@ scenario "admin creates a Travis project", js: true do click_on "Add Project" - select "Travis Project", :from => "Project Type" + select "Travis Project", from: "Project Type" choose "project_webhooks_enabled_false" - fill_in "project[name]", :with => "Project Monitor" + fill_in "project[name]", with: "Project Monitor" click_on "Create" page.should have_content("Travis github account can't be blank") page.should have_content("Travis repository can't be blank") - fill_in "Github Account", :with => "pivotal" - fill_in "Repository", :with => "projectmonitor" + fill_in "Github Account", with: "pivotal" + fill_in "Repository", with: "projectmonitor" click_on "Create" @@ -37,8 +37,8 @@ new_account = "pivotal2" new_project = "projectmonitor2" - fill_in "Github Account", :with => new_account - fill_in "Repository", :with => new_project + fill_in "Github Account", with: new_account + fill_in "Repository", with: new_project click_button "Update" diff --git a/spec/helpers/project_monitor_helper_spec.rb b/spec/helpers/project_monitor_helper_spec.rb index c57e6fbe6..fc7b95fb2 100644 --- a/spec/helpers/project_monitor_helper_spec.rb +++ b/spec/helpers/project_monitor_helper_spec.rb @@ -2,8 +2,8 @@ describe ProjectMonitorHelper do before do - @status = double(ProjectStatus, :published_at => publish_time) - @project = double(Project, :status => @status) + @status = double(ProjectStatus, published_at: publish_time) + @project = double(Project, status: @status) end describe "#static_status_messages_for" do @@ -13,8 +13,8 @@ def publish_time context "when the project's status published_at & red_since is nil" do before do - @status = double(ProjectStatus, :published_at => nil) - @project = double(Project, :status => @status, :red_since => nil) + @status = double(ProjectStatus, published_at: nil) + @project = double(Project, status: @status, red_since: nil) @project.stub(:online?).and_return(true) @project.stub(:failure?).and_return(true) @project.stub(:red_build_count).and_return(2) diff --git a/spec/integration/tracker_api_spec.rb b/spec/integration/tracker_api_spec.rb index 2ababc58e..a7c106e2b 100644 --- a/spec/integration/tracker_api_spec.rb +++ b/spec/integration/tracker_api_spec.rb @@ -1,7 +1,7 @@ require 'spec_helper' describe TrackerApi do - context "with the real service", :vcr => {:re_record_interval => 18.months} do + context "with the real service", vcr: {re_record_interval: 18.months} do subject { TrackerApi.new(project) } # ALERT: Always use a fake tracker project with these tests because they delete everything! diff --git a/spec/lib/project_workload_handler_spec.rb b/spec/lib/project_workload_handler_spec.rb index b1c3c0744..f88bd3693 100644 --- a/spec/lib/project_workload_handler_spec.rb +++ b/spec/lib/project_workload_handler_spec.rb @@ -66,7 +66,7 @@ handler.workload_complete(workload) }.to change(project.payload_log_entries, :count).by(2) - project.payload_log_entries.where(:error_type => "ActiveRecord::RecordInvalid").should be_present + project.payload_log_entries.where(error_type: "ActiveRecord::RecordInvalid").should be_present end it "sets the project to offline" do @@ -89,12 +89,12 @@ it 'should add a log entry' do error.stub(:message).and_return("message") project.payload_log_entries.should_receive(:build) - .with(error_type: "RSpec::Mocks::Mock", error_text: "message", update_method: "Polling", status: "failed", :backtrace => "message\nbacktrace\nmore") + .with(error_type: "RSpec::Mocks::Mock", error_text: "message", update_method: "Polling", status: "failed", backtrace: "message\nbacktrace\nmore") end it 'should not call message on a failure when passed a String instead of an Exception' do project.payload_log_entries.should_receive(:build) - .with(error_type: "RSpec::Mocks::Mock", error_text: "", update_method: "Polling", status: "failed", :backtrace => "\nbacktrace\nmore") + .with(error_type: "RSpec::Mocks::Mock", error_text: "", update_method: "Polling", status: "failed", backtrace: "\nbacktrace\nmore") end it 'should set building to false' do diff --git a/spec/lib/tracker_api_spec.rb b/spec/lib/tracker_api_spec.rb index edd13f5ec..d136b6098 100644 --- a/spec/lib/tracker_api_spec.rb +++ b/spec/lib/tracker_api_spec.rb @@ -8,28 +8,28 @@ PivotalTracker::Project.stub(:find) end - let(:project) { double(:project, :tracker_project_id => 1, :tracker_auth_token => 2) } + let(:project) { double(:project, tracker_project_id: 1, tracker_auth_token: 2) } let(:current_iteration) do - double(:iteration, :stories => [ - double(:story, :estimate => 20, :current_state => "started"), - double(:story, :estimate => 21, :current_state => "accepted") + double(:iteration, stories: [ + double(:story, estimate: 20, current_state: "started"), + double(:story, estimate: 21, current_state: "accepted") ]) end let(:done_iterations) do [ - double(:iteration, :stories => [ double(:story, :estimate => 0), double(:story, :estimate => 0) ]), - double(:iteration, :stories => [ double(:story, :estimate => 0), double(:story, :estimate => 1) ]), - double(:iteration, :stories => [ double(:story, :estimate => 2), double(:story, :estimate => 3) ]), - double(:iteration, :stories => [ double(:story, :estimate => 4), double(:story, :estimate => 5) ]), - double(:iteration, :stories => [ double(:story, :estimate => 6), double(:story, :estimate => 7) ]), - double(:iteration, :stories => [ double(:story, :estimate => 8), double(:story, :estimate => 9) ]), - double(:iteration, :stories => [ double(:story, :estimate => 10), double(:story, :estimate => 11) ]), - double(:iteration, :stories => [ double(:story, :estimate => 12), double(:story, :estimate => 13) ]), - double(:iteration, :stories => [ double(:story, :estimate => 14), double(:story, :estimate => 15) ]), - double(:iteration, :stories => [ double(:story, :estimate => 16), double(:story, :estimate => 17) ]), - double(:iteration, :stories => [ double(:story, :estimate => 18), double(:story, :estimate => 19) ]) + double(:iteration, stories: [ double(:story, estimate: 0), double(:story, estimate: 0) ]), + double(:iteration, stories: [ double(:story, estimate: 0), double(:story, estimate: 1) ]), + double(:iteration, stories: [ double(:story, estimate: 2), double(:story, estimate: 3) ]), + double(:iteration, stories: [ double(:story, estimate: 4), double(:story, estimate: 5) ]), + double(:iteration, stories: [ double(:story, estimate: 6), double(:story, estimate: 7) ]), + double(:iteration, stories: [ double(:story, estimate: 8), double(:story, estimate: 9) ]), + double(:iteration, stories: [ double(:story, estimate: 10), double(:story, estimate: 11) ]), + double(:iteration, stories: [ double(:story, estimate: 12), double(:story, estimate: 13) ]), + double(:iteration, stories: [ double(:story, estimate: 14), double(:story, estimate: 15) ]), + double(:iteration, stories: [ double(:story, estimate: 16), double(:story, estimate: 17) ]), + double(:iteration, stories: [ double(:story, estimate: 18), double(:story, estimate: 19) ]) ] end diff --git a/spec/models/aggregate_project_spec.rb b/spec/models/aggregate_project_spec.rb index cf4504b4d..e24fa0a87 100644 --- a/spec/models/aggregate_project_spec.rb +++ b/spec/models/aggregate_project_spec.rb @@ -39,7 +39,7 @@ describe "before_destroy" do let(:project) { projects(:socialitis) } - let!(:aggregate_project) { FactoryGirl.create :aggregate_project, :projects => [project] } + let!(:aggregate_project) { FactoryGirl.create :aggregate_project, projects: [project] } it "should remove its id from its projects" do project.aggregate_project_id.should_not be_nil @@ -71,8 +71,8 @@ let(:displayable_aggregate) { AggregateProject.displayable } it "should return enabled projects" do - enabled = FactoryGirl.create :aggregate_project, :projects => [create(:project)], enabled: true - disabled = FactoryGirl.create :aggregate_project, :projects => [create(:project)], enabled: false + enabled = FactoryGirl.create :aggregate_project, projects: [create(:project)], enabled: true + disabled = FactoryGirl.create :aggregate_project, projects: [create(:project)], enabled: false displayable_aggregate.should include enabled displayable_aggregate.should_not include disabled @@ -84,7 +84,7 @@ end it "should not return duplicate aggregate projects" do - enabled = FactoryGirl.create :aggregate_project, :projects => [create(:project), create(:project)], enabled: true + enabled = FactoryGirl.create :aggregate_project, projects: [create(:project), create(:project)], enabled: true displayable_aggregate.to_a.count(enabled).should == 1 end @@ -101,10 +101,10 @@ let(:displayable_aggregate) { AggregateProject.displayable "red"} it "should return enabled projects with the requested tags" do - disabled_red_project = FactoryGirl.create :aggregate_project, :projects => [create(:project)], enabled: false, tag_list: "red" - disabled_blue_project = FactoryGirl.create :aggregate_project, :projects => [create(:project)], enabled: false, tag_list: "blue" - enabled_red_project = FactoryGirl.create :aggregate_project, :projects => [create(:project)], enabled: true, tag_list: "red" - enabled_blue_project = FactoryGirl.create :aggregate_project, :projects => [create(:project)], enabled: true, tag_list: "blue" + disabled_red_project = FactoryGirl.create :aggregate_project, projects: [create(:project)], enabled: false, tag_list: "red" + disabled_blue_project = FactoryGirl.create :aggregate_project, projects: [create(:project)], enabled: false, tag_list: "blue" + enabled_red_project = FactoryGirl.create :aggregate_project, projects: [create(:project)], enabled: true, tag_list: "red" + enabled_blue_project = FactoryGirl.create :aggregate_project, projects: [create(:project)], enabled: true, tag_list: "blue" displayable_aggregate.should include enabled_red_project displayable_aggregate.should_not include disabled_red_project, disabled_blue_project, enabled_blue_project @@ -168,7 +168,7 @@ subject do indeterminate_state = double(Project::State, to_s: "indeterminate", failure?: false, indeterminate?: true) project = Project.new.tap{|p| p.stub(state: indeterminate_state)} - AggregateProject.new(:projects => [project]).indeterminate? + AggregateProject.new(projects: [project]).indeterminate? end it { should be_true } @@ -176,7 +176,7 @@ context "aggregate has one yellow and one red project " do subject do - AggregateProject.new(:projects => [ + AggregateProject.new(projects: [ Project.new.tap{|p| p.stub(indeterminate?: true)}, Project.new.tap{|p| p.stub(indeterminate?: false)}]).indeterminate? end @@ -270,7 +270,7 @@ end it "should return nil if the project has no statuses" do - @project = Project.new(:name => "my_project_foo", :feed_url => "http://foo.bar.com:3434/projects/mystuff/baz.rss") + @project = Project.new(name: "my_project_foo", feed_url: "http://foo.bar.com:3434/projects/mystuff/baz.rss") aggregate_project.projects << @project aggregate_project.red_since.should be_nil end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb index c4adfa781..aeddb4d2e 100644 --- a/spec/models/project_spec.rb +++ b/spec/models/project_spec.rb @@ -131,7 +131,7 @@ it "should find tagged with tags" do scope = double Project.stub_chain(:enabled, :order) { scope } - scope.should_receive(:tagged_with).with(tags, {:any => true}) + scope.should_receive(:tagged_with).with(tags, {any: true}) subject end @@ -294,7 +294,7 @@ red_since = project.red_since 2.times do |i| - project.statuses.create!(success: false, build_id: i, :published_at => Time.now + (i+1)*5.minutes) + project.statuses.create!(success: false, build_id: i, published_at: Time.now + (i+1)*5.minutes) end project = Project.find(project.id) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index 701547196..13e4c37a0 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -17,8 +17,8 @@ config.use_instantiated_fixtures = false config.global_fixtures = :project_statuses, :projects, :taggings, :tags, :aggregate_projects - config.include Devise::TestHelpers, :type => :controller - config.include ViewHelpers, :type => :view + config.include Devise::TestHelpers, type: :controller + config.include ViewHelpers, type: :view config.extend VCR::RSpec::Macros @@ -43,7 +43,7 @@ def (ActionDispatch::Integration::Session).fixture_path DatabaseCleaner.strategy = :transaction end - config.before(:each, :js => true) do + config.before(:each, js: true) do DatabaseCleaner.strategy = :truncation end diff --git a/spec/support/feature_test_helper.rb b/spec/support/feature_test_helper.rb index 48897af73..fe42094ae 100644 --- a/spec/support/feature_test_helper.rb +++ b/spec/support/feature_test_helper.rb @@ -10,5 +10,5 @@ def log_in(user, password) end RSpec.configure do |config| - config.include FeatureTestHelper, :type => :feature + config.include FeatureTestHelper, type: :feature end diff --git a/spec/support/request_test_helper.rb b/spec/support/request_test_helper.rb index b0276029e..8c0f71828 100644 --- a/spec/support/request_test_helper.rb +++ b/spec/support/request_test_helper.rb @@ -10,5 +10,5 @@ def log_in(user, password) end RSpec.configure do |config| - config.include RequestTestHelper, :type => :feature + config.include RequestTestHelper, type: :feature end