Commit b540b5192ef8b983d82ddac4b3705a02dedd8d06

Authored by Stephen Crosby
1 parent b07aceec
Exists in master

Refs #913 remove deployment tracking feature

README.md
... ... @@ -80,10 +80,6 @@ Configuration
80 80 Errbit configuration is done entirely through environment variables. See
81 81 [configuration](docs/configuration.md)
82 82  
83   -Deploy Hooks
84   --------------
85   -Errbit can track your application deploys. See [deploy hooks](docs/deploy-hooks.md)
86   -
87 83 Deployment
88 84 ----------
89 85 See [notes on deployment](docs/deployment.md)
... ...
app/assets/javascripts/apps.show.js
... ... @@ -8,7 +8,4 @@ $(function() {
8 8 $("#repository_div").slideToggle("slow");
9 9 });
10 10  
11   - $("#deploys_toggle").click(function() {
12   - $("#deploys_div").slideToggle("slow");
13   - });
14 11 });
... ...
app/assets/stylesheets/errbit.css.erb
... ... @@ -619,7 +619,7 @@ table.apps td.name, table.errs td.message { width: 100%; }
619 619 table.apps td { padding: 16px 20px; }
620 620 table.apps th { padding: 10px 20px; }
621 621  
622   -table.apps td.issue_tracker, table.apps td.count, table.apps td.deploy {
  622 +table.apps td.issue_tracker, table.apps td.count {
623 623 text-align: center;
624 624 }
625 625 table.apps td.issue_tracker, table.apps td.count {
... ... @@ -631,9 +631,6 @@ td.message .line {
631 631 display:inline-block;
632 632 margin-left:1em;
633 633 }
634   -td.deploy {
635   - white-space: nowrap;
636   -}
637 634 td.latest {
638 635 white-space: nowrap;
639 636 }
... ... @@ -719,11 +716,6 @@ table.tally th.value {
719 716 text-transform: none;
720 717 }
721 718  
722   -/* Deploys table */
723   -table.deploys td.when {
724   - width: 102px;
725   -}
726   -
727 719 /* Resolve Errs */
728 720 #action-bar .resolve:before {
729 721 font-family: FontAwesome;
... ... @@ -854,7 +846,7 @@ table.backtrace tr.padding th, table.backtrace tr.padding td {
854 846 padding: 0;
855 847 }
856 848  
857   -h3#watchers_toggle, h3#repository_toggle, h3#deploys_toggle {
  849 +h3#watchers_toggle, h3#repository_toggle {
858 850 cursor: pointer;
859 851 }
860 852  
... ... @@ -862,7 +854,7 @@ span.click_span {
862 854 font-size: 0.7em;
863 855 }
864 856  
865   -#deploys_div, #repository_div, #watchers_div {
  857 +#repository_div, #watchers_div {
866 858 display: none;
867 859 }
868 860  
... ...
app/controllers/apps_controller.rb
... ... @@ -34,10 +34,6 @@ class AppsController < ApplicationController
34 34 end
35 35 end
36 36  
37   - expose(:deploys) do
38   - app.deploys.order_by(:created_at.desc).limit(5)
39   - end
40   -
41 37 expose(:users) do
42 38 User.all.sort_by { |u| u.name.downcase }
43 39 end
... ...
app/controllers/deploys_controller.rb
... ... @@ -1,42 +0,0 @@
1   -class DeploysController < ApplicationController
2   - protect_from_forgery except: :create
3   -
4   - skip_before_action :verify_authenticity_token, only: :create
5   - skip_before_action :authenticate_user!, only: :create
6   -
7   - def create
8   - @app = App.find_by_api_key!(params[:api_key])
9   - @deploy = @app.deploys.create!(default_deploy || heroku_deploy)
10   - render xml: @deploy
11   - end
12   -
13   - def index
14   - @app = App.find(params[:app_id])
15   - @deploys = Kaminari.paginate_array(@app.deploys.order_by(:created_at.desc)).
16   - page(params[:page]).per(10)
17   - end
18   -
19   -private
20   -
21   - def default_deploy
22   - return if params[:deploy].blank?
23   -
24   - {
25   - username: params[:deploy][:local_username],
26   - environment: params[:deploy][:rails_env],
27   - repository: params[:deploy][:scm_repository],
28   - revision: params[:deploy][:scm_revision],
29   - message: params[:deploy][:message]
30   - }
31   - end
32   -
33   - # handle Heroku's HTTP post deployhook format
34   - def heroku_deploy
35   - {
36   - username: params[:user],
37   - environment: params[:rack_env].try(:downcase) || params[:app],
38   - repository: "git@heroku.com:#{params[:app]}.git",
39   - revision: params[:head]
40   - }
41   - end
42   -end
app/controllers/problems_searcher.rb
... ... @@ -6,7 +6,7 @@ module ProblemsSearcher
6 6  
7 7 included do
8 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 count).member?(params[:sort])
10 10 params[:sort]
11 11 else
12 12 "last_notice_at"
... ...
app/helpers/application_helper.rb
... ... @@ -19,21 +19,6 @@ module ApplicationHelper
19 19 end.to_s
20 20 end
21 21  
22   - def generate_ical(deploys)
23   - RiCal.Calendar do |cal|
24   - deploys.each_with_index do |deploy, idx|
25   - cal.event do |event|
26   - event.summary = "#{idx + 1} #{deploy.repository}"
27   - event.description = deploy.revision.to_s
28   - event.dtstart = deploy.created_at.utc
29   - event.dtend = deploy.created_at.utc + 60.minutes
30   - event.location = deploy.environment.to_s
31   - event.organizer = deploy.username.to_s
32   - end
33   - end
34   - end.to_s
35   - end
36   -
37 22 def user_agent_graph(problem)
38 23 create_percentage_table_for(problem.user_agents)
39 24 end
... ...
app/helpers/apps_helper.rb
... ... @@ -31,19 +31,13 @@ module AppsHelper
31 31 @any_issue_trackers
32 32 end
33 33  
34   - def any_deploys?
35   - detect_any_apps_with_attributes if @any_deploys.nil?
36   - @any_deploys
37   - end
38   -
39 34 private def detect_any_apps_with_attributes
40   - @any_github_repos = @any_issue_trackers = @any_deploys = @any_bitbucket_repos = @any_notification_services = false
  35 + @any_github_repos = @any_issue_trackers = @any_bitbucket_repos = @any_notification_services = false
41 36  
42 37 apps.each do |app|
43 38 @any_github_repos ||= app.github_repo?
44 39 @any_bitbucket_repos ||= app.bitbucket_repo?
45 40 @any_issue_trackers ||= app.issue_tracker_configured?
46   - @any_deploys ||= app.last_deploy_at.present?
47 41 @any_notification_services ||= app.notification_service_configured?
48 42 end
49 43 end
... ...
app/mailers/mailer.rb
... ... @@ -27,19 +27,6 @@ class Mailer &lt; ActionMailer::Base
27 27 subject: "#{count}[#{@app.name}][#{@notice.environment_name}] #{@notice.message.truncate(50)}"
28 28 end
29 29  
30   - def deploy_notification(deploy)
31   - @deploy = deploy
32   - @app = AppDecorator.new deploy.app
33   -
34   - errbit_headers 'App' => @app.name,
35   - 'Environment' => @deploy.environment,
36   - 'Deploy-Revision' => @deploy.revision,
37   - 'Deploy-User' => @deploy.username
38   -
39   - mail to: @app.notification_recipients,
40   - subject: "[#{@app.name}] Deployed to #{@deploy.environment} by #{@deploy.username}"
41   - end
42   -
43 30 def comment_notification(comment)
44 31 @comment = comment
45 32 @user = comment.user
... ...
app/models/app.rb
... ... @@ -10,10 +10,8 @@ class App
10 10 field :asset_host
11 11 field :repository_branch
12 12 field :current_app_version
13   - field :resolve_errs_on_deploy, type: Boolean, default: false
14 13 field :notify_all_users, type: Boolean, default: false
15 14 field :notify_on_errs, type: Boolean, default: true
16   - field :notify_on_deploys, type: Boolean, default: false
17 15 field :email_at_notices, type: Array, default: Errbit::Config.email_at_notices
18 16  
19 17 # Some legacy apps may have string as key instead of BSON::ObjectID
... ... @@ -24,7 +22,6 @@ class App
24 22 default: -> { BSON::ObjectId.new.to_s }
25 23  
26 24 embeds_many :watchers
27   - embeds_many :deploys
28 25 embeds_one :issue_tracker, class_name: 'IssueTracker'
29 26 embeds_one :notification_service
30 27 embeds_one :notice_fingerprinter, autobuild: true
... ... @@ -86,11 +83,7 @@ class App
86 83 find_by(api_key: key)
87 84 end
88 85  
89   - def last_deploy_at
90   - (last_deploy = deploys.last) && last_deploy.created_at
91   - end
92   -
93   - # Legacy apps don't have notify_on_errs and notify_on_deploys params
  86 + # Legacy apps don't have notify_on_errs param
94 87 def notify_on_errs
95 88 !(super == false)
96 89 end
... ... @@ -100,11 +93,6 @@ class App
100 93 notify_on_errs? && notification_recipients.any?
101 94 end
102 95  
103   - def notify_on_deploys
104   - !(super == false)
105   - end
106   - alias_method :notify_on_deploys?, :notify_on_deploys
107   -
108 96 def repo_branch
109 97 repository_branch.present? ? repository_branch : 'master'
110 98 end
... ... @@ -159,7 +147,7 @@ class App
159 147 (copy_app.fields.keys - %w(_id name created_at updated_at)).each do |k|
160 148 send("#{k}=", copy_app.send(k))
161 149 end
162   - # Clone the embedded objects that can be changed via apps/edit (ignore errs & deploys, etc.)
  150 + # Clone the embedded objects that can be changed via apps/edit (ignore errs, etc.)
163 151 %w(watchers issue_tracker notification_service).each do |relation|
164 152 if (obj = copy_app.send(relation))
165 153 send("#{relation}=", obj.is_a?(Array) ? obj.map(&:clone) : obj.clone)
... ...
app/models/deploy.rb
... ... @@ -1,46 +0,0 @@
1   -class Deploy
2   - include Mongoid::Document
3   - include Mongoid::Timestamps
4   -
5   - field :username
6   - field :repository
7   - field :environment
8   - field :revision
9   - field :message
10   -
11   - index(created_at: -1)
12   -
13   - embedded_in :app, inverse_of: :deploys
14   -
15   - after_create :resolve_app_errs, if: :should_resolve_app_errs?
16   - after_create :store_cached_attributes_on_problems
17   - after_create :deliver_email
18   -
19   - validates :username, :environment, presence: true
20   -
21   - def resolve_app_errs
22   - app.problems.unresolved.in_env(environment).each(&:resolve!)
23   - end
24   -
25   - def short_revision
26   - revision.to_s[0, 7]
27   - end
28   -
29   -protected
30   -
31   - def should_resolve_app_errs?
32   - app.resolve_errs_on_deploy?
33   - end
34   -
35   - def store_cached_attributes_on_problems
36   - Problem.where(app_id: app.id).update_all(
37   - last_deploy_at: created_at
38   - )
39   - end
40   -
41   - def deliver_email
42   - if app.notify_on_deploys? && app.notification_recipients.any?
43   - Mailer.deploy_notification(self).deliver_now
44   - end
45   - end
46   -end
app/models/problem.rb
... ... @@ -14,7 +14,6 @@ class Problem
14 14  
15 15 field :last_notice_at, type: ActiveSupport::TimeWithZone, default: proc { Time.zone.now }
16 16 field :first_notice_at, type: ActiveSupport::TimeWithZone, default: proc { Time.zone.now }
17   - field :last_deploy_at, type: Time
18 17 field :resolved, type: Boolean, default: false
19 18 field :resolved_at, type: Time
20 19 field :issue_link, type: String
... ... @@ -37,7 +36,6 @@ class Problem
37 36 index message: 1
38 37 index last_notice_at: 1
39 38 index first_notice_at: 1
40   - index last_deploy_at: 1
41 39 index resolved_at: 1
42 40 index notices_count: 1
43 41  
... ... @@ -216,17 +214,13 @@ class Problem
216 214 when "app" then order_by(["app_name", order])
217 215 when "message" then order_by(["message", order])
218 216 when "last_notice_at" then order_by(["last_notice_at", order])
219   - when "last_deploy_at" then order_by(["last_deploy_at", order])
220 217 when "count" then order_by(["notices_count", order])
221 218 else fail("\"#{sort}\" is not a recognized sort")
222 219 end
223 220 end
224 221  
225 222 def cache_app_attributes
226   - if app
227   - self.app_name = app.name
228   - self.last_deploy_at = app.last_deploy_at
229   - end
  223 + self.app_name = app.name if app
230 224 end
231 225  
232 226 def truncate_message
... ...
app/views/apps/_fields.html.haml
... ... @@ -36,17 +36,10 @@
36 36 .field-helpertext Send a notification every
37 37 = f.text_field :email_at_notices, :value => app_decorate.email_at_notices
38 38 .field-helpertext times an error occurs (comma separated).
39   - %div.checkbox
40   - = f.check_box :notify_on_deploys
41   - = f.label :notify_on_deploys, 'Notify on deploys'
42 39  
43 40 %div.checkbox
44 41 = f.check_box :notify_all_users
45 42 = f.label :notify_all_users, 'Send notifications to all users'
46 43  
47   -%div.checkbox
48   - = f.check_box :resolve_errs_on_deploy
49   - = f.label :resolve_errs_on_deploy, 'Resolve errs on deploy'
50   -
51 44 = render "issue_tracker_fields", :f => f
52 45 = render "service_notification_fields", :f => f
... ...
app/views/apps/index.html.haml
... ... @@ -16,8 +16,6 @@
16 16 %th= t('.notify')
17 17 - if any_issue_trackers?
18 18 %th= t('.tracker')
19   - - if any_deploys?
20   - %th= t('.last_deploy')
21 19 %th=t('.errors')
22 20 %tbody
23 21 - apps.each do |app|
... ... @@ -45,11 +43,6 @@
45 43 = link_to( tracker_img, app.issue_tracker.url )
46 44 - else
47 45 = tracker_img
48   - - if any_deploys?
49   - %td.deploy
50   - - if app.last_deploy_at
51   - - revision = app.deploys.last.short_revision
52   - = link_to( app.last_deploy_at.to_s(:micro) << (revision.present? ? " (#{revision})" : ""), app_deploys_path(app))
53 46 %td.count
54 47 - if app.problem_count > 0
55 48 - unresolved = app.unresolved_count
... ...
app/views/apps/show.html.haml
... ... @@ -7,8 +7,6 @@
7 7 = app.current_app_version
8 8 %strong=t('.errors_caught')
9 9 = app.problems.count
10   - %strong=t('.deploy_count')
11   - = app.deploys.count
12 10 %strong=t('.api_key')
13 11 = app.api_key
14 12 - content_for :action_bar do
... ... @@ -60,34 +58,6 @@
60 58 %tr
61 59 %td= link_to(app.github_repo, app.github_url, :target => '_blank')
62 60  
63   -%h3#deploys_toggle
64   - =t('.latest_deploys')
65   - %span.click_span=t('.show_hide')
66   -#deploys_div
67   - - if deploys.any?
68   - %table.deploys
69   - %thead
70   - %tr
71   - %th=t('.when')
72   - %th=t('.environment')
73   - %th=t('.who')
74   - %th=t('.message')
75   - %th=t('.repository')
76   - %th=t('.revision')
77   -
78   - %tbody
79   - - deploys.each do |deploy|
80   - %tr
81   - %td.when #{deploy.created_at.to_s(:micro)}
82   - %td.environment #{deploy.environment}
83   - %td.who #{deploy.username}
84   - %td.message #{deploy.message}
85   - %td.repository #{deploy.repository}
86   - %td.revision #{deploy.short_revision}
87   - = link_to t('.all_deploys', :count => app.deploys.count), app_deploys_path(app), :class => 'button'
88   - - else
89   - %h3=t('.no_deploys')
90   -
91 61 - if app.problems.any?
92 62 %h3.clear=t('.errors')
93 63 %section
... ...
app/views/deploys/_table.html.haml
... ... @@ -1,21 +0,0 @@
1   -%table.errs
2   - %thead
3   - %tr
4   - %th App
5   - %th When
6   - %th Who
7   - %th Message
8   - %th Repository
9   - %th Revision
10   - %tbody
11   - - deploys.each do |deploy|
12   - %tr
13   - %td.app
14   - = deploy.app.name
15   - %span.environment= deploy.environment
16   - %td.latest= deploy.created_at.to_s(:micro)
17   - %td.who= deploy.username
18   - %td.message= deploy.message
19   - %td.repository= deploy.repository
20   - %td.revision= deploy.short_revision
21   -
app/views/deploys/index.html.haml
... ... @@ -1,10 +0,0 @@
1   -- content_for :title, 'Deploys'
2   -- content_for :action_bar do
3   - - if current_user.authentication_token
4   - %span
5   - = link_to app_deploys_path(@app, :format => "ics", :auth_token => current_user.authentication_token) do
6   - %i.fa.fa-calendar
7   - iCal
8   -= render 'table', :deploys => @deploys
9   -= paginate @deploys
10   -
app/views/deploys/index.ics.haml
... ... @@ -1 +0,0 @@
1   -= generate_ical(@app.deploys.order_by(:created_at.asc))
app/views/mailer/deploy_notification.html.haml
... ... @@ -1,30 +0,0 @@
1   -%tr
2   - %td.section
3   - %table(cellpadding="0" cellspacing="0" border="0" align="left")
4   - %tbody
5   - %tr
6   - %td.content(valign="top")
7   - %div
8   - %p
9   - = link_to(@app.name, app_url(@app), :class => "bold")
10   - was just deployed to
11   - %span.bold= @deploy.environment
12   - by
13   - %span.bold= @deploy.username + "."
14   -
15   -%tr
16   - %td.section
17   - %table(cellpadding="0" cellspacing="0" border="0" align="left")
18   - %tbody
19   - %tr
20   - %td.content(valign="top")
21   - %div
22   - %p.heading REVISION:
23   - %p= @deploy.revision
24   - %p.heading MESSAGE:
25   - %p= @deploy.message.blank? ? 'n/a' : @deploy.message
26   - %p.heading WHEN:
27   - %p= @deploy.created_at.to_s(:rfc822)
28   - %p.heading REPOSITORY:
29   - %p= @deploy.repository.blank? ? 'n/a' : link_to(nil, @deploy.repository)
30   -
app/views/mailer/deploy_notification.text.erb
... ... @@ -1,22 +0,0 @@
1   -<%= @app.name %> was just deployed to <%= @deploy.environment %> by <%= @deploy.username %>.
2   -
3   -
4   -REVISION:
5   -
6   -<%= @deploy.revision %>
7   -
8   -
9   -MESSAGE:
10   -
11   -<%= @deploy.message.blank? ? 'n/a' : @deploy.message %>
12   -
13   -
14   -WHEN:
15   -
16   -<%= @deploy.created_at.to_s(:rfc822) %>
17   -
18   -
19   -REPOSITORY:
20   -
21   -<%= @deploy.repository.blank? ? 'n/a' : @deploy.repository %>
22   -
app/views/problems/_table.html.haml
... ... @@ -7,7 +7,6 @@
7 7 %th= link_for_sort "App"
8 8 %th= link_for_sort "What &amp; Where".html_safe, "message"
9 9 %th= link_for_sort "Latest", "last_notice_at"
10   - %th= link_for_sort "Deploy", "last_deploy_at"
11 10 %th= link_for_sort "Count"
12 11 - if any_issue_links
13 12 %th Issue
... ... @@ -34,7 +33,6 @@
34 33 %em.commenter= (Errbit::Config.user_has_username ? comment.user.username : comment.user.email).to_s << ":"
35 34 %em= truncate(comment.body, :length => 100, :separator => ' ')
36 35 %td.latest #{time_ago_in_words(problem.last_notice_at)} ago
37   - %td.deploy= problem.last_deploy_at ? problem.last_deploy_at.to_s(:micro) : 'n/a'
38 36 %td.count= link_to problem.notices_count, app_problem_path(problem.app, problem)
39 37 - if any_issue_links
40 38 %td.issue_link
... ...
config/initializers/ssl_enforcer.rb
... ... @@ -3,6 +3,6 @@ if Errbit::Config.enforce_ssl
3 3 require 'rack/ssl-enforcer'
4 4 ActionMailer::Base.default_url_options.merge!(protocol: 'https://')
5 5 Rails.application.configure do
6   - config.middleware.use Rack::SslEnforcer, except: %r{^/deploys}
  6 + config.middleware.use Rack::SslEnforcer
7 7 end
8 8 end
... ...
config/locales/en.yml
... ... @@ -92,7 +92,6 @@ en:
92 92 index:
93 93 notify: Notification Service
94 94 tracker: Tracker
95   - last_deploy: Last Deploy
96 95 errors: Errors
97 96 name: Name
98 97 repository: Repository
... ... @@ -103,21 +102,17 @@ en:
103 102 fields:
104 103 regenerate_api_key: "Regenerate API key"
105 104 show:
106   - all_deploys: "All Deploys (%{count})"
107 105 all_errs: all errors
108 106 all_users_notified: "All users will be notified when something happens."
109 107 api_key: "API Key:"
110 108 are_you_sure: 'Are you sure?'
111 109 atom_title: "Errbit notices for %{name} at %{host}"
112   - deploy_count: "Deploy Count:"
113 110 edit: edit
114 111 environment: Environment
115 112 errors: Errors
116 113 errors_caught: "Errors Caught:"
117 114 github_repo: GitHub Repo
118   - latest_deploys: Latest Deploys
119 115 message: Message
120   - no_deploys: No deploys
121 116 no_error_yet: "No errors have been caught yet, make sure you setup your app"
122 117 no_watcher: "Sadly, no one is watching this app"
123 118 repository: Repository
... ...
config/routes.rb
... ... @@ -4,10 +4,8 @@ Rails.application.routes.draw do
4 4 # Hoptoad Notifier Routes
5 5 match '/notifier_api/v2/notices' => 'notices#create', via: [:get, :post]
6 6 get '/locate/:id' => 'notices#locate', :as => :locate
7   - post '/deploys.txt' => 'deploys#create'
8 7  
9 8 resources :notices, only: [:show]
10   - resources :deploys, only: [:show]
11 9 resources :users do
12 10 member do
13 11 delete :unlink_github
... ... @@ -47,7 +45,6 @@ Rails.application.routes.draw do
47 45 delete :unlink_issue
48 46 end
49 47 end
50   - resources :deploys, only: [:index]
51 48 resources :watchers, only: [:destroy, :update]
52 49 member do
53 50 post :regenerate_api_key
... ...
docs/deploy-hooks.md
... ... @@ -1,47 +0,0 @@
1   -# Deploy Hooks
2   -Errbit can track your application deploys if you send a special message to
3   -Errbit whenever you deploy.
4   -
5   -## From heroku
6   -If you're using heroku, you can add a deploy hook like this:
7   -~~~bash
8   -$ heroku addons:add deployhooks:http \
9   - --url=http://myerrbit.com/deploys.txt
10   -~~~
11   -
12   -## From the airbrake gem using the rake task
13   -The airbrake gem comes with a nice rake task for sending deploy hooks. Assuming
14   -you already have it configured, you can send hooks like this:
15   -~~~bash
16   -$ TO=env-name \
17   - REVISION=rev-string \
18   - REPO=repo-string \
19   - USER=user-string \
20   - rake airbrake:deploy
21   -~~~
22   -
23   -## From the airbrake gem using capistrano 3
24   -In your application's Capfile, insert:
25   -~~~ruby
26   -require 'airbrake/capistrano3'
27   -~~~
28   -
29   -This will add a new capistrano task named ```airbrake:deploy``` which ends up
30   -calling ```rake airbrake:deploy``` with the values from your capistrano config.
31   -You may need to set the ```API_KEY``` environment variable on the target
32   -application.
33   -
34   -## From curl
35   -Errbit supports sending a message along with your deploy hook. The airbrake gem
36   -doesn't support this, but you can easily send it along yourself. Here's an
37   -example using cURL:
38   -~~~bash
39   -$ curl https://myerrbit.com/deploys.txt \
40   - --data "api_key=406e4374bf508ad0d7732c2d35ed380d" \
41   - --data "app_id=cb71ca8429732ba86b90d57c" \
42   - --data "deploy[local_username]=user-string" \
43   - --data "deploy[rails_env]=env-name" \
44   - --data "deploy[scm_repository]=repo-string" \
45   - --data "deploy[scm_revision]=rev-string" \
46   - --data "deploy[message]=my-message"
47   -~~~
docs/deployment/heroku.md
... ... @@ -75,8 +75,3 @@ Option 3. Clear resolved errors manually:
75 75 ```bash
76 76 heroku run rake errbit:db:clear_resolved
77 77 ```
78   -
79   -### Add the deployment hook
80   -```bash
81   -heroku addons:create deployhooks:http --url="http://YOUR_ERRBIT_HOST/deploys.txt?api_key=YOUR_API_KEY"
82   -```
... ...
spec/controllers/deploys_controller_spec.rb
... ... @@ -1,57 +0,0 @@
1   -describe DeploysController, type: 'controller' do
2   - render_views
3   -
4   - context 'POST #create' do
5   - before do
6   - @params = {
7   - 'local_username' => 'john.doe',
8   - 'scm_repository' => 'git@github.com/errbit/errbit.git',
9   - 'rails_env' => 'production',
10   - 'scm_revision' => '19d77837eef37902cf5df7e4445c85f392a8d0d5',
11   - 'message' => 'johns first deploy'
12   - }
13   - @app = Fabricate(:app_with_watcher, notify_on_deploys: true, api_key: 'APIKEY')
14   - end
15   -
16   - it 'finds the app via the api key' do
17   - expect(App).to receive(:find_by_api_key!).with('APIKEY').and_return(@app)
18   - post :create, deploy: @params, api_key: 'APIKEY'
19   - end
20   -
21   - it 'creates a deploy' do
22   - expect(App).to receive(:find_by_api_key!).and_return(@app)
23   - expect(@app.deploys).to receive(:create!).
24   - with(
25   - username: 'john.doe',
26   - environment: 'production',
27   - repository: 'git@github.com/errbit/errbit.git',
28   - revision: '19d77837eef37902cf5df7e4445c85f392a8d0d5',
29   - message: 'johns first deploy').and_return(Fabricate(:deploy))
30   - post :create, deploy: @params, api_key: 'APIKEY'
31   - end
32   -
33   - it 'sends an email notification when configured to do so' do
34   - post :create, deploy: @params, api_key: 'APIKEY'
35   - email = ActionMailer::Base.deliveries.last
36   - expect(email.to).to include(@app.watchers.first.email)
37   - expect(email.subject).to eq "[#{@app.name}] Deployed to production by john.doe"
38   - end
39   - end
40   -
41   - context "GET #index" do
42   - before(:each) do
43   - @deploy = Fabricate :deploy
44   - sign_in Fabricate(:admin)
45   - get :index, app_id: @deploy.app.id
46   - end
47   -
48   - it "should render successfully" do
49   - expect(response).to be_success
50   - end
51   -
52   - it "should contain info about existing deploy" do
53   - expect(response.body).to match(@deploy.short_revision)
54   - expect(response.body).to match(@deploy.app.name)
55   - end
56   - end
57   -end
spec/fabricators/app_fabricator.rb
... ... @@ -19,11 +19,3 @@ Fabricator(:user_watcher, from: :watcher) do
19 19 user
20 20 watcher_type 'user'
21 21 end
22   -
23   -Fabricator(:deploy) do
24   - app
25   - username 'clyde.frog'
26   - repository 'git@github.com/errbit/errbit.git'
27   - environment 'production'
28   - revision { SecureRandom.hex(10) }
29   -end
... ...
spec/models/app_spec.rb
... ... @@ -3,7 +3,7 @@ describe App, type: &#39;model&#39; do
3 3 it { is_expected.to have_field(:_id).of_type(String) }
4 4 it { is_expected.to have_field(:name).of_type(String) }
5 5 it { is_expected.to have_fields(:api_key, :github_repo, :bitbucket_repo, :asset_host, :repository_branch) }
6   - it { is_expected.to have_fields(:resolve_errs_on_deploy, :notify_all_users, :notify_on_errs, :notify_on_deploys).of_type(Mongoid::Boolean) }
  6 + it { is_expected.to have_fields(:notify_all_users, :notify_on_errs).of_type(Mongoid::Boolean) }
7 7 it { is_expected.to have_field(:email_at_notices).of_type(Array).with_default_value_of(Errbit::Config.email_at_notices) }
8 8 end
9 9  
... ...
spec/models/deploy_observer_spec.rb
... ... @@ -1,18 +0,0 @@
1   -describe "Callback on Deploy", type: 'model' do
2   - context 'when a Deploy is saved' do
3   - context 'and the app should notify on deploys' do
4   - it 'should send an email notification' do
5   - expect(Mailer).to receive(:deploy_notification).
6   - and_return(double('email', deliver_now: true))
7   - Fabricate(:deploy, app: Fabricate(:app_with_watcher, notify_on_deploys: true))
8   - end
9   - end
10   -
11   - context 'and the app is not set to notify on deploys' do
12   - it 'should not send an email notification' do
13   - expect(Mailer).to_not receive(:deploy_notification)
14   - Fabricate(:deploy, app: Fabricate(:app_with_watcher, notify_on_deploys: false))
15   - end
16   - end
17   - end
18   -end
spec/models/deploy_spec.rb
... ... @@ -1,41 +0,0 @@
1   -describe Deploy, type: 'model' do
2   - context 'validations' do
3   - it 'requires a username' do
4   - deploy = Fabricate.build(:deploy, username: nil)
5   - expect(deploy).to_not be_valid
6   - expect(deploy.errors[:username]).to include("can't be blank")
7   - end
8   -
9   - it 'requires an environment' do
10   - deploy = Fabricate.build(:deploy, environment: nil)
11   - expect(deploy).to_not be_valid
12   - expect(deploy.errors[:environment]).to include("can't be blank")
13   - end
14   - end
15   -
16   - context 'being created' do
17   - context 'when the app has resolve_errs_on_deploy set to false' do
18   - it 'should not resolve the apps errs' do
19   - app = Fabricate(:app, resolve_errs_on_deploy: false)
20   - @problems = 3.times.map { Fabricate(:err, problem: Fabricate(:problem, resolved: false, app: app)) }
21   - Fabricate(:deploy, app: app)
22   - expect(app.reload.problems.none?(&:resolved?)).to eq true
23   - end
24   - end
25   -
26   - context 'when the app has resolve_errs_on_deploy set to true' do
27   - it 'should resolve the apps errs that were in the same environment' do
28   - app = Fabricate(:app, resolve_errs_on_deploy: true)
29   - @prod_errs = 3.times.map { Fabricate(:problem, resolved: false, app: app, environment: 'production') }
30   - @staging_errs = 3.times.map { Fabricate(:problem, resolved: false, app: app, environment: 'staging') }
31   - Fabricate(:deploy, app: app, environment: 'production')
32   - expect(@prod_errs.all? { |problem| problem.reload.resolved? }).to eq true
33   - expect(@staging_errs.all? { |problem| problem.reload.resolved? }).to eq false
34   - end
35   - end
36   - end
37   -
38   - it "should produce a shortened revision with 7 characters" do
39   - expect(Deploy.new(revision: "1234567890abcdef").short_revision).to eq "1234567"
40   - end
41   -end
spec/models/problem_spec.rb
... ... @@ -233,30 +233,6 @@ describe Problem, type: &#39;model&#39; do
233 233 end
234 234 end
235 235  
236   - context "#last_deploy_at" do
237   - before do
238   - @app = Fabricate(:app)
239   - @last_deploy = 10.days.ago
240   - Fabricate(:deploy, app: @app, created_at: @last_deploy, environment: "production")
241   - end
242   -
243   - it "is set when a problem is created" do
244   - problem = Fabricate(:problem, app: @app, environment: "production")
245   - assert_equal @last_deploy, problem.last_deploy_at
246   - end
247   -
248   - it "is updated when a deploy is created" do
249   - problem = Fabricate(:problem, app: @app, environment: "production")
250   - next_deploy = 5.minutes.ago
251   - expect do
252   - @deploy = Fabricate(:deploy, app: @app, created_at: next_deploy)
253   - problem.reload
254   - end.to change { problem.last_deploy_at.iso8601 }.
255   - from(@last_deploy.iso8601).
256   - to(next_deploy.iso8601)
257   - end
258   - end
259   -
260 236 context "notice messages cache" do
261 237 before do
262 238 @app = Fabricate(:app)
... ...
spec/views/apps/index.html.haml_spec.rb
... ... @@ -1,14 +0,0 @@
1   -describe "apps/index.html.haml", type: 'view' do
2   - before do
3   - app = stub_model(App, deploys: [stub_model(Deploy, created_at: Time.zone.now, revision: "123456789abcdef")])
4   - allow(view).to receive(:apps).and_return([app])
5   - allow(controller).to receive(:current_user).and_return(stub_model(User))
6   - end
7   -
8   - describe "deploy column" do
9   - it "should show the first 7 characters of the revision in parentheses" do
10   - render
11   - expect(rendered).to match(/\(1234567\)/)
12   - end
13   - end
14   -end
spec/views/apps/show.html.haml_spec.rb
... ... @@ -9,7 +9,6 @@ describe &quot;apps/show.html.haml&quot;, type: &#39;view&#39; do
9 9 before do
10 10 allow(view).to receive(:app).and_return(app)
11 11 allow(view).to receive(:all_errs).and_return(false)
12   - allow(view).to receive(:deploys).and_return([])
13 12 allow(controller).to receive(:current_user).and_return(user)
14 13 end
15 14  
... ...