Browse Source

Fixed failing tests and added deployment complete email

development
Godwin 8 years ago
parent
commit
e5ecf221f6
  1. 8
      Rakefile
  2. 71
      app/controllers/application_controller.rb
  3. 5
      app/mailers/user_mailer.rb
  4. 4
      app/views/user_mailer/contact_details.html.haml
  5. 1
      app/views/user_mailer/server_startup.html.haml
  6. 2
      app/views/workshops/_workshop_previews.html.haml
  7. 12
      features/registration.feature

8
Rakefile

@ -89,6 +89,14 @@ task "cucumber:debug" do
ENV['TEST_DEBUG'] = nil ENV['TEST_DEBUG'] = nil
end end
task deploy: :environment do
if Rails.env.preview? || Rails.env.production?
UserMailer.delay(queue: Rails.env.to_s).server_startup(Rails.env.to_s)
else
UserMailer.server_startup(Rails.env.to_s).deliver_now
end
end
namespace :cucumber do namespace :cucumber do
FAILING_CUCUMBER_SCENARIOS_FILENAME = 'log/rerun.txt' FAILING_CUCUMBER_SCENARIOS_FILENAME = 'log/rerun.txt'

71
app/controllers/application_controller.rb

@ -14,22 +14,22 @@ class ApplicationController < BaseController
def capture_page_info def capture_page_info
# capture request info in case an error occurs # capture request info in case an error occurs
if request.method == "GET" && (params[:controller] != 'application' || params[:action] != 'contact') # if request.method == "GET" && (params[:controller] != 'application' || params[:action] != 'contact')
session[:last_request] # session[:last_request]
request_info = { # request_info = {
'params' => params, # 'params' => params,
'request' => { # 'request' => {
'remote_ip' => request.remote_ip, # 'remote_ip' => request.remote_ip,
'uuid' => request.uuid, # 'uuid' => request.uuid,
'original_url' => request.original_url, # 'original_url' => request.original_url,
'env' => Hash.new # 'env' => Hash.new
} # }
} # }
request.env.each do |key, value| # request.env.each do |key, value|
request_info['request']['env'][key.to_s] = value.to_s # request_info['request']['env'][key.to_s] = value.to_s
end # end
session['request_info'] = request_info # # session['request_info'] = request_info
end # end
# get the current conferences and set them globally # get the current conferences and set them globally
status_hierarchy = { status_hierarchy = {
@ -96,14 +96,14 @@ class ApplicationController < BaseController
logger.info "A JavaScript error has occurred on #{params[:location]}:#{params[:lineNumber]}: #{params[:message]}" logger.info "A JavaScript error has occurred on #{params[:location]}:#{params[:lineNumber]}: #{params[:message]}"
if Rails.env.preview? || Rails.env.production? if Rails.env.preview? || Rails.env.production?
requestHash = { request_info = {
'remote_ip' => arg.remote_ip, 'remote_ip' => arg.remote_ip,
'uuid' => arg.uuid, 'uuid' => arg.uuid,
'original_url' => arg.original_url, 'original_url' => arg.original_url,
'env' => Hash.new 'env' => Hash.new
} }
request.env.each do | key, value | request.env.each do |key, value|
requestHash['env'][key.to_s] = value.to_s request_info['env'][key.to_s] = value.to_s
end end
send_mail(:error_report, send_mail(:error_report,
@ -111,7 +111,7 @@ class ApplicationController < BaseController
report, report,
params[:message], params[:message],
nil, nil,
requestHash, request_info,
params, params,
current_user, current_user,
Time.now.strftime("%d/%m/%Y %H:%M") Time.now.strftime("%d/%m/%Y %H:%M")
@ -172,21 +172,21 @@ class ApplicationController < BaseController
# send and email if this is production # send and email if this is production
if Rails.env.preview? || Rails.env.production? if Rails.env.preview? || Rails.env.production?
suppress(Exception) do suppress(Exception) do
requestHash = { request_info = {
'remote_ip' => arg.remote_ip, 'remote_ip' => arg.remote_ip,
'uuid' => arg.uuid, 'uuid' => arg.uuid,
'original_url' => arg.original_url, 'original_url' => arg.original_url,
'env' => Hash.new 'env' => Hash.new
} }
request.env.each do | key, value | request.env.each do |key, value|
requestHash['env'][key.to_s] = value.to_s request_info['env'][key.to_s] = value.to_s
end end
send_mail(:error_report, send_mail(:error_report,
"An error has occurred in #{Rails.env}", "An error has occurred in #{Rails.env}",
nil, nil,
exception.to_s, exception.to_s,
exception.backtrace.join("\n"), exception.backtrace.join("\n"),
requestHash, request_info,
params, params,
current_user, current_user,
Time.now.strftime("%d/%m/%Y %H:%M") Time.now.strftime("%d/%m/%Y %H:%M")
@ -222,6 +222,16 @@ class ApplicationController < BaseController
end end
end end
request_info = {
'remote_ip' => request.remote_ip,
'uuid' => request.uuid,
'original_url' => request.original_url,
'env' => Hash.new
}
request.env.each do |key, value|
request_info['env'][key.to_s] = value.to_s
end
send_mail(:contact, send_mail(:contact,
current_user || params[:email], current_user || params[:email],
params[:subject], params[:subject],
@ -229,13 +239,12 @@ class ApplicationController < BaseController
email_list email_list
) )
request_info = session['request_info'] || { 'request' => request, 'params' => params }
send_mail(:contact_details, send_mail(:contact_details,
current_user || params[:email], current_user || params[:email],
params[:subject], params[:subject],
params[:message], params[:message],
request_info['request'], request_info,
request_info['params'] params
) )
redirect_to contact_sent_path redirect_to contact_sent_path
@ -339,21 +348,21 @@ class ApplicationController < BaseController
# send an email if this is production # send an email if this is production
if Rails.env.preview? || Rails.env.production? if Rails.env.preview? || Rails.env.production?
begin begin
requestHash = { request_info = {
'remote_ip' => arg.remote_ip, 'remote_ip' => arg.remote_ip,
'uuid' => arg.uuid, 'uuid' => arg.uuid,
'original_url' => arg.original_url, 'original_url' => arg.original_url,
'env' => Hash.new 'env' => Hash.new
} }
request.env.each do | key, value | request.env.each do |key, value|
requestHash['env'][key.to_s] = value.to_s request_info['env'][key.to_s] = value.to_s
end end
send_mail(:error_report, send_mail(:error_report,
"A missing translation found in #{Rails.env}", "A missing translation found in #{Rails.env}",
"<p>A translation for <code>#{key}</code> in <code>#{locale.to_s}</code> was found. The text that was rendered to the user was:</p><blockquote>#{str || 'nil'}</blockquote>", "<p>A translation for <code>#{key}</code> in <code>#{locale.to_s}</code> was found. The text that was rendered to the user was:</p><blockquote>#{str || 'nil'}</blockquote>",
exception.to_s, exception.to_s,
nil, nil,
requestHash, request_info,
params, params,
current_user.id, current_user.id,
Time.now.strftime("%d/%m/%Y %H:%M") Time.now.strftime("%d/%m/%Y %H:%M")

5
app/mailers/user_mailer.rb

@ -148,6 +148,11 @@ class UserMailer < ActionMailer::Base
mail to: 'goodgodwin@hotmail.com', subject: clean_subject("Details for: \"#{subject}\"") mail to: 'goodgodwin@hotmail.com', subject: clean_subject("Details for: \"#{subject}\"")
end end
def server_startup(environment)
@environment = environment
mail to: 'goodgodwin@hotmail.com', subject: clean_subject("Deployment to #{environment} complete")
end
private private
def set_host(*args) def set_host(*args)
if Rails.env.production? if Rails.env.production?

4
app/views/user_mailer/contact_details.html.haml

@ -30,7 +30,7 @@
%tr %tr
%th=_!'Key' %th=_!'Key'
%th=_!'Value' %th=_!'Value'
- @params.each do | key, value | - @params.each do |key, value|
%tr %tr
%td=_!key %td=_!key
%td=_!value %td=_!value
@ -40,7 +40,7 @@
%tr %tr
%th=_!'Key' %th=_!'Key'
%th=_!'Value' %th=_!'Value'
- @request['env'].each do | key, value | - @request['env'].each do |key, value|
%tr %tr
%td=_!key %td=_!key
%td=_!value %td=_!value

1
app/views/user_mailer/server_startup.html.haml

@ -0,0 +1 @@
%p="Deployment to #{@environment} is now complete"

2
app/views/workshops/_workshop_previews.html.haml

@ -3,7 +3,7 @@
- workshops.sort_by{ |w| w.title.downcase }.each do |w| - workshops.sort_by{ |w| w.title.downcase }.each do |w|
- is_interested = w.interested?(current_user) - is_interested = w.interested?(current_user)
%li{class: [is_interested ? :interested : nil]} %li{class: [is_interested ? :interested : nil]}
= content_tag("h#{depth}", w.title, class: :title) = content_tag("h#{depth}", _!(w.title), class: :title)
.workshop-interest .workshop-interest
- if w.can_show_interest?(current_user) - if w.can_show_interest?(current_user)
= form_tag toggle_workshop_interest_path(w.conference.slug, w.id), class: 'js-xhr' do = form_tag toggle_workshop_interest_path(w.conference.slug, w.id), class: 'js-xhr' do

12
features/registration.feature

@ -13,7 +13,7 @@ Feature: Registration
When I enter my email address When I enter my email address
And press confirm email And press confirm email
Then I should see 'Confirmation Sent' Then I should see 'Check your spam box'
And I should get a 'confirmation' email And I should get a 'confirmation' email
When I click on the 'Confirm' link in the email When I click on the 'Confirm' link in the email
@ -134,7 +134,7 @@ Feature: Registration
When I enter my email address When I enter my email address
And press confirm email And press confirm email
Then I should see 'Confirmation Sent' Then I should see 'Check your spam box'
And I should get a 'confirmation' email And I should get a 'confirmation' email
When I click on the 'Confirm' link in the email When I click on the 'Confirm' link in the email
@ -215,7 +215,7 @@ Feature: Registration
When I enter my email address When I enter my email address
And press confirm email And press confirm email
Then I should see 'Confirmation Sent' Then I should see 'Check your spam box'
And I should get a 'confirmation' email And I should get a 'confirmation' email
When I click on the 'Confirm' link in the email When I click on the 'Confirm' link in the email
@ -281,7 +281,7 @@ Feature: Registration
When I enter my email address When I enter my email address
And press confirm email And press confirm email
Then I should see 'Confirmation Sent' Then I should see 'Check your spam box'
And I should get a 'confirmation' email And I should get a 'confirmation' email
When I click on the 'Confirm' link in the email When I click on the 'Confirm' link in the email
@ -379,7 +379,7 @@ Feature: Registration
When I enter my email address as 'me@bikebike.org' When I enter my email address as 'me@bikebike.org'
And press confirm email And press confirm email
Then I should see 'Confirmation Sent' Then I should see 'Check your spam box'
And I should get a 'confirmation' email And I should get a 'confirmation' email
When I click on the 'Confirm' link in the email When I click on the 'Confirm' link in the email
@ -543,7 +543,7 @@ Scenario: Housing providers can enter incorrect data and fix it
When I enter my email address When I enter my email address
And press confirm email And press confirm email
Then I should see 'Confirmation Sent' Then I should see 'Check your spam box'
And I should get a 'confirmation' email And I should get a 'confirmation' email
When I click on the 'Confirm' link in the email When I click on the 'Confirm' link in the email

Loading…
Cancel
Save