diff --git a/README.md b/README.md index eaacd0a..b86e7c8 100644 --- a/README.md +++ b/README.md @@ -80,10 +80,6 @@ Configuration Errbit configuration is done entirely through environment variables. See [configuration](docs/configuration.md) -Deploy Hooks -------------- -Errbit can track your application deploys. See [deploy hooks](docs/deploy-hooks.md) - Deployment ---------- See [notes on deployment](docs/deployment.md) diff --git a/app/assets/javascripts/apps.show.js b/app/assets/javascripts/apps.show.js index f340d32..ee5e277 100644 --- a/app/assets/javascripts/apps.show.js +++ b/app/assets/javascripts/apps.show.js @@ -8,7 +8,4 @@ $(function() { $("#repository_div").slideToggle("slow"); }); - $("#deploys_toggle").click(function() { - $("#deploys_div").slideToggle("slow"); - }); }); diff --git a/app/assets/stylesheets/errbit.css.erb b/app/assets/stylesheets/errbit.css.erb index 3db0f61..c7d76cf 100644 --- a/app/assets/stylesheets/errbit.css.erb +++ b/app/assets/stylesheets/errbit.css.erb @@ -619,7 +619,7 @@ table.apps td.name, table.errs td.message { width: 100%; } table.apps td { padding: 16px 20px; } table.apps th { padding: 10px 20px; } -table.apps td.issue_tracker, table.apps td.count, table.apps td.deploy { +table.apps td.issue_tracker, table.apps td.count { text-align: center; } table.apps td.issue_tracker, table.apps td.count { @@ -631,9 +631,6 @@ td.message .line { display:inline-block; margin-left:1em; } -td.deploy { - white-space: nowrap; -} td.latest { white-space: nowrap; } @@ -719,11 +716,6 @@ table.tally th.value { text-transform: none; } -/* Deploys table */ -table.deploys td.when { - width: 102px; -} - /* Resolve Errs */ #action-bar .resolve:before { font-family: FontAwesome; @@ -854,7 +846,7 @@ table.backtrace tr.padding th, table.backtrace tr.padding td { padding: 0; } -h3#watchers_toggle, h3#repository_toggle, h3#deploys_toggle { +h3#watchers_toggle, h3#repository_toggle { cursor: pointer; } @@ -862,7 +854,7 @@ span.click_span { font-size: 0.7em; } -#deploys_div, #repository_div, #watchers_div { +#repository_div, #watchers_div { display: none; } diff --git a/app/controllers/apps_controller.rb b/app/controllers/apps_controller.rb index 0013ea5..a0366ac 100644 --- a/app/controllers/apps_controller.rb +++ b/app/controllers/apps_controller.rb @@ -34,10 +34,6 @@ class AppsController < ApplicationController end end - expose(:deploys) do - app.deploys.order_by(:created_at.desc).limit(5) - end - expose(:users) do User.all.sort_by { |u| u.name.downcase } end diff --git a/app/controllers/deploys_controller.rb b/app/controllers/deploys_controller.rb deleted file mode 100644 index 2301396..0000000 --- a/app/controllers/deploys_controller.rb +++ /dev/null @@ -1,42 +0,0 @@ -class DeploysController < ApplicationController - protect_from_forgery except: :create - - skip_before_action :verify_authenticity_token, only: :create - skip_before_action :authenticate_user!, only: :create - - def create - @app = App.find_by_api_key!(params[:api_key]) - @deploy = @app.deploys.create!(default_deploy || heroku_deploy) - render xml: @deploy - end - - def index - @app = App.find(params[:app_id]) - @deploys = Kaminari.paginate_array(@app.deploys.order_by(:created_at.desc)). - page(params[:page]).per(10) - end - -private - - def default_deploy - return if params[:deploy].blank? - - { - username: params[:deploy][:local_username], - environment: params[:deploy][:rails_env], - repository: params[:deploy][:scm_repository], - revision: params[:deploy][:scm_revision], - message: params[:deploy][:message] - } - end - - # handle Heroku's HTTP post deployhook format - def heroku_deploy - { - username: params[:user], - environment: params[:rack_env].try(:downcase) || params[:app], - repository: "git@heroku.com:#{params[:app]}.git", - revision: params[:head] - } - end -end diff --git a/app/controllers/problems_searcher.rb b/app/controllers/problems_searcher.rb index 1c14659..16a1de7 100644 --- a/app/controllers/problems_searcher.rb +++ b/app/controllers/problems_searcher.rb @@ -6,7 +6,7 @@ module ProblemsSearcher included do expose(:params_sort) do - if %w(app message last_notice_at last_deploy_at count).member?(params[:sort]) + if %w(app message last_notice_at count).member?(params[:sort]) params[:sort] else "last_notice_at" diff --git a/app/helpers/application_helper.rb b/app/helpers/application_helper.rb index 55f86fc..8940306 100644 --- a/app/helpers/application_helper.rb +++ b/app/helpers/application_helper.rb @@ -19,21 +19,6 @@ module ApplicationHelper end.to_s end - def generate_ical(deploys) - RiCal.Calendar do |cal| - deploys.each_with_index do |deploy, idx| - cal.event do |event| - event.summary = "#{idx + 1} #{deploy.repository}" - event.description = deploy.revision.to_s - event.dtstart = deploy.created_at.utc - event.dtend = deploy.created_at.utc + 60.minutes - event.location = deploy.environment.to_s - event.organizer = deploy.username.to_s - end - end - end.to_s - end - def user_agent_graph(problem) create_percentage_table_for(problem.user_agents) end diff --git a/app/helpers/apps_helper.rb b/app/helpers/apps_helper.rb index 5ca2e2c..cf9731f 100644 --- a/app/helpers/apps_helper.rb +++ b/app/helpers/apps_helper.rb @@ -31,19 +31,13 @@ module AppsHelper @any_issue_trackers end - def any_deploys? - detect_any_apps_with_attributes if @any_deploys.nil? - @any_deploys - end - private def detect_any_apps_with_attributes - @any_github_repos = @any_issue_trackers = @any_deploys = @any_bitbucket_repos = @any_notification_services = false + @any_github_repos = @any_issue_trackers = @any_bitbucket_repos = @any_notification_services = false apps.each do |app| @any_github_repos ||= app.github_repo? @any_bitbucket_repos ||= app.bitbucket_repo? @any_issue_trackers ||= app.issue_tracker_configured? - @any_deploys ||= app.last_deploy_at.present? @any_notification_services ||= app.notification_service_configured? end end diff --git a/app/mailers/mailer.rb b/app/mailers/mailer.rb index 1013793..1acd24d 100644 --- a/app/mailers/mailer.rb +++ b/app/mailers/mailer.rb @@ -27,19 +27,6 @@ class Mailer < ActionMailer::Base subject: "#{count}[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}" end - def deploy_notification(deploy) - @deploy = deploy - @app = AppDecorator.new deploy.app - - errbit_headers 'App' => @app.name, - 'Environment' => @deploy.environment, - 'Deploy-Revision' => @deploy.revision, - 'Deploy-User' => @deploy.username - - mail to: @app.notification_recipients, - subject: "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}" - end - def comment_notification(comment) @comment = comment @user = comment.user diff --git a/app/models/app.rb b/app/models/app.rb index 5991bb0..37d9ca7 100644 --- a/app/models/app.rb +++ b/app/models/app.rb @@ -10,10 +10,8 @@ class App field :asset_host field :repository_branch field :current_app_version - field :resolve_errs_on_deploy, type: Boolean, default: false field :notify_all_users, type: Boolean, default: false field :notify_on_errs, type: Boolean, default: true - field :notify_on_deploys, type: Boolean, default: false field :email_at_notices, type: Array, default: Errbit::Config.email_at_notices # Some legacy apps may have string as key instead of BSON::ObjectID @@ -24,7 +22,6 @@ class App default: -> { BSON::ObjectId.new.to_s } embeds_many :watchers - embeds_many :deploys embeds_one :issue_tracker, class_name: 'IssueTracker' embeds_one :notification_service embeds_one :notice_fingerprinter, autobuild: true @@ -86,11 +83,7 @@ class App find_by(api_key: key) end - def last_deploy_at - (last_deploy = deploys.last) && last_deploy.created_at - end - - # Legacy apps don't have notify_on_errs and notify_on_deploys params + # Legacy apps don't have notify_on_errs param def notify_on_errs !(super == false) end @@ -100,11 +93,6 @@ class App notify_on_errs? && notification_recipients.any? end - def notify_on_deploys - !(super == false) - end - alias_method :notify_on_deploys?, :notify_on_deploys - def repo_branch repository_branch.present? ? repository_branch : 'master' end @@ -159,7 +147,7 @@ class App (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k| send("#{k}=", copy_app.send(k)) end - # Clone the embedded objects that can be changed via apps/edit (ignore errs & deploys, etc.) + # Clone the embedded objects that can be changed via apps/edit (ignore errs, etc.) %w(watchers issue_tracker notification_service).each do |relation| if (obj = copy_app.send(relation)) send("#{relation}=", obj.is_a?(Array) ? obj.map(&:clone) : obj.clone) diff --git a/app/models/deploy.rb b/app/models/deploy.rb deleted file mode 100644 index 3448f53..0000000 --- a/app/models/deploy.rb +++ /dev/null @@ -1,46 +0,0 @@ -class Deploy - include Mongoid::Document - include Mongoid::Timestamps - - field :username - field :repository - field :environment - field :revision - field :message - - index(created_at: -1) - - embedded_in :app, inverse_of: :deploys - - after_create :resolve_app_errs, if: :should_resolve_app_errs? - after_create :store_cached_attributes_on_problems - after_create :deliver_email - - validates :username, :environment, presence: true - - def resolve_app_errs - app.problems.unresolved.in_env(environment).each(&:resolve!) - end - - def short_revision - revision.to_s[0, 7] - end - -protected - - def should_resolve_app_errs? - app.resolve_errs_on_deploy? - end - - def store_cached_attributes_on_problems - Problem.where(app_id: app.id).update_all( - last_deploy_at: created_at - ) - end - - def deliver_email - if app.notify_on_deploys? && app.notification_recipients.any? - Mailer.deploy_notification(self).deliver_now - end - end -end diff --git a/app/models/problem.rb b/app/models/problem.rb index ed9f127..c8c8d07 100644 --- a/app/models/problem.rb +++ b/app/models/problem.rb @@ -14,7 +14,6 @@ class Problem field :last_notice_at, type: ActiveSupport::TimeWithZone, default: proc { Time.zone.now } field :first_notice_at, type: ActiveSupport::TimeWithZone, default: proc { Time.zone.now } - field :last_deploy_at, type: Time field :resolved, type: Boolean, default: false field :resolved_at, type: Time field :issue_link, type: String @@ -37,7 +36,6 @@ class Problem index message: 1 index last_notice_at: 1 index first_notice_at: 1 - index last_deploy_at: 1 index resolved_at: 1 index notices_count: 1 @@ -216,17 +214,13 @@ class Problem when "app" then order_by(["app_name", order]) when "message" then order_by(["message", order]) when "last_notice_at" then order_by(["last_notice_at", order]) - when "last_deploy_at" then order_by(["last_deploy_at", order]) when "count" then order_by(["notices_count", order]) else fail("\"#{sort}\" is not a recognized sort") end end def cache_app_attributes - if app - self.app_name = app.name - self.last_deploy_at = app.last_deploy_at - end + self.app_name = app.name if app end def truncate_message diff --git a/app/views/apps/_fields.html.haml b/app/views/apps/_fields.html.haml index d44de9b..4a89dd7 100644 --- a/app/views/apps/_fields.html.haml +++ b/app/views/apps/_fields.html.haml @@ -36,17 +36,10 @@ .field-helpertext Send a notification every = f.text_field :email_at_notices, :value => app_decorate.email_at_notices .field-helpertext times an error occurs (comma separated). - %div.checkbox - = f.check_box :notify_on_deploys - = f.label :notify_on_deploys, 'Notify on deploys' %div.checkbox = f.check_box :notify_all_users = f.label :notify_all_users, 'Send notifications to all users' -%div.checkbox - = f.check_box :resolve_errs_on_deploy - = f.label :resolve_errs_on_deploy, 'Resolve errs on deploy' - = render "issue_tracker_fields", :f => f = render "service_notification_fields", :f => f diff --git a/app/views/apps/index.html.haml b/app/views/apps/index.html.haml index be3f802..8c80b26 100644 --- a/app/views/apps/index.html.haml +++ b/app/views/apps/index.html.haml @@ -16,8 +16,6 @@ %th= t('.notify') - if any_issue_trackers? %th= t('.tracker') - - if any_deploys? - %th= t('.last_deploy') %th=t('.errors') %tbody - apps.each do |app| @@ -45,11 +43,6 @@ = link_to( tracker_img, app.issue_tracker.url ) - else = tracker_img - - if any_deploys? - %td.deploy - - if app.last_deploy_at - - revision = app.deploys.last.short_revision - = link_to( app.last_deploy_at.to_s(:micro) << (revision.present? ? " (#{revision})" : ""), app_deploys_path(app)) %td.count - if app.problem_count > 0 - unresolved = app.unresolved_count diff --git a/app/views/apps/show.html.haml b/app/views/apps/show.html.haml index 4092191..6c96bb2 100644 --- a/app/views/apps/show.html.haml +++ b/app/views/apps/show.html.haml @@ -7,8 +7,6 @@ = app.current_app_version %strong=t('.errors_caught') = app.problems.count - %strong=t('.deploy_count') - = app.deploys.count %strong=t('.api_key') = app.api_key - content_for :action_bar do @@ -60,34 +58,6 @@ %tr %td= link_to(app.github_repo, app.github_url, :target => '_blank') -%h3#deploys_toggle - =t('.latest_deploys') - %span.click_span=t('.show_hide') -#deploys_div - - if deploys.any? - %table.deploys - %thead - %tr - %th=t('.when') - %th=t('.environment') - %th=t('.who') - %th=t('.message') - %th=t('.repository') - %th=t('.revision') - - %tbody - - deploys.each do |deploy| - %tr - %td.when #{deploy.created_at.to_s(:micro)} - %td.environment #{deploy.environment} - %td.who #{deploy.username} - %td.message #{deploy.message} - %td.repository #{deploy.repository} - %td.revision #{deploy.short_revision} - = link_to t('.all_deploys', :count => app.deploys.count), app_deploys_path(app), :class => 'button' - - else - %h3=t('.no_deploys') - - if app.problems.any? %h3.clear=t('.errors') %section diff --git a/app/views/deploys/_table.html.haml b/app/views/deploys/_table.html.haml deleted file mode 100644 index 3cea070..0000000 --- a/app/views/deploys/_table.html.haml +++ /dev/null @@ -1,21 +0,0 @@ -%table.errs - %thead - %tr - %th App - %th When - %th Who - %th Message - %th Repository - %th Revision - %tbody - - deploys.each do |deploy| - %tr - %td.app - = deploy.app.name - %span.environment= deploy.environment - %td.latest= deploy.created_at.to_s(:micro) - %td.who= deploy.username - %td.message= deploy.message - %td.repository= deploy.repository - %td.revision= deploy.short_revision - diff --git a/app/views/deploys/index.html.haml b/app/views/deploys/index.html.haml deleted file mode 100644 index fec5a4c..0000000 --- a/app/views/deploys/index.html.haml +++ /dev/null @@ -1,10 +0,0 @@ -- content_for :title, 'Deploys' -- content_for :action_bar do - - if current_user.authentication_token - %span - = link_to app_deploys_path(@app, :format => "ics", :auth_token => current_user.authentication_token) do - %i.fa.fa-calendar - iCal -= render 'table', :deploys => @deploys -= paginate @deploys - diff --git a/app/views/deploys/index.ics.haml b/app/views/deploys/index.ics.haml deleted file mode 100644 index 629b13b..0000000 --- a/app/views/deploys/index.ics.haml +++ /dev/null @@ -1 +0,0 @@ -= generate_ical(@app.deploys.order_by(:created_at.asc)) diff --git a/app/views/mailer/deploy_notification.html.haml b/app/views/mailer/deploy_notification.html.haml deleted file mode 100644 index 6338bea..0000000 --- a/app/views/mailer/deploy_notification.html.haml +++ /dev/null @@ -1,30 +0,0 @@ -%tr - %td.section - %table(cellpadding="0" cellspacing="0" border="0" align="left") - %tbody - %tr - %td.content(valign="top") - %div - %p - = link_to(@app.name, app_url(@app), :class => "bold") - was just deployed to - %span.bold= @deploy.environment - by - %span.bold= @deploy.username + "." - -%tr - %td.section - %table(cellpadding="0" cellspacing="0" border="0" align="left") - %tbody - %tr - %td.content(valign="top") - %div - %p.heading REVISION: - %p= @deploy.revision - %p.heading MESSAGE: - %p= @deploy.message.blank? ? 'n/a' : @deploy.message - %p.heading WHEN: - %p= @deploy.created_at.to_s(:rfc822) - %p.heading REPOSITORY: - %p= @deploy.repository.blank? ? 'n/a' : link_to(nil, @deploy.repository) - diff --git a/app/views/mailer/deploy_notification.text.erb b/app/views/mailer/deploy_notification.text.erb deleted file mode 100644 index f00c0fb..0000000 --- a/app/views/mailer/deploy_notification.text.erb +++ /dev/null @@ -1,22 +0,0 @@ -<%= @app.name %> was just deployed to <%= @deploy.environment %> by <%= @deploy.username %>. - - -REVISION: - -<%= @deploy.revision %> - - -MESSAGE: - -<%= @deploy.message.blank? ? 'n/a' : @deploy.message %> - - -WHEN: - -<%= @deploy.created_at.to_s(:rfc822) %> - - -REPOSITORY: - -<%= @deploy.repository.blank? ? 'n/a' : @deploy.repository %> - diff --git a/app/views/problems/_table.html.haml b/app/views/problems/_table.html.haml index 37a6225..c91db41 100644 --- a/app/views/problems/_table.html.haml +++ b/app/views/problems/_table.html.haml @@ -7,7 +7,6 @@ %th= link_for_sort "App" %th= link_for_sort "What & Where".html_safe, "message" %th= link_for_sort "Latest", "last_notice_at" - %th= link_for_sort "Deploy", "last_deploy_at" %th= link_for_sort "Count" - if any_issue_links %th Issue @@ -34,7 +33,6 @@ %em.commenter= (Errbit::Config.user_has_username ? comment.user.username : comment.user.email).to_s << ":" %em= truncate(comment.body, :length => 100, :separator => ' ') %td.latest #{time_ago_in_words(problem.last_notice_at)} ago - %td.deploy= problem.last_deploy_at ? problem.last_deploy_at.to_s(:micro) : 'n/a' %td.count= link_to problem.notices_count, app_problem_path(problem.app, problem) - if any_issue_links %td.issue_link diff --git a/config/initializers/ssl_enforcer.rb b/config/initializers/ssl_enforcer.rb index d064638..3ec289b 100644 --- a/config/initializers/ssl_enforcer.rb +++ b/config/initializers/ssl_enforcer.rb @@ -3,6 +3,6 @@ if Errbit::Config.enforce_ssl require 'rack/ssl-enforcer' ActionMailer::Base.default_url_options.merge!(protocol: 'https://') Rails.application.configure do - config.middleware.use Rack::SslEnforcer, except: %r{^/deploys} + config.middleware.use Rack::SslEnforcer end end diff --git a/config/locales/en.yml b/config/locales/en.yml index a430639..272a926 100644 --- a/config/locales/en.yml +++ b/config/locales/en.yml @@ -92,7 +92,6 @@ en: index: notify: Notification Service tracker: Tracker - last_deploy: Last Deploy errors: Errors name: Name repository: Repository @@ -103,21 +102,17 @@ en: fields: regenerate_api_key: "Regenerate API key" show: - all_deploys: "All Deploys (%{count})" all_errs: all errors all_users_notified: "All users will be notified when something happens." api_key: "API Key:" are_you_sure: 'Are you sure?' atom_title: "Errbit notices for %{name} at %{host}" - deploy_count: "Deploy Count:" edit: edit environment: Environment errors: Errors errors_caught: "Errors Caught:" github_repo: GitHub Repo - latest_deploys: Latest Deploys message: Message - no_deploys: No deploys no_error_yet: "No errors have been caught yet, make sure you setup your app" no_watcher: "Sadly, no one is watching this app" repository: Repository diff --git a/config/routes.rb b/config/routes.rb index 2464fdd..3164fb5 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -4,10 +4,8 @@ Rails.application.routes.draw do # Hoptoad Notifier Routes match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post] get '/locate/:id' => 'notices#locate', :as => :locate - post '/deploys.txt' => 'deploys#create' resources :notices, only: [:show] - resources :deploys, only: [:show] resources :users do member do delete :unlink_github @@ -47,7 +45,6 @@ Rails.application.routes.draw do delete :unlink_issue end end - resources :deploys, only: [:index] resources :watchers, only: [:destroy, :update] member do post :regenerate_api_key diff --git a/docs/deploy-hooks.md b/docs/deploy-hooks.md deleted file mode 100644 index d2e9d52..0000000 --- a/docs/deploy-hooks.md +++ /dev/null @@ -1,47 +0,0 @@ -# Deploy Hooks -Errbit can track your application deploys if you send a special message to -Errbit whenever you deploy. - -## From heroku -If you're using heroku, you can add a deploy hook like this: -~~~bash -$ heroku addons:add deployhooks:http \ - --url=http://myerrbit.com/deploys.txt -~~~ - -## From the airbrake gem using the rake task -The airbrake gem comes with a nice rake task for sending deploy hooks. Assuming -you already have it configured, you can send hooks like this: -~~~bash -$ TO=env-name \ - REVISION=rev-string \ - REPO=repo-string \ - USER=user-string \ - rake airbrake:deploy -~~~ - -## From the airbrake gem using capistrano 3 -In your application's Capfile, insert: -~~~ruby -require 'airbrake/capistrano3' -~~~ - -This will add a new capistrano task named ```airbrake:deploy``` which ends up -calling ```rake airbrake:deploy``` with the values from your capistrano config. -You may need to set the ```API_KEY``` environment variable on the target -application. - -## From curl -Errbit supports sending a message along with your deploy hook. The airbrake gem -doesn't support this, but you can easily send it along yourself. Here's an -example using cURL: -~~~bash -$ curl https://myerrbit.com/deploys.txt \ - --data "api_key=406e4374bf508ad0d7732c2d35ed380d" \ - --data "app_id=cb71ca8429732ba86b90d57c" \ - --data "deploy[local_username]=user-string" \ - --data "deploy[rails_env]=env-name" \ - --data "deploy[scm_repository]=repo-string" \ - --data "deploy[scm_revision]=rev-string" \ - --data "deploy[message]=my-message" -~~~ diff --git a/docs/deployment/heroku.md b/docs/deployment/heroku.md index b506a71..a5e4df9 100644 --- a/docs/deployment/heroku.md +++ b/docs/deployment/heroku.md @@ -75,8 +75,3 @@ Option 3. Clear resolved errors manually: ```bash heroku run rake errbit:db:clear_resolved ``` - -### Add the deployment hook -```bash -heroku addons:create deployhooks:http --url="http://YOUR_ERRBIT_HOST/deploys.txt?api_key=YOUR_API_KEY" -``` diff --git a/spec/controllers/deploys_controller_spec.rb b/spec/controllers/deploys_controller_spec.rb deleted file mode 100644 index 4d8287d..0000000 --- a/spec/controllers/deploys_controller_spec.rb +++ /dev/null @@ -1,57 +0,0 @@ -describe DeploysController, type: 'controller' do - render_views - - context 'POST #create' do - before do - @params = { - 'local_username' => 'john.doe', - 'scm_repository' => 'git@github.com/errbit/errbit.git', - 'rails_env' => 'production', - 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5', - 'message' => 'johns first deploy' - } - @app = Fabricate(:app_with_watcher, notify_on_deploys: true, api_key: 'APIKEY') - end - - it 'finds the app via the api key' do - expect(App).to receive(:find_by_api_key!).with('APIKEY').and_return(@app) - post :create, deploy: @params, api_key: 'APIKEY' - end - - it 'creates a deploy' do - expect(App).to receive(:find_by_api_key!).and_return(@app) - expect(@app.deploys).to receive(:create!). - with( - username: 'john.doe', - environment: 'production', - repository: 'git@github.com/errbit/errbit.git', - revision: '19d77837eef37902cf5df7e4445c85f392a8d0d5', - message: 'johns first deploy').and_return(Fabricate(:deploy)) - post :create, deploy: @params, api_key: 'APIKEY' - end - - it 'sends an email notification when configured to do so' do - post :create, deploy: @params, api_key: 'APIKEY' - email = ActionMailer::Base.deliveries.last - expect(email.to).to include(@app.watchers.first.email) - expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe" - end - end - - context "GET #index" do - before(:each) do - @deploy = Fabricate :deploy - sign_in Fabricate(:admin) - get :index, app_id: @deploy.app.id - end - - it "should render successfully" do - expect(response).to be_success - end - - it "should contain info about existing deploy" do - expect(response.body).to match(@deploy.short_revision) - expect(response.body).to match(@deploy.app.name) - end - end -end diff --git a/spec/fabricators/app_fabricator.rb b/spec/fabricators/app_fabricator.rb index 46a3f98..58a219f 100644 --- a/spec/fabricators/app_fabricator.rb +++ b/spec/fabricators/app_fabricator.rb @@ -19,11 +19,3 @@ Fabricator(:user_watcher, from: :watcher) do user watcher_type 'user' end - -Fabricator(:deploy) do - app - username 'clyde.frog' - repository 'git@github.com/errbit/errbit.git' - environment 'production' - revision { SecureRandom.hex(10) } -end diff --git a/spec/models/app_spec.rb b/spec/models/app_spec.rb index 6cac76a..c48a9e0 100644 --- a/spec/models/app_spec.rb +++ b/spec/models/app_spec.rb @@ -3,7 +3,7 @@ describe App, type: 'model' do it { is_expected.to have_field(:_id).of_type(String) } it { is_expected.to have_field(:name).of_type(String) } it { is_expected.to have_fields(:api_key, :github_repo, :bitbucket_repo, :asset_host, :repository_branch) } - it { is_expected.to have_fields(:resolve_errs_on_deploy, :notify_all_users, :notify_on_errs, :notify_on_deploys).of_type(Mongoid::Boolean) } + it { is_expected.to have_fields(:notify_all_users, :notify_on_errs).of_type(Mongoid::Boolean) } it { is_expected.to have_field(:email_at_notices).of_type(Array).with_default_value_of(Errbit::Config.email_at_notices) } end diff --git a/spec/models/deploy_observer_spec.rb b/spec/models/deploy_observer_spec.rb deleted file mode 100644 index e578565..0000000 --- a/spec/models/deploy_observer_spec.rb +++ /dev/null @@ -1,18 +0,0 @@ -describe "Callback on Deploy", type: 'model' do - context 'when a Deploy is saved' do - context 'and the app should notify on deploys' do - it 'should send an email notification' do - expect(Mailer).to receive(:deploy_notification). - and_return(double('email', deliver_now: true)) - Fabricate(:deploy, app: Fabricate(:app_with_watcher, notify_on_deploys: true)) - end - end - - context 'and the app is not set to notify on deploys' do - it 'should not send an email notification' do - expect(Mailer).to_not receive(:deploy_notification) - Fabricate(:deploy, app: Fabricate(:app_with_watcher, notify_on_deploys: false)) - end - end - end -end diff --git a/spec/models/deploy_spec.rb b/spec/models/deploy_spec.rb deleted file mode 100644 index 85cb068..0000000 --- a/spec/models/deploy_spec.rb +++ /dev/null @@ -1,41 +0,0 @@ -describe Deploy, type: 'model' do - context 'validations' do - it 'requires a username' do - deploy = Fabricate.build(:deploy, username: nil) - expect(deploy).to_not be_valid - expect(deploy.errors[:username]).to include("can't be blank") - end - - it 'requires an environment' do - deploy = Fabricate.build(:deploy, environment: nil) - expect(deploy).to_not be_valid - expect(deploy.errors[:environment]).to include("can't be blank") - end - end - - context 'being created' do - context 'when the app has resolve_errs_on_deploy set to false' do - it 'should not resolve the apps errs' do - app = Fabricate(:app, resolve_errs_on_deploy: false) - @problems = 3.times.map { Fabricate(:err, problem: Fabricate(:problem, resolved: false, app: app)) } - Fabricate(:deploy, app: app) - expect(app.reload.problems.none?(&:resolved?)).to eq true - end - end - - context 'when the app has resolve_errs_on_deploy set to true' do - it 'should resolve the apps errs that were in the same environment' do - app = Fabricate(:app, resolve_errs_on_deploy: true) - @prod_errs = 3.times.map { Fabricate(:problem, resolved: false, app: app, environment: 'production') } - @staging_errs = 3.times.map { Fabricate(:problem, resolved: false, app: app, environment: 'staging') } - Fabricate(:deploy, app: app, environment: 'production') - expect(@prod_errs.all? { |problem| problem.reload.resolved? }).to eq true - expect(@staging_errs.all? { |problem| problem.reload.resolved? }).to eq false - end - end - end - - it "should produce a shortened revision with 7 characters" do - expect(Deploy.new(revision: "1234567890abcdef").short_revision).to eq "1234567" - end -end diff --git a/spec/models/problem_spec.rb b/spec/models/problem_spec.rb index 5dda16d..9ed1dab 100644 --- a/spec/models/problem_spec.rb +++ b/spec/models/problem_spec.rb @@ -233,30 +233,6 @@ describe Problem, type: 'model' do end end - context "#last_deploy_at" do - before do - @app = Fabricate(:app) - @last_deploy = 10.days.ago - Fabricate(:deploy, app: @app, created_at: @last_deploy, environment: "production") - end - - it "is set when a problem is created" do - problem = Fabricate(:problem, app: @app, environment: "production") - assert_equal @last_deploy, problem.last_deploy_at - end - - it "is updated when a deploy is created" do - problem = Fabricate(:problem, app: @app, environment: "production") - next_deploy = 5.minutes.ago - expect do - @deploy = Fabricate(:deploy, app: @app, created_at: next_deploy) - problem.reload - end.to change { problem.last_deploy_at.iso8601 }. - from(@last_deploy.iso8601). - to(next_deploy.iso8601) - end - end - context "notice messages cache" do before do @app = Fabricate(:app) diff --git a/spec/views/apps/index.html.haml_spec.rb b/spec/views/apps/index.html.haml_spec.rb deleted file mode 100644 index aa37382..0000000 --- a/spec/views/apps/index.html.haml_spec.rb +++ /dev/null @@ -1,14 +0,0 @@ -describe "apps/index.html.haml", type: 'view' do - before do - app = stub_model(App, deploys: [stub_model(Deploy, created_at: Time.zone.now, revision: "123456789abcdef")]) - allow(view).to receive(:apps).and_return([app]) - allow(controller).to receive(:current_user).and_return(stub_model(User)) - end - - describe "deploy column" do - it "should show the first 7 characters of the revision in parentheses" do - render - expect(rendered).to match(/\(1234567\)/) - end - end -end diff --git a/spec/views/apps/show.html.haml_spec.rb b/spec/views/apps/show.html.haml_spec.rb index 15eb6b6..81bca8c 100644 --- a/spec/views/apps/show.html.haml_spec.rb +++ b/spec/views/apps/show.html.haml_spec.rb @@ -9,7 +9,6 @@ describe "apps/show.html.haml", type: 'view' do before do allow(view).to receive(:app).and_return(app) allow(view).to receive(:all_errs).and_return(false) - allow(view).to receive(:deploys).and_return([]) allow(controller).to receive(:current_user).and_return(user) end -- libgit2 0.21.2