Browse Source

Fixed failing tests and added deployment complete email

development
Godwin 7 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
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
FAILING_CUCUMBER_SCENARIOS_FILENAME = 'log/rerun.txt'

71
app/controllers/application_controller.rb

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

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

@ -30,7 +30,7 @@
%tr
%th=_!'Key'
%th=_!'Value'
- @params.each do | key, value |
- @params.each do |key, value|
%tr
%td=_!key
%td=_!value
@ -40,7 +40,7 @@
%tr
%th=_!'Key'
%th=_!'Value'
- @request['env'].each do | key, value |
- @request['env'].each do |key, value|
%tr
%td=_!key
%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|
- is_interested = w.interested?(current_user)
%li{class: [is_interested ? :interested : nil]}
= content_tag("h#{depth}", w.title, class: :title)
= content_tag("h#{depth}", _!(w.title), class: :title)
.workshop-interest
- if w.can_show_interest?(current_user)
= 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
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
When I click on the 'Confirm' link in the email
@ -134,7 +134,7 @@ Feature: Registration
When I enter my email address
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
When I click on the 'Confirm' link in the email
@ -215,7 +215,7 @@ Feature: Registration
When I enter my email address
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
When I click on the 'Confirm' link in the email
@ -281,7 +281,7 @@ Feature: Registration
When I enter my email address
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
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'
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
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
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
When I click on the 'Confirm' link in the email

Loading…
Cancel
Save