Commit f89b60669f4b999083b597393d9e76ce5ca7d473
1 parent
909cbf7d
Exists in
master
and in
1 other branch
Rubocop: fix block delimiters
Based on https://github.com/bbatsov/ruby-style-guide#single-line-blocks
Showing
36 changed files
with
210 additions
and
214 deletions
Show diff stats
.rubocop_todo.yml
| @@ -41,12 +41,6 @@ Rails/Output: | @@ -41,12 +41,6 @@ Rails/Output: | ||
| 41 | - 'app/interactors/problem_recacher.rb' | 41 | - 'app/interactors/problem_recacher.rb' |
| 42 | - 'db/seeds.rb' | 42 | - 'db/seeds.rb' |
| 43 | 43 | ||
| 44 | -# Offense count: 105 | ||
| 45 | -# Cop supports --auto-correct. | ||
| 46 | -# Configuration parameters: EnforcedStyle, SupportedStyles, ProceduralMethods, FunctionalMethods, IgnoredMethods. | ||
| 47 | -Style/BlockDelimiters: | ||
| 48 | - Enabled: false | ||
| 49 | - | ||
| 50 | # Offense count: 15 | 44 | # Offense count: 15 |
| 51 | # Configuration parameters: EnforcedStyle, SupportedStyles. | 45 | # Configuration parameters: EnforcedStyle, SupportedStyles. |
| 52 | Style/ClassAndModuleChildren: | 46 | Style/ClassAndModuleChildren: |
app/controllers/apps_controller.rb
| @@ -8,9 +8,9 @@ class AppsController < ApplicationController | @@ -8,9 +8,9 @@ class AppsController < ApplicationController | ||
| 8 | 8 | ||
| 9 | expose(:app_scope) { App } | 9 | expose(:app_scope) { App } |
| 10 | 10 | ||
| 11 | - expose(:apps) { | 11 | + expose(:apps) do |
| 12 | app_scope.all.sort.map { |app| AppDecorator.new(app) } | 12 | app_scope.all.sort.map { |app| AppDecorator.new(app) } |
| 13 | - } | 13 | + end |
| 14 | 14 | ||
| 15 | expose(:app, ancestor: :app_scope, attributes: :app_params) | 15 | expose(:app, ancestor: :app_scope, attributes: :app_params) |
| 16 | 16 | ||
| @@ -18,11 +18,11 @@ class AppsController < ApplicationController | @@ -18,11 +18,11 @@ class AppsController < ApplicationController | ||
| 18 | AppDecorator.new(app) | 18 | AppDecorator.new(app) |
| 19 | end | 19 | end |
| 20 | 20 | ||
| 21 | - expose(:all_errs) { | 21 | + expose(:all_errs) do |
| 22 | params[:all_errs].present? | 22 | params[:all_errs].present? |
| 23 | - } | 23 | + end |
| 24 | 24 | ||
| 25 | - expose(:problems) { | 25 | + expose(:problems) do |
| 26 | if request.format == :atom | 26 | if request.format == :atom |
| 27 | app.problems.unresolved.ordered | 27 | app.problems.unresolved.ordered |
| 28 | else | 28 | else |
| @@ -32,15 +32,15 @@ class AppsController < ApplicationController | @@ -32,15 +32,15 @@ class AppsController < ApplicationController | ||
| 32 | params[:environment] | 32 | params[:environment] |
| 33 | ).ordered_by(params_sort, params_order).page(params[:page]).per(current_user.per_page) | 33 | ).ordered_by(params_sort, params_order).page(params[:page]).per(current_user.per_page) |
| 34 | end | 34 | end |
| 35 | - } | 35 | + end |
| 36 | 36 | ||
| 37 | - expose(:deploys) { | 37 | + expose(:deploys) do |
| 38 | app.deploys.order_by(:created_at.desc).limit(5) | 38 | app.deploys.order_by(:created_at.desc).limit(5) |
| 39 | - } | 39 | + end |
| 40 | 40 | ||
| 41 | - expose(:users) { | 41 | + expose(:users) do |
| 42 | User.all.sort_by { |u| u.name.downcase } | 42 | User.all.sort_by { |u| u.name.downcase } |
| 43 | - } | 43 | + end |
| 44 | 44 | ||
| 45 | def index; end | 45 | def index; end |
| 46 | 46 |
app/controllers/problems_controller.rb
| @@ -11,27 +11,27 @@ class ProblemsController < ApplicationController | @@ -11,27 +11,27 @@ class ProblemsController < ApplicationController | ||
| 11 | :resolve_several, :unresolve_several, :unmerge_several | 11 | :resolve_several, :unresolve_several, :unmerge_several |
| 12 | ] | 12 | ] |
| 13 | 13 | ||
| 14 | - expose(:app_scope) { | 14 | + expose(:app_scope) do |
| 15 | params[:app_id] ? App.where(_id: params[:app_id]) : App.all | 15 | params[:app_id] ? App.where(_id: params[:app_id]) : App.all |
| 16 | - } | 16 | + end |
| 17 | 17 | ||
| 18 | - expose(:app) { | 18 | + expose(:app) do |
| 19 | AppDecorator.new app_scope.find(params[:app_id]) | 19 | AppDecorator.new app_scope.find(params[:app_id]) |
| 20 | - } | 20 | + end |
| 21 | 21 | ||
| 22 | - expose(:problem) { | 22 | + expose(:problem) do |
| 23 | ProblemDecorator.new app.problems.find(params[:id]) | 23 | ProblemDecorator.new app.problems.find(params[:id]) |
| 24 | - } | 24 | + end |
| 25 | 25 | ||
| 26 | - expose(:all_errs) { | 26 | + expose(:all_errs) do |
| 27 | params[:all_errs] | 27 | params[:all_errs] |
| 28 | - } | 28 | + end |
| 29 | 29 | ||
| 30 | - expose(:params_environement) { | 30 | + expose(:params_environement) do |
| 31 | params[:environment] | 31 | params[:environment] |
| 32 | - } | 32 | + end |
| 33 | 33 | ||
| 34 | - expose(:problems) { | 34 | + expose(:problems) do |
| 35 | pro = Problem. | 35 | pro = Problem. |
| 36 | for_apps(app_scope). | 36 | for_apps(app_scope). |
| 37 | in_env(params_environement). | 37 | in_env(params_environement). |
| @@ -43,7 +43,7 @@ class ProblemsController < ApplicationController | @@ -43,7 +43,7 @@ class ProblemsController < ApplicationController | ||
| 43 | else | 43 | else |
| 44 | pro | 44 | pro |
| 45 | end | 45 | end |
| 46 | - } | 46 | + end |
| 47 | 47 | ||
| 48 | def index; end | 48 | def index; end |
| 49 | 49 |
app/controllers/problems_searcher.rb
| @@ -5,28 +5,28 @@ module ProblemsSearcher | @@ -5,28 +5,28 @@ module ProblemsSearcher | ||
| 5 | extend ActiveSupport::Concern | 5 | extend ActiveSupport::Concern |
| 6 | 6 | ||
| 7 | included do | 7 | included do |
| 8 | - expose(:params_sort) { | 8 | + expose(:params_sort) do |
| 9 | if %w(app message last_notice_at last_deploy_at count).member?(params[:sort]) | 9 | if %w(app message last_notice_at last_deploy_at count).member?(params[:sort]) |
| 10 | params[:sort] | 10 | params[:sort] |
| 11 | else | 11 | else |
| 12 | "last_notice_at" | 12 | "last_notice_at" |
| 13 | end | 13 | end |
| 14 | - } | 14 | + end |
| 15 | 15 | ||
| 16 | - expose(:params_order) { | 16 | + expose(:params_order) do |
| 17 | if %w(asc desc).member?(params[:order]) | 17 | if %w(asc desc).member?(params[:order]) |
| 18 | params[:order] | 18 | params[:order] |
| 19 | else | 19 | else |
| 20 | 'desc' | 20 | 'desc' |
| 21 | end | 21 | end |
| 22 | - } | 22 | + end |
| 23 | 23 | ||
| 24 | - expose(:selected_problems) { | 24 | + expose(:selected_problems) do |
| 25 | Array(Problem.find(err_ids)) | 25 | Array(Problem.find(err_ids)) |
| 26 | - } | 26 | + end |
| 27 | 27 | ||
| 28 | - expose(:err_ids) { | 28 | + expose(:err_ids) do |
| 29 | (params[:problems] || []).compact | 29 | (params[:problems] || []).compact |
| 30 | - } | 30 | + end |
| 31 | end | 31 | end |
| 32 | end | 32 | end |
app/controllers/users_controller.rb
| @@ -5,9 +5,9 @@ class UsersController < ApplicationController | @@ -5,9 +5,9 @@ class UsersController < ApplicationController | ||
| 5 | before_action :require_user_edit_priviledges, only: [:edit, :update] | 5 | before_action :require_user_edit_priviledges, only: [:edit, :update] |
| 6 | 6 | ||
| 7 | expose(:user, attributes: :user_params) | 7 | expose(:user, attributes: :user_params) |
| 8 | - expose(:users) { | 8 | + expose(:users) do |
| 9 | User.all.page(params[:page]).per(current_user.per_page) | 9 | User.all.page(params[:page]).per(current_user.per_page) |
| 10 | - } | 10 | + end |
| 11 | 11 | ||
| 12 | def index; end | 12 | def index; end |
| 13 | def new; end | 13 | def new; end |
app/helpers/application_helper.rb
| @@ -20,7 +20,7 @@ module ApplicationHelper | @@ -20,7 +20,7 @@ module ApplicationHelper | ||
| 20 | end | 20 | end |
| 21 | 21 | ||
| 22 | def generate_ical(deploys) | 22 | def generate_ical(deploys) |
| 23 | - RiCal.Calendar { |cal| | 23 | + RiCal.Calendar do |cal| |
| 24 | deploys.each_with_index do |deploy, idx| | 24 | deploys.each_with_index do |deploy, idx| |
| 25 | cal.event do |event| | 25 | cal.event do |event| |
| 26 | event.summary = "#{idx + 1} #{deploy.repository}" | 26 | event.summary = "#{idx + 1} #{deploy.repository}" |
| @@ -31,7 +31,7 @@ module ApplicationHelper | @@ -31,7 +31,7 @@ module ApplicationHelper | ||
| 31 | event.organizer = deploy.username.to_s | 31 | event.organizer = deploy.username.to_s |
| 32 | end | 32 | end |
| 33 | end | 33 | end |
| 34 | - }.to_s | 34 | + end.to_s |
| 35 | end | 35 | end |
| 36 | 36 | ||
| 37 | def user_agent_graph(problem) | 37 | def user_agent_graph(problem) |
app/interactors/problem_destroy.rb
| @@ -20,9 +20,9 @@ class ProblemDestroy | @@ -20,9 +20,9 @@ class ProblemDestroy | ||
| 20 | # the number of problem destroy | 20 | # the number of problem destroy |
| 21 | # | 21 | # |
| 22 | def self.execute(problems) | 22 | def self.execute(problems) |
| 23 | - Array(problems).each { |problem| | 23 | + Array(problems).each do |problem| |
| 24 | ProblemDestroy.new(problem).execute | 24 | ProblemDestroy.new(problem).execute |
| 25 | - }.count | 25 | + end.count |
| 26 | end | 26 | end |
| 27 | 27 | ||
| 28 | private | 28 | private |
app/interactors/resolved_problem_clearer.rb
| @@ -5,14 +5,14 @@ class ResolvedProblemClearer | @@ -5,14 +5,14 @@ class ResolvedProblemClearer | ||
| 5 | # Clear all problem already resolved | 5 | # Clear all problem already resolved |
| 6 | # | 6 | # |
| 7 | def execute | 7 | def execute |
| 8 | - nb_problem_resolved.tap { |nb| | 8 | + nb_problem_resolved.tap do |nb| |
| 9 | if nb > 0 | 9 | if nb > 0 |
| 10 | criteria.each do |problem| | 10 | criteria.each do |problem| |
| 11 | ProblemDestroy.new(problem).execute | 11 | ProblemDestroy.new(problem).execute |
| 12 | end | 12 | end |
| 13 | repair_database | 13 | repair_database |
| 14 | end | 14 | end |
| 15 | - } | 15 | + end |
| 16 | end | 16 | end |
| 17 | 17 | ||
| 18 | private | 18 | private |
config/load.rb
| @@ -29,9 +29,9 @@ Errbit::Config = Configurator.run( | @@ -29,9 +29,9 @@ Errbit::Config = Configurator.run( | ||
| 29 | mongo_url: %w(MONGOLAB_URI MONGOHQ_URL MONGODB_URL MONGO_URL), | 29 | mongo_url: %w(MONGOLAB_URI MONGOHQ_URL MONGODB_URL MONGO_URL), |
| 30 | 30 | ||
| 31 | # github | 31 | # github |
| 32 | - github_url: ['GITHUB_URL', lambda { |values| | 32 | + github_url: ['GITHUB_URL', lambda do |values| |
| 33 | values[:github_url].gsub(%r{/*\z}, '') | 33 | values[:github_url].gsub(%r{/*\z}, '') |
| 34 | - }], | 34 | + end], |
| 35 | github_authentication: ['GITHUB_AUTHENTICATION'], | 35 | github_authentication: ['GITHUB_AUTHENTICATION'], |
| 36 | github_client_id: ['GITHUB_CLIENT_ID'], | 36 | github_client_id: ['GITHUB_CLIENT_ID'], |
| 37 | github_secret: ['GITHUB_SECRET'], | 37 | github_secret: ['GITHUB_SECRET'], |
| @@ -40,9 +40,9 @@ Errbit::Config = Configurator.run( | @@ -40,9 +40,9 @@ Errbit::Config = Configurator.run( | ||
| 40 | github_api_url: ['GITHUB_API_URL'], | 40 | github_api_url: ['GITHUB_API_URL'], |
| 41 | github_site_title: ['GITHUB_SITE_TITLE'], | 41 | github_site_title: ['GITHUB_SITE_TITLE'], |
| 42 | 42 | ||
| 43 | - email_delivery_method: ['EMAIL_DELIVERY_METHOD', lambda { |values| | 43 | + email_delivery_method: ['EMAIL_DELIVERY_METHOD', lambda do |values| |
| 44 | values[:email_delivery_method] && values[:email_delivery_method].to_sym | 44 | values[:email_delivery_method] && values[:email_delivery_method].to_sym |
| 45 | - }], | 45 | + end], |
| 46 | 46 | ||
| 47 | # smtp settings | 47 | # smtp settings |
| 48 | smtp_address: ['SMTP_SERVER'], | 48 | smtp_address: ['SMTP_SERVER'], |
| @@ -50,10 +50,10 @@ Errbit::Config = Configurator.run( | @@ -50,10 +50,10 @@ Errbit::Config = Configurator.run( | ||
| 50 | smtp_authentication: ['SMTP_AUTHENTICATION'], | 50 | smtp_authentication: ['SMTP_AUTHENTICATION'], |
| 51 | smtp_user_name: %w(SMTP_USERNAME SENDGRID_USERNAME), | 51 | smtp_user_name: %w(SMTP_USERNAME SENDGRID_USERNAME), |
| 52 | smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD), | 52 | smtp_password: %w(SMTP_PASSWORD SENDGRID_PASSWORD), |
| 53 | - smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', lambda { |values| | 53 | + smtp_domain: ['SMTP_DOMAIN', 'SENDGRID_DOMAIN', lambda do |values| |
| 54 | values[:smtp_domain] || | 54 | values[:smtp_domain] || |
| 55 | (values[:email_from] && values[:email_from].split('@').last) || nil | 55 | (values[:email_from] && values[:email_from].split('@').last) || nil |
| 56 | - }], | 56 | + end], |
| 57 | 57 | ||
| 58 | # sendmail settings | 58 | # sendmail settings |
| 59 | sendmail_location: ['SENDMAIL_LOCATION'], | 59 | sendmail_location: ['SENDMAIL_LOCATION'], |
lib/tasks/errbit/demo.rake
| @@ -32,12 +32,13 @@ namespace :errbit do | @@ -32,12 +32,13 @@ namespace :errbit do | ||
| 32 | 32 | ||
| 33 | def random_backtrace | 33 | def random_backtrace |
| 34 | backtrace = [] | 34 | backtrace = [] |
| 35 | - 99.times {|t| | 35 | + 99.times do |t| |
| 36 | backtrace << { | 36 | backtrace << { |
| 37 | 'number' => t.hash % 1000, | 37 | 'number' => t.hash % 1000, |
| 38 | 'file' => "/path/to/file.rb", | 38 | 'file' => "/path/to/file.rb", |
| 39 | 'method' => RANDOM_METHODS.sample.to_s | 39 | 'method' => RANDOM_METHODS.sample.to_s |
| 40 | - }} | 40 | + } |
| 41 | + end | ||
| 41 | backtrace | 42 | backtrace |
| 42 | end | 43 | end |
| 43 | 44 |
spec/acceptance/app_regenerate_api_key_spec.rb
| @@ -3,9 +3,9 @@ require 'acceptance/acceptance_helper' | @@ -3,9 +3,9 @@ require 'acceptance/acceptance_helper' | ||
| 3 | feature "Regeneration api_Key" do | 3 | feature "Regeneration api_Key" do |
| 4 | let(:app) { Fabricate(:app) } | 4 | let(:app) { Fabricate(:app) } |
| 5 | let(:admin) { Fabricate(:admin) } | 5 | let(:admin) { Fabricate(:admin) } |
| 6 | - let(:user) { | 6 | + let(:user) do |
| 7 | Fabricate(:user_watcher, app: app).user | 7 | Fabricate(:user_watcher, app: app).user |
| 8 | - } | 8 | + end |
| 9 | 9 | ||
| 10 | before do | 10 | before do |
| 11 | app && admin | 11 | app && admin |
| @@ -16,9 +16,9 @@ feature "Regeneration api_Key" do | @@ -16,9 +16,9 @@ feature "Regeneration api_Key" do | ||
| 16 | log_in admin | 16 | log_in admin |
| 17 | click_link app.name | 17 | click_link app.name |
| 18 | click_link I18n.t('apps.show.edit') | 18 | click_link I18n.t('apps.show.edit') |
| 19 | - expect { | 19 | + expect do |
| 20 | click_link I18n.t('apps.fields.regenerate_api_key') | 20 | click_link I18n.t('apps.fields.regenerate_api_key') |
| 21 | - }.to change { | 21 | + end.to change { |
| 22 | app.reload.api_key | 22 | app.reload.api_key |
| 23 | } | 23 | } |
| 24 | click_link I18n.t('shared.navigation.apps') | 24 | click_link I18n.t('shared.navigation.apps') |
| @@ -36,9 +36,9 @@ end | @@ -36,9 +36,9 @@ end | ||
| 36 | 36 | ||
| 37 | feature "Create an application" do | 37 | feature "Create an application" do |
| 38 | let(:admin) { Fabricate(:admin) } | 38 | let(:admin) { Fabricate(:admin) } |
| 39 | - let(:user) { | 39 | + let(:user) do |
| 40 | Fabricate(:user_watcher, app: app).user | 40 | Fabricate(:user_watcher, app: app).user |
| 41 | - } | 41 | + end |
| 42 | 42 | ||
| 43 | before do | 43 | before do |
| 44 | admin | 44 | admin |
spec/controllers/apps_controller_spec.rb
| @@ -312,9 +312,9 @@ describe AppsController, type: 'controller' do | @@ -312,9 +312,9 @@ describe AppsController, type: 'controller' do | ||
| 312 | 312 | ||
| 313 | it "should destroy the app" do | 313 | it "should destroy the app" do |
| 314 | delete :destroy, id: @app.id | 314 | delete :destroy, id: @app.id |
| 315 | - expect { | 315 | + expect do |
| 316 | @app.reload | 316 | @app.reload |
| 317 | - }.to raise_error(Mongoid::Errors::DocumentNotFound) | 317 | + end.to raise_error(Mongoid::Errors::DocumentNotFound) |
| 318 | end | 318 | end |
| 319 | 319 | ||
| 320 | it "should display a message" do | 320 | it "should display a message" do |
spec/controllers/problems_controller_spec.rb
| @@ -326,10 +326,10 @@ describe ProblemsController, type: 'controller' do | @@ -326,10 +326,10 @@ describe ProblemsController, type: 'controller' do | ||
| 326 | it "should unmerge a merged problem" do | 326 | it "should unmerge a merged problem" do |
| 327 | merged_problem = Problem.merge!(@problem1, @problem2) | 327 | merged_problem = Problem.merge!(@problem1, @problem2) |
| 328 | expect(merged_problem.errs.length).to eq 2 | 328 | expect(merged_problem.errs.length).to eq 2 |
| 329 | - expect { | 329 | + expect do |
| 330 | post :unmerge_several, problems: [merged_problem.id.to_s] | 330 | post :unmerge_several, problems: [merged_problem.id.to_s] |
| 331 | expect(merged_problem.reload.errs.length).to eq 1 | 331 | expect(merged_problem.reload.errs.length).to eq 1 |
| 332 | - }.to change(Problem, :count).by(1) | 332 | + end.to change(Problem, :count).by(1) |
| 333 | end | 333 | end |
| 334 | end | 334 | end |
| 335 | 335 | ||
| @@ -370,9 +370,9 @@ describe ProblemsController, type: 'controller' do | @@ -370,9 +370,9 @@ describe ProblemsController, type: 'controller' do | ||
| 370 | 370 | ||
| 371 | context "POST /problems/destroy_several" do | 371 | context "POST /problems/destroy_several" do |
| 372 | it "should delete the problems" do | 372 | it "should delete the problems" do |
| 373 | - expect { | 373 | + expect do |
| 374 | post :destroy_several, problems: [@problem1.id.to_s] | 374 | post :destroy_several, problems: [@problem1.id.to_s] |
| 375 | - }.to change(Problem, :count).by(-1) | 375 | + end.to change(Problem, :count).by(-1) |
| 376 | end | 376 | end |
| 377 | end | 377 | end |
| 378 | 378 | ||
| @@ -385,9 +385,9 @@ describe ProblemsController, type: 'controller' do | @@ -385,9 +385,9 @@ describe ProblemsController, type: 'controller' do | ||
| 385 | end | 385 | end |
| 386 | 386 | ||
| 387 | it "destroys all problems" do | 387 | it "destroys all problems" do |
| 388 | - expect { | 388 | + expect do |
| 389 | post :destroy_all, app_id: @app.id | 389 | post :destroy_all, app_id: @app.id |
| 390 | - }.to change(Problem, :count).by(-2) | 390 | + end.to change(Problem, :count).by(-2) |
| 391 | expect(controller.app).to eq @app | 391 | expect(controller.app).to eq @app |
| 392 | end | 392 | end |
| 393 | 393 |
spec/controllers/users_controller_spec.rb
| @@ -56,9 +56,9 @@ describe UsersController, type: 'controller' do | @@ -56,9 +56,9 @@ describe UsersController, type: 'controller' do | ||
| 56 | end | 56 | end |
| 57 | 57 | ||
| 58 | it "should not be able to become an admin" do | 58 | it "should not be able to become an admin" do |
| 59 | - expect { | 59 | + expect do |
| 60 | put :update, id: user.to_param, user: { admin: true } | 60 | put :update, id: user.to_param, user: { admin: true } |
| 61 | - }.to_not change { | 61 | + end.to_not change { |
| 62 | user.reload.admin | 62 | user.reload.admin |
| 63 | }.from(false) | 63 | }.from(false) |
| 64 | end | 64 | end |
| @@ -157,9 +157,9 @@ describe UsersController, type: 'controller' do | @@ -157,9 +157,9 @@ describe UsersController, type: 'controller' do | ||
| 157 | end | 157 | end |
| 158 | 158 | ||
| 159 | context "when the create is unsuccessful" do | 159 | context "when the create is unsuccessful" do |
| 160 | - let(:user) { | 160 | + let(:user) do |
| 161 | Struct.new(:admin, :attributes).new(true, {}) | 161 | Struct.new(:admin, :attributes).new(true, {}) |
| 162 | - } | 162 | + end |
| 163 | before do | 163 | before do |
| 164 | expect(User).to receive(:new).and_return(user) | 164 | expect(User).to receive(:new).and_return(user) |
| 165 | expect(user).to receive(:save).and_return(false) | 165 | expect(user).to receive(:save).and_return(false) |
| @@ -174,9 +174,9 @@ describe UsersController, type: 'controller' do | @@ -174,9 +174,9 @@ describe UsersController, type: 'controller' do | ||
| 174 | 174 | ||
| 175 | context "PUT /users/:id" do | 175 | context "PUT /users/:id" do |
| 176 | context "when the update is successful" do | 176 | context "when the update is successful" do |
| 177 | - before { | 177 | + before do |
| 178 | put :update, id: user.to_param, user: user_params | 178 | put :update, id: user.to_param, user: user_params |
| 179 | - } | 179 | + end |
| 180 | 180 | ||
| 181 | context "with normal params" do | 181 | context "with normal params" do |
| 182 | let(:user_params) { { name: 'Kermit' } } | 182 | let(:user_params) { { name: 'Kermit' } } |
| @@ -198,10 +198,10 @@ describe UsersController, type: 'controller' do | @@ -198,10 +198,10 @@ describe UsersController, type: 'controller' do | ||
| 198 | context "with a destroy success" do | 198 | context "with a destroy success" do |
| 199 | let(:user_destroy) { double(destroy: true) } | 199 | let(:user_destroy) { double(destroy: true) } |
| 200 | 200 | ||
| 201 | - before { | 201 | + before do |
| 202 | expect(UserDestroy).to receive(:new).with(user).and_return(user_destroy) | 202 | expect(UserDestroy).to receive(:new).with(user).and_return(user_destroy) |
| 203 | delete :destroy, id: user.id | 203 | delete :destroy, id: user.id |
| 204 | - } | 204 | + end |
| 205 | 205 | ||
| 206 | it 'should destroy user' do | 206 | it 'should destroy user' do |
| 207 | expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.destroy.success', name: user.name) | 207 | expect(request.flash[:success]).to eq I18n.t('controllers.users.flash.destroy.success', name: user.name) |
| @@ -210,10 +210,10 @@ describe UsersController, type: 'controller' do | @@ -210,10 +210,10 @@ describe UsersController, type: 'controller' do | ||
| 210 | end | 210 | end |
| 211 | 211 | ||
| 212 | context "with trying destroy himself" do | 212 | context "with trying destroy himself" do |
| 213 | - before { | 213 | + before do |
| 214 | expect(UserDestroy).to_not receive(:new) | 214 | expect(UserDestroy).to_not receive(:new) |
| 215 | delete :destroy, id: admin.id | 215 | delete :destroy, id: admin.id |
| 216 | - } | 216 | + end |
| 217 | 217 | ||
| 218 | it 'should not destroy user' do | 218 | it 'should not destroy user' do |
| 219 | expect(response).to redirect_to(users_path) | 219 | expect(response).to redirect_to(users_path) |
| @@ -224,12 +224,12 @@ describe UsersController, type: 'controller' do | @@ -224,12 +224,12 @@ describe UsersController, type: 'controller' do | ||
| 224 | 224 | ||
| 225 | describe "#user_params" do | 225 | describe "#user_params" do |
| 226 | context "with current user not admin" do | 226 | context "with current user not admin" do |
| 227 | - before { | 227 | + before do |
| 228 | allow(controller).to receive(:current_user).and_return(user) | 228 | allow(controller).to receive(:current_user).and_return(user) |
| 229 | allow(controller).to receive(:params).and_return( | 229 | allow(controller).to receive(:params).and_return( |
| 230 | ActionController::Parameters.new(user_param) | 230 | ActionController::Parameters.new(user_param) |
| 231 | ) | 231 | ) |
| 232 | - } | 232 | + end |
| 233 | let(:user_param) { { 'user' => { name: 'foo', admin: true } } } | 233 | let(:user_param) { { 'user' => { name: 'foo', admin: true } } } |
| 234 | it 'not have admin field' do | 234 | it 'not have admin field' do |
| 235 | expect(controller.send(:user_params)).to eq('name' => 'foo') | 235 | expect(controller.send(:user_params)).to eq('name' => 'foo') |
spec/decorators/issue_tracker_decorator_spec.rb
| 1 | describe IssueTrackerDecorator do | 1 | describe IssueTrackerDecorator do |
| 2 | let(:fake_tracker) do | 2 | let(:fake_tracker) do |
| 3 | - klass = Class.new(ErrbitPlugin::IssueTracker) { | 3 | + klass = Class.new(ErrbitPlugin::IssueTracker) do |
| 4 | def self.label | 4 | def self.label |
| 5 | 'fake' | 5 | 'fake' |
| 6 | end | 6 | end |
| @@ -19,7 +19,7 @@ describe IssueTrackerDecorator do | @@ -19,7 +19,7 @@ describe IssueTrackerDecorator do | ||
| 19 | def configured? | 19 | def configured? |
| 20 | true | 20 | true |
| 21 | end | 21 | end |
| 22 | - } | 22 | + end |
| 23 | klass.new 'nothing special' | 23 | klass.new 'nothing special' |
| 24 | end | 24 | end |
| 25 | 25 |
spec/fabricators/app_fabricator.rb
| @@ -4,9 +4,9 @@ Fabricator(:app) do | @@ -4,9 +4,9 @@ Fabricator(:app) do | ||
| 4 | end | 4 | end |
| 5 | 5 | ||
| 6 | Fabricator(:app_with_watcher, from: :app) do | 6 | Fabricator(:app_with_watcher, from: :app) do |
| 7 | - watchers(count: 1) { |parent, _i| | 7 | + watchers(count: 1) do |parent, _i| |
| 8 | Fabricate.build(:watcher, app: parent) | 8 | Fabricate.build(:watcher, app: parent) |
| 9 | - } | 9 | + end |
| 10 | end | 10 | end |
| 11 | 11 | ||
| 12 | Fabricator(:watcher) do | 12 | Fabricator(:watcher) do |
spec/fabricators/issue_tracker_fabricator.rb
spec/fabricators/problem_fabricator.rb
| @@ -6,19 +6,19 @@ Fabricator(:problem) do | @@ -6,19 +6,19 @@ Fabricator(:problem) do | ||
| 6 | end | 6 | end |
| 7 | 7 | ||
| 8 | Fabricator(:problem_with_comments, from: :problem) do | 8 | Fabricator(:problem_with_comments, from: :problem) do |
| 9 | - after_create { |parent| | 9 | + after_create do |parent| |
| 10 | 3.times do | 10 | 3.times do |
| 11 | Fabricate(:comment, err: parent) | 11 | Fabricate(:comment, err: parent) |
| 12 | end | 12 | end |
| 13 | - } | 13 | + end |
| 14 | end | 14 | end |
| 15 | 15 | ||
| 16 | Fabricator(:problem_with_errs, from: :problem) do | 16 | Fabricator(:problem_with_errs, from: :problem) do |
| 17 | - after_create { |parent| | 17 | + after_create do |parent| |
| 18 | 3.times do | 18 | 3.times do |
| 19 | Fabricate(:err, problem: parent) | 19 | Fabricate(:err, problem: parent) |
| 20 | end | 20 | end |
| 21 | - } | 21 | + end |
| 22 | end | 22 | end |
| 23 | 23 | ||
| 24 | Fabricator(:problem_resolved, from: :problem) do | 24 | Fabricator(:problem_resolved, from: :problem) do |
spec/interactors/problem_destroy_spec.rb
| 1 | describe ProblemDestroy do | 1 | describe ProblemDestroy do |
| 2 | - let(:problem_destroy) { | 2 | + let(:problem_destroy) do |
| 3 | ProblemDestroy.new(problem) | 3 | ProblemDestroy.new(problem) |
| 4 | - } | 4 | + end |
| 5 | 5 | ||
| 6 | context "in unit way" do | 6 | context "in unit way" do |
| 7 | - let(:problem) { | 7 | + let(:problem) do |
| 8 | problem = Problem.new | 8 | problem = Problem.new |
| 9 | allow(problem).to receive(:errs).and_return(double(:criteria, only: [err_1, err_2])) | 9 | allow(problem).to receive(:errs).and_return(double(:criteria, only: [err_1, err_2])) |
| 10 | allow(problem).to receive(:comments).and_return(double(:criteria, only: [comment_1, comment_2])) | 10 | allow(problem).to receive(:comments).and_return(double(:criteria, only: [comment_1, comment_2])) |
| 11 | allow(problem).to receive(:delete) | 11 | allow(problem).to receive(:delete) |
| 12 | problem | 12 | problem |
| 13 | - } | 13 | + end |
| 14 | let(:err_1) { Err.new } | 14 | let(:err_1) { Err.new } |
| 15 | let(:err_2) { Err.new } | 15 | let(:err_2) { Err.new } |
| 16 | 16 |
spec/interactors/problem_merge_spec.rb
| @@ -4,9 +4,9 @@ describe ProblemMerge do | @@ -4,9 +4,9 @@ describe ProblemMerge do | ||
| 4 | 4 | ||
| 5 | describe "#initialize" do | 5 | describe "#initialize" do |
| 6 | it 'failed if less than 2 uniq problem pass in args' do | 6 | it 'failed if less than 2 uniq problem pass in args' do |
| 7 | - expect { | 7 | + expect do |
| 8 | ProblemMerge.new(problem) | 8 | ProblemMerge.new(problem) |
| 9 | - }.to raise_error(ArgumentError) | 9 | + end.to raise_error(ArgumentError) |
| 10 | end | 10 | end |
| 11 | 11 | ||
| 12 | it 'extract first problem like merged_problem' do | 12 | it 'extract first problem like merged_problem' do |
| @@ -20,18 +20,18 @@ describe ProblemMerge do | @@ -20,18 +20,18 @@ describe ProblemMerge do | ||
| 20 | end | 20 | end |
| 21 | 21 | ||
| 22 | describe "#merge" do | 22 | describe "#merge" do |
| 23 | - let!(:problem_merge) { | 23 | + let!(:problem_merge) do |
| 24 | ProblemMerge.new(problem, problem_1) | 24 | ProblemMerge.new(problem, problem_1) |
| 25 | - } | 25 | + end |
| 26 | let(:first_errs) { problem.errs } | 26 | let(:first_errs) { problem.errs } |
| 27 | let(:merged_errs) { problem_1.errs } | 27 | let(:merged_errs) { problem_1.errs } |
| 28 | let!(:notice) { Fabricate(:notice, err: first_errs.first) } | 28 | let!(:notice) { Fabricate(:notice, err: first_errs.first) } |
| 29 | let!(:notice_1) { Fabricate(:notice, err: merged_errs.first) } | 29 | let!(:notice_1) { Fabricate(:notice, err: merged_errs.first) } |
| 30 | 30 | ||
| 31 | it 'delete one of problem' do | 31 | it 'delete one of problem' do |
| 32 | - expect { | 32 | + expect do |
| 33 | problem_merge.merge | 33 | problem_merge.merge |
| 34 | - }.to change(Problem, :count).by(-1) | 34 | + end.to change(Problem, :count).by(-1) |
| 35 | end | 35 | end |
| 36 | 36 | ||
| 37 | it 'move all err in one problem' do | 37 | it 'move all err in one problem' do |
| @@ -55,9 +55,9 @@ describe ProblemMerge do | @@ -55,9 +55,9 @@ describe ProblemMerge do | ||
| 55 | let!(:comment) { Fabricate(:comment, err: problem) } | 55 | let!(:comment) { Fabricate(:comment, err: problem) } |
| 56 | let!(:comment_2) { Fabricate(:comment, err: problem_1, user: comment.user) } | 56 | let!(:comment_2) { Fabricate(:comment, err: problem_1, user: comment.user) } |
| 57 | it 'merge comment' do | 57 | it 'merge comment' do |
| 58 | - expect { | 58 | + expect do |
| 59 | problem_merge.merge | 59 | problem_merge.merge |
| 60 | - }.to change { | 60 | + end.to change { |
| 61 | problem.comments.size | 61 | problem.comments.size |
| 62 | }.from(1).to(2) | 62 | }.from(1).to(2) |
| 63 | expect(comment_2.reload.err).to eq problem | 63 | expect(comment_2.reload.err).to eq problem |
spec/interactors/resolved_problem_clearer_spec.rb
| 1 | describe ResolvedProblemClearer do | 1 | describe ResolvedProblemClearer do |
| 2 | - let(:resolved_problem_clearer) { | 2 | + let(:resolved_problem_clearer) do |
| 3 | ResolvedProblemClearer.new | 3 | ResolvedProblemClearer.new |
| 4 | - } | 4 | + end |
| 5 | describe "#execute" do | 5 | describe "#execute" do |
| 6 | - let!(:problems) { | 6 | + let!(:problems) do |
| 7 | [ | 7 | [ |
| 8 | Fabricate(:problem), | 8 | Fabricate(:problem), |
| 9 | Fabricate(:problem), | 9 | Fabricate(:problem), |
| 10 | Fabricate(:problem) | 10 | Fabricate(:problem) |
| 11 | ] | 11 | ] |
| 12 | - } | 12 | + end |
| 13 | context 'without problem resolved' do | 13 | context 'without problem resolved' do |
| 14 | it 'do nothing' do | 14 | it 'do nothing' do |
| 15 | - expect { | 15 | + expect do |
| 16 | expect(resolved_problem_clearer.execute).to eq 0 | 16 | expect(resolved_problem_clearer.execute).to eq 0 |
| 17 | - }.to_not change { | 17 | + end.to_not change { |
| 18 | Problem.count | 18 | Problem.count |
| 19 | } | 19 | } |
| 20 | end | 20 | end |
| @@ -34,9 +34,9 @@ describe ResolvedProblemClearer do | @@ -34,9 +34,9 @@ describe ResolvedProblemClearer do | ||
| 34 | end | 34 | end |
| 35 | 35 | ||
| 36 | it 'delete problem resolve' do | 36 | it 'delete problem resolve' do |
| 37 | - expect { | 37 | + expect do |
| 38 | expect(resolved_problem_clearer.execute).to eq 2 | 38 | expect(resolved_problem_clearer.execute).to eq 2 |
| 39 | - }.to change { | 39 | + end.to change { |
| 40 | Problem.count | 40 | Problem.count |
| 41 | }.by(-2) | 41 | }.by(-2) |
| 42 | expect(Problem.where(_id: problems.first.id).first).to be_nil | 42 | expect(Problem.where(_id: problems.first.id).first).to be_nil |
spec/interactors/user_destroy_spec.rb
| 1 | describe UserDestroy do | 1 | describe UserDestroy do |
| 2 | - let(:app) { | 2 | + let(:app) do |
| 3 | Fabricate( | 3 | Fabricate( |
| 4 | :app, | 4 | :app, |
| 5 | watchers: [ | 5 | watchers: [ |
| 6 | Fabricate.build(:user_watcher, user: user) | 6 | Fabricate.build(:user_watcher, user: user) |
| 7 | ]) | 7 | ]) |
| 8 | - } | 8 | + end |
| 9 | 9 | ||
| 10 | describe "#destroy" do | 10 | describe "#destroy" do |
| 11 | let!(:user) { Fabricate(:user) } | 11 | let!(:user) { Fabricate(:user) } |
| 12 | it 'should delete user' do | 12 | it 'should delete user' do |
| 13 | - expect { | 13 | + expect do |
| 14 | UserDestroy.new(user).destroy | 14 | UserDestroy.new(user).destroy |
| 15 | - }.to change(User, :count) | 15 | + end.to change(User, :count) |
| 16 | end | 16 | end |
| 17 | 17 | ||
| 18 | it 'should delete watcher' do | 18 | it 'should delete watcher' do |
| 19 | - expect { | 19 | + expect do |
| 20 | UserDestroy.new(user).destroy | 20 | UserDestroy.new(user).destroy |
| 21 | - }.to change { | 21 | + end.to change { |
| 22 | app.reload.watchers.where(user_id: user.id).count | 22 | app.reload.watchers.where(user_id: user.id).count |
| 23 | }.from(1).to(0) | 23 | }.from(1).to(0) |
| 24 | end | 24 | end |
spec/lib/airbrake_api/v3/notice_parser_spec.rb
| @@ -2,13 +2,13 @@ describe AirbrakeApi::V3::NoticeParser do | @@ -2,13 +2,13 @@ describe AirbrakeApi::V3::NoticeParser do | ||
| 2 | let(:app) { Fabricate(:app) } | 2 | let(:app) { Fabricate(:app) } |
| 3 | 3 | ||
| 4 | it 'raises error when errors attribute is missing' do | 4 | it 'raises error when errors attribute is missing' do |
| 5 | - expect { | 5 | + expect do |
| 6 | AirbrakeApi::V3::NoticeParser.new({}).report | 6 | AirbrakeApi::V3::NoticeParser.new({}).report |
| 7 | - }.to raise_error(AirbrakeApi::ParamsError) | 7 | + end.to raise_error(AirbrakeApi::ParamsError) |
| 8 | 8 | ||
| 9 | - expect { | 9 | + expect do |
| 10 | AirbrakeApi::V3::NoticeParser.new('errors' => []).report | 10 | AirbrakeApi::V3::NoticeParser.new('errors' => []).report |
| 11 | - }.to raise_error(AirbrakeApi::ParamsError) | 11 | + end.to raise_error(AirbrakeApi::ParamsError) |
| 12 | end | 12 | end |
| 13 | 13 | ||
| 14 | it 'parses JSON payload and returns ErrorReport' do | 14 | it 'parses JSON payload and returns ErrorReport' do |
spec/models/app_spec.rb
| @@ -164,13 +164,13 @@ describe App, type: 'model' do | @@ -164,13 +164,13 @@ describe App, type: 'model' do | ||
| 164 | 164 | ||
| 165 | context '#find_or_create_err!' do | 165 | context '#find_or_create_err!' do |
| 166 | let(:app) { Fabricate(:app) } | 166 | let(:app) { Fabricate(:app) } |
| 167 | - let(:conditions) { | 167 | + let(:conditions) do |
| 168 | { | 168 | { |
| 169 | error_class: 'Whoops', | 169 | error_class: 'Whoops', |
| 170 | environment: 'production', | 170 | environment: 'production', |
| 171 | fingerprint: 'some-finger-print' | 171 | fingerprint: 'some-finger-print' |
| 172 | } | 172 | } |
| 173 | - } | 173 | + end |
| 174 | 174 | ||
| 175 | it 'returns the correct err if one already exists' do | 175 | it 'returns the correct err if one already exists' do |
| 176 | existing = Fabricate( | 176 | existing = Fabricate( |
| @@ -188,23 +188,23 @@ describe App, type: 'model' do | @@ -188,23 +188,23 @@ describe App, type: 'model' do | ||
| 188 | 188 | ||
| 189 | it 'creates a new problem if a matching one does not already exist' do | 189 | it 'creates a new problem if a matching one does not already exist' do |
| 190 | expect(Err.where(conditions).first).to be_nil | 190 | expect(Err.where(conditions).first).to be_nil |
| 191 | - expect { | 191 | + expect do |
| 192 | app.find_or_create_err!(conditions) | 192 | app.find_or_create_err!(conditions) |
| 193 | - }.to change(Problem, :count).by(1) | 193 | + end.to change(Problem, :count).by(1) |
| 194 | end | 194 | end |
| 195 | 195 | ||
| 196 | context "without error_class" do | 196 | context "without error_class" do |
| 197 | - let(:conditions) { | 197 | + let(:conditions) do |
| 198 | { | 198 | { |
| 199 | environment: 'production', | 199 | environment: 'production', |
| 200 | fingerprint: 'some-finger-print' | 200 | fingerprint: 'some-finger-print' |
| 201 | } | 201 | } |
| 202 | - } | 202 | + end |
| 203 | it 'save the err' do | 203 | it 'save the err' do |
| 204 | expect(Err.where(conditions).first).to be_nil | 204 | expect(Err.where(conditions).first).to be_nil |
| 205 | - expect { | 205 | + expect do |
| 206 | app.find_or_create_err!(conditions) | 206 | app.find_or_create_err!(conditions) |
| 207 | - }.to change(Problem, :count).by(1) | 207 | + end.to change(Problem, :count).by(1) |
| 208 | end | 208 | end |
| 209 | end | 209 | end |
| 210 | end | 210 | end |
| @@ -215,9 +215,9 @@ describe App, type: 'model' do | @@ -215,9 +215,9 @@ describe App, type: 'model' do | ||
| 215 | expect(App.find_by_api_key!(app.api_key)).to eq app | 215 | expect(App.find_by_api_key!(app.api_key)).to eq app |
| 216 | end | 216 | end |
| 217 | it 'raise Mongoid::Errors::DocumentNotFound if not found' do | 217 | it 'raise Mongoid::Errors::DocumentNotFound if not found' do |
| 218 | - expect { | 218 | + expect do |
| 219 | App.find_by_api_key!('foo') | 219 | App.find_by_api_key!('foo') |
| 220 | - }.to raise_error(Mongoid::Errors::DocumentNotFound) | 220 | + end.to raise_error(Mongoid::Errors::DocumentNotFound) |
| 221 | end | 221 | end |
| 222 | end | 222 | end |
| 223 | end | 223 | end |
spec/models/error_report_spec.rb
| @@ -17,18 +17,18 @@ module Airbrake | @@ -17,18 +17,18 @@ module Airbrake | ||
| 17 | end | 17 | end |
| 18 | 18 | ||
| 19 | describe ErrorReport do | 19 | describe ErrorReport do |
| 20 | - let(:xml) { | 20 | + let(:xml) do |
| 21 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read | 21 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read |
| 22 | - } | 22 | + end |
| 23 | 23 | ||
| 24 | let(:error_report) { ErrorReport.new(xml) } | 24 | let(:error_report) { ErrorReport.new(xml) } |
| 25 | 25 | ||
| 26 | - let!(:app) { | 26 | + let!(:app) do |
| 27 | Fabricate( | 27 | Fabricate( |
| 28 | :app, | 28 | :app, |
| 29 | api_key: 'APIKEY' | 29 | api_key: 'APIKEY' |
| 30 | ) | 30 | ) |
| 31 | - } | 31 | + end |
| 32 | 32 | ||
| 33 | describe "#app" do | 33 | describe "#app" do |
| 34 | it 'find the good app' do | 34 | it 'find the good app' do |
| @@ -44,39 +44,39 @@ describe ErrorReport do | @@ -44,39 +44,39 @@ describe ErrorReport do | ||
| 44 | 44 | ||
| 45 | describe "#generate_notice!" do | 45 | describe "#generate_notice!" do |
| 46 | it "save a notice" do | 46 | it "save a notice" do |
| 47 | - expect { | 47 | + expect do |
| 48 | error_report.generate_notice! | 48 | error_report.generate_notice! |
| 49 | - }.to change { | 49 | + end.to change { |
| 50 | app.reload.problems.count | 50 | app.reload.problems.count |
| 51 | }.by(1) | 51 | }.by(1) |
| 52 | end | 52 | end |
| 53 | 53 | ||
| 54 | context "with a minimal notice" do | 54 | context "with a minimal notice" do |
| 55 | - let(:xml) { | 55 | + let(:xml) do |
| 56 | Rails.root.join('spec', 'fixtures', 'minimal_test_notice.xml').read | 56 | Rails.root.join('spec', 'fixtures', 'minimal_test_notice.xml').read |
| 57 | - } | 57 | + end |
| 58 | 58 | ||
| 59 | it 'save a notice' do | 59 | it 'save a notice' do |
| 60 | - expect { | 60 | + expect do |
| 61 | error_report.generate_notice! | 61 | error_report.generate_notice! |
| 62 | - }.to change { | 62 | + end.to change { |
| 63 | app.reload.problems.count | 63 | app.reload.problems.count |
| 64 | }.by(1) | 64 | }.by(1) |
| 65 | end | 65 | end |
| 66 | end | 66 | end |
| 67 | 67 | ||
| 68 | context "with notice generate by Airbrake gem" do | 68 | context "with notice generate by Airbrake gem" do |
| 69 | - let(:xml) { | 69 | + let(:xml) do |
| 70 | Airbrake::Notice.new( | 70 | Airbrake::Notice.new( |
| 71 | exception: Exception.new, | 71 | exception: Exception.new, |
| 72 | api_key: 'APIKEY', | 72 | api_key: 'APIKEY', |
| 73 | project_root: Rails.root | 73 | project_root: Rails.root |
| 74 | ).to_xml | 74 | ).to_xml |
| 75 | - } | 75 | + end |
| 76 | it 'save a notice' do | 76 | it 'save a notice' do |
| 77 | - expect { | 77 | + expect do |
| 78 | error_report.generate_notice! | 78 | error_report.generate_notice! |
| 79 | - }.to change { | 79 | + end.to change { |
| 80 | app.reload.problems.count | 80 | app.reload.problems.count |
| 81 | }.by(1) | 81 | }.by(1) |
| 82 | end | 82 | end |
| @@ -201,10 +201,10 @@ describe ErrorReport do | @@ -201,10 +201,10 @@ describe ErrorReport do | ||
| 201 | end | 201 | end |
| 202 | 202 | ||
| 203 | it 'memoize the notice' do | 203 | it 'memoize the notice' do |
| 204 | - expect { | 204 | + expect do |
| 205 | error_report.generate_notice! | 205 | error_report.generate_notice! |
| 206 | error_report.generate_notice! | 206 | error_report.generate_notice! |
| 207 | - }.to change { | 207 | + end.to change { |
| 208 | Notice.count | 208 | Notice.count |
| 209 | }.by(1) | 209 | }.by(1) |
| 210 | end | 210 | end |
| @@ -213,9 +213,9 @@ describe ErrorReport do | @@ -213,9 +213,9 @@ describe ErrorReport do | ||
| 213 | error_report.generate_notice! | 213 | error_report.generate_notice! |
| 214 | error_report.problem.resolve! | 214 | error_report.problem.resolve! |
| 215 | 215 | ||
| 216 | - expect { | 216 | + expect do |
| 217 | ErrorReport.new(xml).generate_notice! | 217 | ErrorReport.new(xml).generate_notice! |
| 218 | - }.to change { | 218 | + end.to change { |
| 219 | error_report.problem.reload.resolved? | 219 | error_report.problem.reload.resolved? |
| 220 | }.from(true).to(false) | 220 | }.from(true).to(false) |
| 221 | end | 221 | end |
| @@ -237,26 +237,26 @@ describe ErrorReport do | @@ -237,26 +237,26 @@ describe ErrorReport do | ||
| 237 | end | 237 | end |
| 238 | 238 | ||
| 239 | context "with xml without request section" do | 239 | context "with xml without request section" do |
| 240 | - let(:xml) { | 240 | + let(:xml) do |
| 241 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_request_section.xml').read | 241 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_request_section.xml').read |
| 242 | - } | 242 | + end |
| 243 | it "save a notice" do | 243 | it "save a notice" do |
| 244 | - expect { | 244 | + expect do |
| 245 | error_report.generate_notice! | 245 | error_report.generate_notice! |
| 246 | - }.to change { | 246 | + end.to change { |
| 247 | app.reload.problems.count | 247 | app.reload.problems.count |
| 248 | }.by(1) | 248 | }.by(1) |
| 249 | end | 249 | end |
| 250 | end | 250 | end |
| 251 | 251 | ||
| 252 | context "with xml with only a single line of backtrace" do | 252 | context "with xml with only a single line of backtrace" do |
| 253 | - let(:xml) { | 253 | + let(:xml) do |
| 254 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_with_one_line_of_backtrace.xml').read | 254 | Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_with_one_line_of_backtrace.xml').read |
| 255 | - } | 255 | + end |
| 256 | it "save a notice" do | 256 | it "save a notice" do |
| 257 | - expect { | 257 | + expect do |
| 258 | error_report.generate_notice! | 258 | error_report.generate_notice! |
| 259 | - }.to change { | 259 | + end.to change { |
| 260 | app.reload.problems.count | 260 | app.reload.problems.count |
| 261 | }.by(1) | 261 | }.by(1) |
| 262 | end | 262 | end |
spec/models/problem_spec.rb
| @@ -10,25 +10,25 @@ describe Problem, type: 'model' do | @@ -10,25 +10,25 @@ describe Problem, type: 'model' do | ||
| 10 | describe "Fabrication" do | 10 | describe "Fabrication" do |
| 11 | context "Fabricate(:problem)" do | 11 | context "Fabricate(:problem)" do |
| 12 | it 'should have no comment' do | 12 | it 'should have no comment' do |
| 13 | - expect { | 13 | + expect do |
| 14 | Fabricate(:problem) | 14 | Fabricate(:problem) |
| 15 | - }.to_not change(Comment, :count) | 15 | + end.to_not change(Comment, :count) |
| 16 | end | 16 | end |
| 17 | end | 17 | end |
| 18 | 18 | ||
| 19 | context "Fabricate(:problem_with_comments)" do | 19 | context "Fabricate(:problem_with_comments)" do |
| 20 | it 'should have 3 comments' do | 20 | it 'should have 3 comments' do |
| 21 | - expect { | 21 | + expect do |
| 22 | Fabricate(:problem_with_comments) | 22 | Fabricate(:problem_with_comments) |
| 23 | - }.to change(Comment, :count).by(3) | 23 | + end.to change(Comment, :count).by(3) |
| 24 | end | 24 | end |
| 25 | end | 25 | end |
| 26 | 26 | ||
| 27 | context "Fabricate(:problem_with_errs)" do | 27 | context "Fabricate(:problem_with_errs)" do |
| 28 | it 'should have 3 errs' do | 28 | it 'should have 3 errs' do |
| 29 | - expect { | 29 | + expect do |
| 30 | Fabricate(:problem_with_errs) | 30 | Fabricate(:problem_with_errs) |
| 31 | - }.to change(Err, :count).by(3) | 31 | + end.to change(Err, :count).by(3) |
| 32 | end | 32 | end |
| 33 | end | 33 | end |
| 34 | end | 34 | end |
| @@ -65,9 +65,9 @@ describe Problem, type: 'model' do | @@ -65,9 +65,9 @@ describe Problem, type: 'model' do | ||
| 65 | it "adding a notice caches its message" do | 65 | it "adding a notice caches its message" do |
| 66 | err = Fabricate(:err) | 66 | err = Fabricate(:err) |
| 67 | problem = err.problem | 67 | problem = err.problem |
| 68 | - expect { | 68 | + expect do |
| 69 | Fabricate(:notice, err: err, message: 'ERR 1') | 69 | Fabricate(:notice, err: err, message: 'ERR 1') |
| 70 | - }.to change(problem, :message).from(nil).to('ERR 1') | 70 | + end.to change(problem, :message).from(nil).to('ERR 1') |
| 71 | end | 71 | end |
| 72 | end | 72 | end |
| 73 | 73 | ||
| @@ -132,9 +132,9 @@ describe Problem, type: 'model' do | @@ -132,9 +132,9 @@ describe Problem, type: 'model' do | ||
| 132 | er.add_on_blank(:resolved) | 132 | er.add_on_blank(:resolved) |
| 133 | allow(problem).to receive(:errors).and_return(er) | 133 | allow(problem).to receive(:errors).and_return(er) |
| 134 | expect(problem).to_not be_valid | 134 | expect(problem).to_not be_valid |
| 135 | - expect { | 135 | + expect do |
| 136 | problem.resolve! | 136 | problem.resolve! |
| 137 | - }.to raise_error(Mongoid::Errors::Validations) | 137 | + end.to raise_error(Mongoid::Errors::Validations) |
| 138 | end | 138 | end |
| 139 | end | 139 | end |
| 140 | 140 | ||
| @@ -201,17 +201,17 @@ describe Problem, type: 'model' do | @@ -201,17 +201,17 @@ describe Problem, type: 'model' do | ||
| 201 | end | 201 | end |
| 202 | 202 | ||
| 203 | it "adding a notice increases #notices_count by 1" do | 203 | it "adding a notice increases #notices_count by 1" do |
| 204 | - expect { | 204 | + expect do |
| 205 | Fabricate(:notice, err: @err, message: 'ERR 1') | 205 | Fabricate(:notice, err: @err, message: 'ERR 1') |
| 206 | - }.to change(@problem.reload, :notices_count).from(0).to(1) | 206 | + end.to change(@problem.reload, :notices_count).from(0).to(1) |
| 207 | end | 207 | end |
| 208 | 208 | ||
| 209 | it "removing a notice decreases #notices_count by 1" do | 209 | it "removing a notice decreases #notices_count by 1" do |
| 210 | Fabricate(:notice, err: @err, message: 'ERR 1') | 210 | Fabricate(:notice, err: @err, message: 'ERR 1') |
| 211 | - expect { | 211 | + expect do |
| 212 | @err.notices.first.destroy | 212 | @err.notices.first.destroy |
| 213 | @problem.reload | 213 | @problem.reload |
| 214 | - }.to change(@problem, :notices_count).from(1).to(0) | 214 | + end.to change(@problem, :notices_count).from(1).to(0) |
| 215 | end | 215 | end |
| 216 | end | 216 | end |
| 217 | 217 | ||
| @@ -226,10 +226,10 @@ describe Problem, type: 'model' do | @@ -226,10 +226,10 @@ describe Problem, type: 'model' do | ||
| 226 | end | 226 | end |
| 227 | 227 | ||
| 228 | it "is updated when an app is updated" do | 228 | it "is updated when an app is updated" do |
| 229 | - expect { | 229 | + expect do |
| 230 | app.update_attributes!(name: "Bar App") | 230 | app.update_attributes!(name: "Bar App") |
| 231 | problem.reload | 231 | problem.reload |
| 232 | - }.to change(problem, :app_name).to("Bar App") | 232 | + end.to change(problem, :app_name).to("Bar App") |
| 233 | end | 233 | end |
| 234 | end | 234 | end |
| 235 | 235 | ||
| @@ -248,10 +248,10 @@ describe Problem, type: 'model' do | @@ -248,10 +248,10 @@ describe Problem, type: 'model' do | ||
| 248 | it "is updated when a deploy is created" do | 248 | it "is updated when a deploy is created" do |
| 249 | problem = Fabricate(:problem, app: @app, environment: "production") | 249 | problem = Fabricate(:problem, app: @app, environment: "production") |
| 250 | next_deploy = 5.minutes.ago | 250 | next_deploy = 5.minutes.ago |
| 251 | - expect { | 251 | + expect do |
| 252 | @deploy = Fabricate(:deploy, app: @app, created_at: next_deploy) | 252 | @deploy = Fabricate(:deploy, app: @app, created_at: next_deploy) |
| 253 | problem.reload | 253 | problem.reload |
| 254 | - }.to change { problem.last_deploy_at.iso8601 }. | 254 | + end.to change { problem.last_deploy_at.iso8601 }. |
| 255 | from(@last_deploy.iso8601). | 255 | from(@last_deploy.iso8601). |
| 256 | to(next_deploy.iso8601) | 256 | to(next_deploy.iso8601) |
| 257 | end | 257 | end |
| @@ -270,10 +270,10 @@ describe Problem, type: 'model' do | @@ -270,10 +270,10 @@ describe Problem, type: 'model' do | ||
| 270 | 270 | ||
| 271 | it "removing a notice removes string from #messages" do | 271 | it "removing a notice removes string from #messages" do |
| 272 | Fabricate(:notice, err: @err, message: 'ERR 1') | 272 | Fabricate(:notice, err: @err, message: 'ERR 1') |
| 273 | - expect { | 273 | + expect do |
| 274 | @err.notices.first.destroy | 274 | @err.notices.first.destroy |
| 275 | @problem.reload | 275 | @problem.reload |
| 276 | - }.to change(@problem, :messages).from(Digest::MD5.hexdigest('ERR 1') => { 'value' => 'ERR 1', 'count' => 1 }).to({}) | 276 | + end.to change(@problem, :messages).from(Digest::MD5.hexdigest('ERR 1') => { 'value' => 'ERR 1', 'count' => 1 }).to({}) |
| 277 | end | 277 | end |
| 278 | 278 | ||
| 279 | it "removing a notice from the problem with broken counter should not raise an error" do | 279 | it "removing a notice from the problem with broken counter should not raise an error" do |
| @@ -297,10 +297,10 @@ describe Problem, type: 'model' do | @@ -297,10 +297,10 @@ describe Problem, type: 'model' do | ||
| 297 | 297 | ||
| 298 | it "removing a notice removes string from #hosts" do | 298 | it "removing a notice removes string from #hosts" do |
| 299 | Fabricate(:notice, err: @err, request: { 'url' => "http://example.com/resource/12" }) | 299 | Fabricate(:notice, err: @err, request: { 'url' => "http://example.com/resource/12" }) |
| 300 | - expect { | 300 | + expect do |
| 301 | @err.notices.first.destroy | 301 | @err.notices.first.destroy |
| 302 | @problem.reload | 302 | @problem.reload |
| 303 | - }.to change(@problem, :hosts).from(Digest::MD5.hexdigest('example.com') => { 'value' => 'example.com', 'count' => 1 }).to({}) | 303 | + end.to change(@problem, :hosts).from(Digest::MD5.hexdigest('example.com') => { 'value' => 'example.com', 'count' => 1 }).to({}) |
| 304 | end | 304 | end |
| 305 | end | 305 | end |
| 306 | 306 | ||
| @@ -325,10 +325,10 @@ describe Problem, type: 'model' do | @@ -325,10 +325,10 @@ describe Problem, type: 'model' do | ||
| 325 | } | 325 | } |
| 326 | } | 326 | } |
| 327 | ) | 327 | ) |
| 328 | - expect { | 328 | + expect do |
| 329 | @err.notices.first.destroy | 329 | @err.notices.first.destroy |
| 330 | @problem.reload | 330 | @problem.reload |
| 331 | - }.to change(@problem, :user_agents). | 331 | + end.to change(@problem, :user_agents). |
| 332 | from( | 332 | from( |
| 333 | Digest::MD5.hexdigest('Chrome 10.0.648.204 (OS X 10.6.7)') => { | 333 | Digest::MD5.hexdigest('Chrome 10.0.648.204 (OS X 10.6.7)') => { |
| 334 | 'value' => 'Chrome 10.0.648.204 (OS X 10.6.7)', 'count' => 1 } | 334 | 'value' => 'Chrome 10.0.648.204 (OS X 10.6.7)', 'count' => 1 } |
| @@ -347,17 +347,17 @@ describe Problem, type: 'model' do | @@ -347,17 +347,17 @@ describe Problem, type: 'model' do | ||
| 347 | end | 347 | end |
| 348 | 348 | ||
| 349 | it "adding a comment increases #comments_count by 1" do | 349 | it "adding a comment increases #comments_count by 1" do |
| 350 | - expect { | 350 | + expect do |
| 351 | Fabricate(:comment, err: @problem) | 351 | Fabricate(:comment, err: @problem) |
| 352 | - }.to change(@problem, :comments_count).from(0).to(1) | 352 | + end.to change(@problem, :comments_count).from(0).to(1) |
| 353 | end | 353 | end |
| 354 | 354 | ||
| 355 | it "removing a comment decreases #comments_count by 1" do | 355 | it "removing a comment decreases #comments_count by 1" do |
| 356 | Fabricate(:comment, err: @problem) | 356 | Fabricate(:comment, err: @problem) |
| 357 | - expect { | 357 | + expect do |
| 358 | @problem.reload.comments.first.destroy | 358 | @problem.reload.comments.first.destroy |
| 359 | @problem.reload | 359 | @problem.reload |
| 360 | - }.to change(@problem, :comments_count).from(1).to(0) | 360 | + end.to change(@problem, :comments_count).from(1).to(0) |
| 361 | end | 361 | end |
| 362 | end | 362 | end |
| 363 | 363 | ||
| @@ -420,9 +420,9 @@ describe Problem, type: 'model' do | @@ -420,9 +420,9 @@ describe Problem, type: 'model' do | ||
| 420 | end | 420 | end |
| 421 | 421 | ||
| 422 | it 'update the notice_count' do | 422 | it 'update the notice_count' do |
| 423 | - expect { | 423 | + expect do |
| 424 | problem.recache | 424 | problem.recache |
| 425 | - }.to change { | 425 | + end.to change { |
| 426 | problem.notices_count | 426 | problem.notices_count |
| 427 | }.from(0).to(1) | 427 | }.from(0).to(1) |
| 428 | end | 428 | end |
spec/models/user_spec.rb
| @@ -39,10 +39,10 @@ describe User do | @@ -39,10 +39,10 @@ describe User do | ||
| 39 | 39 | ||
| 40 | context "First user" do | 40 | context "First user" do |
| 41 | it "should be created this admin access via db:seed" do | 41 | it "should be created this admin access via db:seed" do |
| 42 | - expect { | 42 | + expect do |
| 43 | allow($stdout).to receive(:puts).and_return(true) | 43 | allow($stdout).to receive(:puts).and_return(true) |
| 44 | require Rails.root.join('db/seeds.rb') | 44 | require Rails.root.join('db/seeds.rb') |
| 45 | - }.to change { | 45 | + end.to change { |
| 46 | User.where(admin: true).count | 46 | User.where(admin: true).count |
| 47 | }.from(0).to(1) | 47 | }.from(0).to(1) |
| 48 | end | 48 | end |
spec/requests/notices_controller_spec.rb
| @@ -5,10 +5,10 @@ describe "Notices management", type: 'request' do | @@ -5,10 +5,10 @@ describe "Notices management", type: 'request' do | ||
| 5 | context "with valide notice" do | 5 | context "with valide notice" do |
| 6 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } | 6 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } |
| 7 | it 'save a new notice' do | 7 | it 'save a new notice' do |
| 8 | - expect { | 8 | + expect do |
| 9 | post '/notifier_api/v2/notices', data: xml | 9 | post '/notifier_api/v2/notices', data: xml |
| 10 | expect(response).to be_success | 10 | expect(response).to be_success |
| 11 | - }.to change { | 11 | + end.to change { |
| 12 | errbit_app.problems.count | 12 | errbit_app.problems.count |
| 13 | }.by(1) | 13 | }.by(1) |
| 14 | end | 14 | end |
| @@ -17,10 +17,10 @@ describe "Notices management", type: 'request' do | @@ -17,10 +17,10 @@ describe "Notices management", type: 'request' do | ||
| 17 | context "with notice with empty backtrace" do | 17 | context "with notice with empty backtrace" do |
| 18 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_line_of_backtrace.xml').read } | 18 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice_without_line_of_backtrace.xml').read } |
| 19 | it 'save a new notice' do | 19 | it 'save a new notice' do |
| 20 | - expect { | 20 | + expect do |
| 21 | post '/notifier_api/v2/notices', data: xml | 21 | post '/notifier_api/v2/notices', data: xml |
| 22 | expect(response).to be_success | 22 | expect(response).to be_success |
| 23 | - }.to change { | 23 | + end.to change { |
| 24 | errbit_app.problems.count | 24 | errbit_app.problems.count |
| 25 | }.by(1) | 25 | }.by(1) |
| 26 | end | 26 | end |
| @@ -30,21 +30,21 @@ describe "Notices management", type: 'request' do | @@ -30,21 +30,21 @@ describe "Notices management", type: 'request' do | ||
| 30 | let(:errbit_app) { Fabricate(:app) } | 30 | let(:errbit_app) { Fabricate(:app) } |
| 31 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } | 31 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } |
| 32 | it 'not save a new notice and return 422' do | 32 | it 'not save a new notice and return 422' do |
| 33 | - expect { | 33 | + expect do |
| 34 | post '/notifier_api/v2/notices', data: xml | 34 | post '/notifier_api/v2/notices', data: xml |
| 35 | expect(response.status).to eq 422 | 35 | expect(response.status).to eq 422 |
| 36 | expect(response.body).to eq "Your API key is unknown" | 36 | expect(response.body).to eq "Your API key is unknown" |
| 37 | - }.to_not change(errbit_app.problems, :count) | 37 | + end.to_not change(errbit_app.problems, :count) |
| 38 | end | 38 | end |
| 39 | end | 39 | end |
| 40 | 40 | ||
| 41 | context "with GET request" do | 41 | context "with GET request" do |
| 42 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } | 42 | let(:xml) { Rails.root.join('spec', 'fixtures', 'hoptoad_test_notice.xml').read } |
| 43 | it 'save a new notice' do | 43 | it 'save a new notice' do |
| 44 | - expect { | 44 | + expect do |
| 45 | get '/notifier_api/v2/notices', data: xml | 45 | get '/notifier_api/v2/notices', data: xml |
| 46 | expect(response).to be_success | 46 | expect(response).to be_success |
| 47 | - }.to change { | 47 | + end.to change { |
| 48 | errbit_app.problems.count | 48 | errbit_app.problems.count |
| 49 | }.by(1) | 49 | }.by(1) |
| 50 | end | 50 | end |
spec/views/apps/edit.html.haml_spec.rb
| @@ -35,11 +35,11 @@ describe "apps/edit.html.haml", type: 'view' do | @@ -35,11 +35,11 @@ describe "apps/edit.html.haml", type: 'view' do | ||
| 35 | end | 35 | end |
| 36 | 36 | ||
| 37 | context "with unvalid app" do | 37 | context "with unvalid app" do |
| 38 | - let(:app) { | 38 | + let(:app) do |
| 39 | app = stub_model(App) | 39 | app = stub_model(App) |
| 40 | app.errors.add(:base, 'You must specify your') | 40 | app.errors.add(:base, 'You must specify your') |
| 41 | app | 41 | app |
| 42 | - } | 42 | + end |
| 43 | 43 | ||
| 44 | it 'see the error' do | 44 | it 'see the error' do |
| 45 | render | 45 | render |
spec/views/apps/new.html.haml_spec.rb
| @@ -21,11 +21,11 @@ describe "apps/new.html.haml", type: 'view' do | @@ -21,11 +21,11 @@ describe "apps/new.html.haml", type: 'view' do | ||
| 21 | end | 21 | end |
| 22 | 22 | ||
| 23 | context "with unvalid app" do | 23 | context "with unvalid app" do |
| 24 | - let(:app) { | 24 | + let(:app) do |
| 25 | app = stub_model(App) | 25 | app = stub_model(App) |
| 26 | app.errors.add(:base, 'You must specify your') | 26 | app.errors.add(:base, 'You must specify your') |
| 27 | app | 27 | app |
| 28 | - } | 28 | + end |
| 29 | 29 | ||
| 30 | it 'see the error' do | 30 | it 'see the error' do |
| 31 | render | 31 | render |
spec/views/issue_trackers/issue.md.erb_spec.rb
| 1 | describe "issue_trackers/issue.md.erb", type: 'view' do | 1 | describe "issue_trackers/issue.md.erb", type: 'view' do |
| 2 | - let(:problem) { | 2 | + let(:problem) do |
| 3 | problem = Fabricate(:problem) | 3 | problem = Fabricate(:problem) |
| 4 | Fabricate(:notice, err: Fabricate(:err, problem: problem)) | 4 | Fabricate(:notice, err: Fabricate(:err, problem: problem)) |
| 5 | problem | 5 | problem |
| 6 | - } | 6 | + end |
| 7 | 7 | ||
| 8 | before do | 8 | before do |
| 9 | allow(view).to receive(:problem).and_return(ProblemDecorator.new(problem)) | 9 | allow(view).to receive(:problem).and_return(ProblemDecorator.new(problem)) |
spec/views/issue_trackers/issue.txt.erb_spec.rb
| 1 | describe "issue_trackers/issue.txt.erb", type: 'view' do | 1 | describe "issue_trackers/issue.txt.erb", type: 'view' do |
| 2 | - let(:problem) { | 2 | + let(:problem) do |
| 3 | problem = Fabricate(:problem) | 3 | problem = Fabricate(:problem) |
| 4 | Fabricate(:notice, err: Fabricate(:err, problem: problem)) | 4 | Fabricate(:notice, err: Fabricate(:err, problem: problem)) |
| 5 | problem | 5 | problem |
| 6 | - } | 6 | + end |
| 7 | 7 | ||
| 8 | before do | 8 | before do |
| 9 | allow(view).to receive(:problem).and_return( | 9 | allow(view).to receive(:problem).and_return( |
spec/views/problems/show.html.haml_spec.rb
| 1 | describe "problems/show.html.haml", type: 'view' do | 1 | describe "problems/show.html.haml", type: 'view' do |
| 2 | let(:problem) { Fabricate(:problem) } | 2 | let(:problem) { Fabricate(:problem) } |
| 3 | let(:comment) { Fabricate(:comment) } | 3 | let(:comment) { Fabricate(:comment) } |
| 4 | - let(:pivotal_tracker) { | 4 | + let(:pivotal_tracker) do |
| 5 | Class.new(ErrbitPlugin::MockIssueTracker) do | 5 | Class.new(ErrbitPlugin::MockIssueTracker) do |
| 6 | def self.label | 6 | def self.label |
| 7 | 'pivotal' | 7 | 'pivotal' |
| @@ -15,8 +15,8 @@ describe "problems/show.html.haml", type: 'view' do | @@ -15,8 +15,8 @@ describe "problems/show.html.haml", type: 'view' do | ||
| 15 | true | 15 | true |
| 16 | end | 16 | end |
| 17 | end | 17 | end |
| 18 | - } | ||
| 19 | - let(:github_tracker) { | 18 | + end |
| 19 | + let(:github_tracker) do | ||
| 20 | Class.new(ErrbitPlugin::MockIssueTracker) do | 20 | Class.new(ErrbitPlugin::MockIssueTracker) do |
| 21 | def self.label | 21 | def self.label |
| 22 | 'github' | 22 | 'github' |
| @@ -30,13 +30,13 @@ describe "problems/show.html.haml", type: 'view' do | @@ -30,13 +30,13 @@ describe "problems/show.html.haml", type: 'view' do | ||
| 30 | true | 30 | true |
| 31 | end | 31 | end |
| 32 | end | 32 | end |
| 33 | - } | ||
| 34 | - let(:trackers) { | 33 | + end |
| 34 | + let(:trackers) do | ||
| 35 | { | 35 | { |
| 36 | 'github' => github_tracker, | 36 | 'github' => github_tracker, |
| 37 | 'pivotal' => pivotal_tracker | 37 | 'pivotal' => pivotal_tracker |
| 38 | } | 38 | } |
| 39 | - } | 39 | + end |
| 40 | let(:app) { AppDecorator.new(problem.app) } | 40 | let(:app) { AppDecorator.new(problem.app) } |
| 41 | 41 | ||
| 42 | before do | 42 | before do |
spec/views/users/edit.html.haml_spec.rb
| 1 | describe 'users/edit.html.haml', type: 'view' do | 1 | describe 'users/edit.html.haml', type: 'view' do |
| 2 | let(:user) { stub_model(User, name: 'shingara') } | 2 | let(:user) { stub_model(User, name: 'shingara') } |
| 3 | - before { | 3 | + before do |
| 4 | allow(view).to receive(:current_user).and_return(user) | 4 | allow(view).to receive(:current_user).and_return(user) |
| 5 | allow(view).to receive(:user).and_return(user) | 5 | allow(view).to receive(:user).and_return(user) |
| 6 | - } | 6 | + end |
| 7 | it 'should have per_page option' do | 7 | it 'should have per_page option' do |
| 8 | render | 8 | render |
| 9 | expect(rendered).to match(/id="user_per_page"/) | 9 | expect(rendered).to match(/id="user_per_page"/) |
spec/views/users/index.html.haml_spec.rb
| 1 | describe 'users/index.html.haml', type: 'view' do | 1 | describe 'users/index.html.haml', type: 'view' do |
| 2 | let(:user) { stub_model(User) } | 2 | let(:user) { stub_model(User) } |
| 3 | - before { | 3 | + before do |
| 4 | allow(view).to receive(:current_user).and_return(user) | 4 | allow(view).to receive(:current_user).and_return(user) |
| 5 | allow(view).to receive(:users).and_return( | 5 | allow(view).to receive(:users).and_return( |
| 6 | Kaminari.paginate_array([user], total_count: 1).page(1) | 6 | Kaminari.paginate_array([user], total_count: 1).page(1) |
| 7 | ) | 7 | ) |
| 8 | - } | 8 | + end |
| 9 | it 'should see users option' do | 9 | it 'should see users option' do |
| 10 | render | 10 | render |
| 11 | expect(rendered).to match(/class='user_list'/) | 11 | expect(rendered).to match(/class='user_list'/) |
spec/views/users/new.html.haml_spec.rb
| 1 | describe 'users/new.html.haml', type: 'view' do | 1 | describe 'users/new.html.haml', type: 'view' do |
| 2 | let(:user) { stub_model(User) } | 2 | let(:user) { stub_model(User) } |
| 3 | - before { | 3 | + before do |
| 4 | allow(view).to receive(:current_user).and_return(user) | 4 | allow(view).to receive(:current_user).and_return(user) |
| 5 | allow(view).to receive(:user).and_return(user) | 5 | allow(view).to receive(:user).and_return(user) |
| 6 | - } | 6 | + end |
| 7 | it 'should have per_page option' do | 7 | it 'should have per_page option' do |
| 8 | render | 8 | render |
| 9 | expect(rendered).to match(/id="user_per_page"/) | 9 | expect(rendered).to match(/id="user_per_page"/) |