diff --git a/Rakefile b/Rakefile index a497b25..b85cfb9 100644 --- a/Rakefile +++ b/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' diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index 80918fe..6ea4050 100644 --- a/app/controllers/application_controller.rb +++ b/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}", "

A translation for #{key} in #{locale.to_s} was found. The text that was rendered to the user was:

#{str || 'nil'}
", exception.to_s, nil, - requestHash, + request_info, params, current_user.id, Time.now.strftime("%d/%m/%Y %H:%M") diff --git a/app/mailers/user_mailer.rb b/app/mailers/user_mailer.rb index a719094..c439702 100644 --- a/app/mailers/user_mailer.rb +++ b/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? diff --git a/app/views/user_mailer/contact_details.html.haml b/app/views/user_mailer/contact_details.html.haml index dedef6e..3c5b16b 100644 --- a/app/views/user_mailer/contact_details.html.haml +++ b/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 \ No newline at end of file diff --git a/app/views/user_mailer/server_startup.html.haml b/app/views/user_mailer/server_startup.html.haml new file mode 100644 index 0000000..6e6df4e --- /dev/null +++ b/app/views/user_mailer/server_startup.html.haml @@ -0,0 +1 @@ +%p="Deployment to #{@environment} is now complete" diff --git a/app/views/workshops/_workshop_previews.html.haml b/app/views/workshops/_workshop_previews.html.haml index fc793dc..48933cb 100644 --- a/app/views/workshops/_workshop_previews.html.haml +++ b/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 diff --git a/features/registration.feature b/features/registration.feature index c10fcd4..3d37b12 100644 --- a/features/registration.feature +++ b/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