From e8013d83451fa1b455aefd7ce620801ddaff8570 Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Fri, 5 Mar 2021 03:35:29 -0800 Subject: [PATCH 01/51] stylesheet, layout and rendering for email_template (test) --- app/assets/stylesheets/mailbot.css | 40 ++++++++++ app/views/layouts/_mailbot_footer.html.haml | 9 +++ app/views/layouts/_mailbot_header.html.haml | 19 +++++ app/views/mailbot/email_template.erb | 81 +-------------------- 4 files changed, 72 insertions(+), 77 deletions(-) create mode 100644 app/assets/stylesheets/mailbot.css create mode 100644 app/views/layouts/_mailbot_footer.html.haml create mode 100644 app/views/layouts/_mailbot_header.html.haml diff --git a/app/assets/stylesheets/mailbot.css b/app/assets/stylesheets/mailbot.css new file mode 100644 index 00000000..870eb7ef --- /dev/null +++ b/app/assets/stylesheets/mailbot.css @@ -0,0 +1,40 @@ +html { + scroll-behavior: smooth; + } + + body { + background: #fff; + box-shadow: 0 0 2px rgba(0, 0, 0, 0.06); + color: #000; + font-family: 'Montserrat', sans-serif; + font-size: 16px; + line-height: 1.5; + margin: 0 auto; + } + + h1, + h3, + h4, + h5, + h6 { + font-weight: 400; + line-height: 1.3; + } + p { + color: #0B3559; + font-weight: 400; + line-height: 2; + } + + #border { + background-color: #0B3559; + padding: 25px; + color:#fff; + } + + #content { + background-color: #fff; + padding: 100px; + color: #0B3559; + } + \ No newline at end of file diff --git a/app/views/layouts/_mailbot_footer.html.haml b/app/views/layouts/_mailbot_footer.html.haml new file mode 100644 index 00000000..f086135d --- /dev/null +++ b/app/views/layouts/_mailbot_footer.html.haml @@ -0,0 +1,9 @@ +%html{lang: 'en'} + %head + %meta{charset: 'utf-8'} + %meta{name: 'viewport', content: 'width=device-width, initial-scale=1'} + %meta{content: 'Snap!Con -- A conference all about Snap!, a programing language from UC Berkeley.', name: 'description'} + %meta{content: 'Michael Ball, Brian Harvey, Jens Moenig, Bernat Romagosa, Dan Garcia, Lauren Mock', name: 'author'} + = stylesheet_link_tag "mailbot" + %body + #border \ No newline at end of file diff --git a/app/views/layouts/_mailbot_header.html.haml b/app/views/layouts/_mailbot_header.html.haml new file mode 100644 index 00000000..1492a469 --- /dev/null +++ b/app/views/layouts/_mailbot_header.html.haml @@ -0,0 +1,19 @@ +%html{lang: 'en'} + %head + %meta{charset: 'utf-8'} + %meta{name: 'viewport', content: 'width=device-width, initial-scale=1'} + %title= 'Email' + %meta{content: 'Snap!Con -- A conference all about Snap!, a programing language from UC Berkeley.', name: 'description'} + %meta{content: 'Michael Ball, Brian Harvey, Jens Moenig, Bernat Romagosa, Dan Garcia, Lauren Mock', name: 'author'} + = stylesheet_link_tag "mailbot" + %body + #border + .row + .col-md-2 + - if !@logo.nil? + = image_tag(@logo, style: "display:block") + .col-md-10 + %h1 + #content + %span{:style => "white-space: pre-line"} + \ No newline at end of file diff --git a/app/views/mailbot/email_template.erb b/app/views/mailbot/email_template.erb index 429553be..9834d3fc 100644 --- a/app/views/mailbot/email_template.erb +++ b/app/views/mailbot/email_template.erb @@ -1,77 +1,4 @@ - - - - - - - - - - - - - - Email - - -
-
- -
- <% if !@logo.nil? %> - <%= image_tag(@logo, style: "display:block") %> - <% end %> -
-

-
-
-
- - <%= @email_body %> - -
-
-

-
- - += render "layouts/_mailbot_header" + = @email_body += render "layouts/_mailbot_footer" + \ No newline at end of file From 9dc3ac6bca2250b8f8954a2ef1f896c4ef5454c7 Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Fri, 5 Mar 2021 03:41:41 -0800 Subject: [PATCH 02/51] change file type --- .../mailbot/{email_template.erb => email_template.html.haml} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename app/views/mailbot/{email_template.erb => email_template.html.haml} (100%) diff --git a/app/views/mailbot/email_template.erb b/app/views/mailbot/email_template.html.haml similarity index 100% rename from app/views/mailbot/email_template.erb rename to app/views/mailbot/email_template.html.haml From 7bccf277909ad9bbd3d7f9cd89c5ffdde7e109fa Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Fri, 5 Mar 2021 09:02:02 -0800 Subject: [PATCH 03/51] change to erb --- app/views/mailbot/email_template.html.erb | 5 +++++ app/views/mailbot/email_template.html.haml | 4 ---- 2 files changed, 5 insertions(+), 4 deletions(-) create mode 100644 app/views/mailbot/email_template.html.erb delete mode 100644 app/views/mailbot/email_template.html.haml diff --git a/app/views/mailbot/email_template.html.erb b/app/views/mailbot/email_template.html.erb new file mode 100644 index 00000000..41e0b0e6 --- /dev/null +++ b/app/views/mailbot/email_template.html.erb @@ -0,0 +1,5 @@ +<%= render "layouts/_mailbot_header" %> + <%= @email_body %> +<% end %> +<%= render "layouts/_mailbot_footer" %> + \ No newline at end of file diff --git a/app/views/mailbot/email_template.html.haml b/app/views/mailbot/email_template.html.haml deleted file mode 100644 index 9834d3fc..00000000 --- a/app/views/mailbot/email_template.html.haml +++ /dev/null @@ -1,4 +0,0 @@ -= render "layouts/_mailbot_header" - = @email_body -= render "layouts/_mailbot_footer" - \ No newline at end of file From 26bb7fcdca5d3a2c219d6a664b9371289cd08713 Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Fri, 5 Mar 2021 09:12:52 -0800 Subject: [PATCH 04/51] change layouts to erb --- app/views/layouts/_mailbot_footer.html.erb | 12 +++++++++ app/views/layouts/_mailbot_header.html.erb | 31 ++++++++++++++++++++++ 2 files changed, 43 insertions(+) create mode 100644 app/views/layouts/_mailbot_footer.html.erb create mode 100644 app/views/layouts/_mailbot_header.html.erb diff --git a/app/views/layouts/_mailbot_footer.html.erb b/app/views/layouts/_mailbot_footer.html.erb new file mode 100644 index 00000000..fe304c9d --- /dev/null +++ b/app/views/layouts/_mailbot_footer.html.erb @@ -0,0 +1,12 @@ + + + + + + + <%= stylesheet_link_tag "mailbot" %> + + +
+ + \ No newline at end of file diff --git a/app/views/layouts/_mailbot_header.html.erb b/app/views/layouts/_mailbot_header.html.erb new file mode 100644 index 00000000..cc968b80 --- /dev/null +++ b/app/views/layouts/_mailbot_header.html.erb @@ -0,0 +1,31 @@ + + + + + + <%= 'Email' %> + + + + <%= stylesheet_link_tag "mailbot" %> + + +
+
+
+ <% if !@logo.nil? %> + <%= image_tag(@logo, style: "display:block") %> + <% end %> +
+
+

+
+
+
+
+ +
+ + + + \ No newline at end of file From c97b081b2cf13711e16393ef6391f13cbd4c23c0 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 5 Mar 2021 09:30:01 -0800 Subject: [PATCH 05/51] FOR DEMO ONLY --- app/models/registration.rb | 2 +- app/views/layouts/_mailbot_footer.html.erb | 2 ++ app/views/layouts/_mailbot_footer.html.haml | 9 --------- app/views/layouts/_mailbot_header.html.erb | 4 +--- app/views/layouts/_mailbot_header.html.haml | 19 ------------------- app/views/mailbot/email_template.html.erb | 10 +++++----- config/environments/development.rb | 1 + 7 files changed, 10 insertions(+), 37 deletions(-) delete mode 100644 app/views/layouts/_mailbot_footer.html.haml delete mode 100644 app/views/layouts/_mailbot_header.html.haml diff --git a/app/models/registration.rb b/app/models/registration.rb index 3906f558..d220e49f 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -69,7 +69,7 @@ class Registration < ApplicationRecord def send_registration_mail if conference.email_settings.send_on_registration? - Mailbot.registration_mail(conference, user).deliver_later + Mailbot.registration_mail(conference, user).deliver_now end end diff --git a/app/views/layouts/_mailbot_footer.html.erb b/app/views/layouts/_mailbot_footer.html.erb index fe304c9d..4f479cc7 100644 --- a/app/views/layouts/_mailbot_footer.html.erb +++ b/app/views/layouts/_mailbot_footer.html.erb @@ -7,6 +7,8 @@ <%= stylesheet_link_tag "mailbot" %> + +
\ No newline at end of file diff --git a/app/views/layouts/_mailbot_footer.html.haml b/app/views/layouts/_mailbot_footer.html.haml deleted file mode 100644 index f086135d..00000000 --- a/app/views/layouts/_mailbot_footer.html.haml +++ /dev/null @@ -1,9 +0,0 @@ -%html{lang: 'en'} - %head - %meta{charset: 'utf-8'} - %meta{name: 'viewport', content: 'width=device-width, initial-scale=1'} - %meta{content: 'Snap!Con -- A conference all about Snap!, a programing language from UC Berkeley.', name: 'description'} - %meta{content: 'Michael Ball, Brian Harvey, Jens Moenig, Bernat Romagosa, Dan Garcia, Lauren Mock', name: 'author'} - = stylesheet_link_tag "mailbot" - %body - #border \ No newline at end of file diff --git a/app/views/layouts/_mailbot_header.html.erb b/app/views/layouts/_mailbot_header.html.erb index cc968b80..0c29963f 100644 --- a/app/views/layouts/_mailbot_header.html.erb +++ b/app/views/layouts/_mailbot_header.html.erb @@ -24,8 +24,6 @@
-
- - + \ No newline at end of file diff --git a/app/views/layouts/_mailbot_header.html.haml b/app/views/layouts/_mailbot_header.html.haml deleted file mode 100644 index 1492a469..00000000 --- a/app/views/layouts/_mailbot_header.html.haml +++ /dev/null @@ -1,19 +0,0 @@ -%html{lang: 'en'} - %head - %meta{charset: 'utf-8'} - %meta{name: 'viewport', content: 'width=device-width, initial-scale=1'} - %title= 'Email' - %meta{content: 'Snap!Con -- A conference all about Snap!, a programing language from UC Berkeley.', name: 'description'} - %meta{content: 'Michael Ball, Brian Harvey, Jens Moenig, Bernat Romagosa, Dan Garcia, Lauren Mock', name: 'author'} - = stylesheet_link_tag "mailbot" - %body - #border - .row - .col-md-2 - - if !@logo.nil? - = image_tag(@logo, style: "display:block") - .col-md-10 - %h1 - #content - %span{:style => "white-space: pre-line"} - \ No newline at end of file diff --git a/app/views/mailbot/email_template.html.erb b/app/views/mailbot/email_template.html.erb index 41e0b0e6..fd8ae362 100644 --- a/app/views/mailbot/email_template.html.erb +++ b/app/views/mailbot/email_template.html.erb @@ -1,5 +1,5 @@ -<%= render "layouts/_mailbot_header" %> - <%= @email_body %> -<% end %> -<%= render "layouts/_mailbot_footer" %> - \ No newline at end of file +<%= render partial: "layouts/mailbot_header" %> + + <%= @email_body %> + +<%= render partial: "layouts/mailbot_footer" %> \ No newline at end of file diff --git a/config/environments/development.rb b/config/environments/development.rb index 6f2a1042..12119595 100644 --- a/config/environments/development.rb +++ b/config/environments/development.rb @@ -114,4 +114,5 @@ Osem::Application.configure do end end + config.assets.precompile += ['mailbot.css'] end From 0a20f80d6e3de9199ea3d662a8ed0061e7cd9e1a Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Wed, 10 Mar 2021 10:25:41 -0800 Subject: [PATCH 06/51] all layouts implemented in the emails --- app/views/mailbot/comment_template.html.erb | 14 ++++ app/views/mailbot/comment_template.text.erb | 83 ------------------- .../ticket_confirmation_template.html.erb | 12 +++ .../ticket_confirmation_template.text.erb | 81 ------------------ ...kers_ticket_confirmation_template.html.erb | 14 ++++ ...kers_ticket_confirmation_template.text.erb | 83 ------------------- 6 files changed, 40 insertions(+), 247 deletions(-) create mode 100644 app/views/mailbot/comment_template.html.erb delete mode 100644 app/views/mailbot/comment_template.text.erb create mode 100644 app/views/mailbot/ticket_confirmation_template.html.erb delete mode 100644 app/views/mailbot/ticket_confirmation_template.text.erb create mode 100644 app/views/mailbot/young_thinkers_ticket_confirmation_template.html.erb delete mode 100644 app/views/mailbot/young_thinkers_ticket_confirmation_template.text.erb diff --git a/app/views/mailbot/comment_template.html.erb b/app/views/mailbot/comment_template.html.erb new file mode 100644 index 00000000..2f5158e8 --- /dev/null +++ b/app/views/mailbot/comment_template.html.erb @@ -0,0 +1,14 @@ +<%= render partial: "layouts/mailbot_header" %> + + Dear <%= @user.name %>, + + User <%= @comment.user.name %> posted a new comment for event <%= @event.title %> of <%= @conference.short_title %> . + + "<%= @comment.body %>" + + To reply to this comment, please go to <%= h(admin_conference_program_event_url(@conference.short_title, @event, only_path: false)) %> + + Best wishes, + <%= @conference.title %> Team + +<%= render partial: "layouts/mailbot_footer" %> \ No newline at end of file diff --git a/app/views/mailbot/comment_template.text.erb b/app/views/mailbot/comment_template.text.erb deleted file mode 100644 index d162d710..00000000 --- a/app/views/mailbot/comment_template.text.erb +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - Email - - -
-
- -
-
-

-
-
-
- - Dear <%= @user.name %>, - - User <%= @comment.user.name %> posted a new comment for event <%= @event.title %> of <%= @conference.short_title %> . - - "<%= @comment.body %>" - - To reply to this comment, please go to <%= h(admin_conference_program_event_url(@conference.short_title, @event, only_path: false)) %> - - Best wishes, - <%= @conference.title %> Team - -
-
-

-
- - diff --git a/app/views/mailbot/ticket_confirmation_template.html.erb b/app/views/mailbot/ticket_confirmation_template.html.erb new file mode 100644 index 00000000..51e83f9c --- /dev/null +++ b/app/views/mailbot/ticket_confirmation_template.html.erb @@ -0,0 +1,12 @@ +<%= render partial: "layouts/mailbot_header" %> + + Dear <%= @user.name %>, + + Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>. + + Please, find the ticket(s) pdf attached. + + Best wishes, + <%= @conference.title %> Team + +<%= render partial: "layouts/mailbot_footer" %> \ No newline at end of file diff --git a/app/views/mailbot/ticket_confirmation_template.text.erb b/app/views/mailbot/ticket_confirmation_template.text.erb deleted file mode 100644 index 0e4e54f8..00000000 --- a/app/views/mailbot/ticket_confirmation_template.text.erb +++ /dev/null @@ -1,81 +0,0 @@ - - - - - - - - - - - - - - Email - - -
-
- -
-
-

-
-
-
- - Dear <%= @user.name %>, - - Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>. - - Please, find the ticket(s) pdf attached. - - Best wishes, - <%= @conference.title %> Team - -
-
-

-
- - diff --git a/app/views/mailbot/young_thinkers_ticket_confirmation_template.html.erb b/app/views/mailbot/young_thinkers_ticket_confirmation_template.html.erb new file mode 100644 index 00000000..44d3c2a0 --- /dev/null +++ b/app/views/mailbot/young_thinkers_ticket_confirmation_template.html.erb @@ -0,0 +1,14 @@ +<%= render partial: "layouts/mailbot_header" %> + + Dear <%= @user.name %>, + + Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>. + + Please, find the ticket(s) pdf attached. + + The SAP Young Thinkers team will reach out to you with information on how to participate in the event soon. In the meantime, you can check the event page (https://events.sap.com/yt-learning-festival-at-snapcon-2020/en/home) or send an email with your questions to youngthinkers@sap.com. + + Best wishes, + <%= @conference.title %> Team + +<%= render partial: "layouts/mailbot_footer" %> \ No newline at end of file diff --git a/app/views/mailbot/young_thinkers_ticket_confirmation_template.text.erb b/app/views/mailbot/young_thinkers_ticket_confirmation_template.text.erb deleted file mode 100644 index 6a4c7fb5..00000000 --- a/app/views/mailbot/young_thinkers_ticket_confirmation_template.text.erb +++ /dev/null @@ -1,83 +0,0 @@ - - - - - - - - - - - - - - Email - - -
-
- -
-
-

-
-
-
- - Dear <%= @user.name %>, - - Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>. - - Please, find the ticket(s) pdf attached. - - The SAP Young Thinkers team will reach out to you with information on how to participate in the event soon. In the meantime, you can check the event page (https://events.sap.com/yt-learning-festival-at-snapcon-2020/en/home) or send an email with your questions to youngthinkers@sap.com. - - Best wishes, - <%= @conference.title %> Team - -
-
-

-
- - From 1c28f3839e1d71ffcfe4f61971e32fe6adc8288d Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Wed, 10 Mar 2021 11:18:39 -0800 Subject: [PATCH 07/51] image tag --- app/views/layouts/_mailbot_header.html.erb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/views/layouts/_mailbot_header.html.erb b/app/views/layouts/_mailbot_header.html.erb index 0c29963f..343af234 100644 --- a/app/views/layouts/_mailbot_header.html.erb +++ b/app/views/layouts/_mailbot_header.html.erb @@ -13,12 +13,12 @@
- <% if !@logo.nil? %> + <% if @logo.present? %> <%= image_tag(@logo, style: "display:block") %> <% end %>
-

+

Snap!Con -- A conference all about Snap!, a programing language from UC Berkeley.

From ba4de34fa77abdfd34913362db471f6a3069c76e Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 10 Mar 2021 17:44:15 -0800 Subject: [PATCH 08/51] [fix] Add alt text to logo --- app/views/layouts/_mailbot_header.html.erb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/layouts/_mailbot_header.html.erb b/app/views/layouts/_mailbot_header.html.erb index 343af234..96beec33 100644 --- a/app/views/layouts/_mailbot_header.html.erb +++ b/app/views/layouts/_mailbot_header.html.erb @@ -14,7 +14,7 @@
<% if @logo.present? %> - <%= image_tag(@logo, style: "display:block") %> + <%= image_tag(@logo, style: "display:block", alt: 'conference logo') %> <% end %>
From ac4fb8a75722cc31838cd22c19354b4a1d4bf111 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 10 Mar 2021 20:13:49 -0800 Subject: [PATCH 09/51] [feat] Refactor mailbot.rb and support displaying conf/org/default logo --- app/mailers/mailbot.rb | 92 +++++++++++----------- app/models/registration.rb | 2 +- app/views/layouts/_mailbot_header.html.erb | 7 +- 3 files changed, 50 insertions(+), 51 deletions(-) diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index c055ec84..216bb9f9 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -3,23 +3,26 @@ SNAPCON_BCC_ADDRESS = 'messages@snap.berkeley.edu' EMAIL_TEMPLATE = 'email_template' YTLF_TICKET_ID = 50 +DEFAULT_LOGO = 'snapcon_logo.png' class Mailbot < ActionMailer::Base + default bcc: -> { SNAPCON_BCC_ADDRESS }, + template_name: -> { EMAIL_TEMPLATE } + def registration_mail(conference, user) @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.registration_body) - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) mail(to: user.email, - bcc: SNAPCON_BCC_ADDRESS, from: conference.contact.email, - subject: conference.email_settings.registration_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.registration_subject) end def ticket_confirmation_mail(ticket_purchase) @ticket_purchase = ticket_purchase @conference = ticket_purchase.conference @user = ticket_purchase.user + @logo_url = logo_url(@conference) PhysicalTicket.last(ticket_purchase.quantity).each do |physical_ticket| pdf = TicketPdf.new(@conference, @user, physical_ticket, @conference.ticket_layout.to_sym, "ticket_for_#{@conference.short_title}_#{physical_ticket.id}") @@ -32,7 +35,6 @@ class Mailbot < ActionMailer::Base end mail(to: @user.email, - bcc: SNAPCON_BCC_ADDRESS, from: @conference.contact.email, template_name: template_name, subject: "#{@conference.title} | Ticket Confirmation and PDF!") @@ -41,128 +43,114 @@ class Mailbot < ActionMailer::Base def acceptance_mail(event) conference = event.program.conference - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.accepted_body) mail(to: event.submitter.email, - bcc: SNAPCON_BCC_ADDRESS, from: conference.contact.email, - subject: conference.email_settings.accepted_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.accepted_subject) end def submitted_proposal_mail(event) conference = event.program.conference - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.submitted_proposal_body) mail(to: event.submitter.email, - bcc: SNAPCON_BCC_ADDRESS, from: conference.contact.email, - subject: conference.email_settings.submitted_proposal_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.submitted_proposal_subject) end def rejection_mail(event) conference = event.program.conference - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.rejected_body) mail(to: event.submitter.email, - bcc: SNAPCON_BCC_ADDRESS, from: conference.contact.email, - subject: conference.email_settings.rejected_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.rejected_subject) end def confirm_reminder_mail(event) conference = event.program.conference - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.confirmed_without_registration_body) mail(to: event.submitter.email, - bcc: SNAPCON_BCC_ADDRESS, from: conference.contact.email, - subject: conference.email_settings.confirmed_without_registration_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.confirmed_without_registration_subject) end def conference_date_update_mail(conference, user) - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.conference_dates_updated_body) mail(to: user.email, - bcc: SNAPCON_BCC_ADDRESS, from: conference.contact.email, - subject: conference.email_settings.conference_dates_updated_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.conference_dates_updated_subject) end def conference_registration_date_update_mail(conference, user) - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.conference_registration_dates_updated_body) mail(to: user.email, - bcc: SNAPCON_BCC_ADDRESS, from: conference.contact.email, - subject: conference.email_settings.conference_registration_dates_updated_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.conference_registration_dates_updated_subject) end def conference_venue_update_mail(conference, user) - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.venue_updated_body) mail(to: user.email, - bcc: SNAPCON_BCC_ADDRESS, from: conference.contact.email, - subject: conference.email_settings.venue_updated_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.venue_updated_subject) end def conference_schedule_update_mail(conference, user) - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.program_schedule_public_body) mail(to: user.email, + bcc: nil, from: conference.contact.email, - subject: conference.email_settings.program_schedule_public_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.program_schedule_public_subject) end def conference_cfp_update_mail(conference, user) - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.cfp_dates_updated_body) mail(to: user.email, + bcc: nil, from: conference.contact.email, - subject: conference.email_settings.cfp_dates_updated_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.cfp_dates_updated_subject) end def conference_booths_acceptance_mail(booth) conference = booth.conference - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) @email_body = conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_acceptance_body) mail(to: booth.submitter.email, + bcc: nil, from: conference.contact.email, - subject: conference.email_settings.booths_acceptance_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.booths_acceptance_subject) end def conference_booths_rejection_mail(booth) conference = booth.conference - @logo = conference.picture.thumb.url + @logo_url = logo_url(conference) @email_body = conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_rejection_body) mail(to: booth.submitter.email, + bcc: nil, from: conference.contact.email, - subject: conference.email_settings.booths_rejection_subject, - template_name: EMAIL_TEMPLATE) + subject: conference.email_settings.booths_rejection_subject) end def event_comment_mail(comment, user) @@ -170,10 +158,24 @@ class Mailbot < ActionMailer::Base @event = @comment.commentable @conference = @event.program.conference @user = user + @logo_url = logo_url(@conference) mail(to: @user.email, + bcc: nil, from: @conference.contact.email, template_name: 'comment_template', subject: "New comment has been posted for #{@event.title}") end + + private + + def logo_url(conference) + if conference.picture.present? + return conference.picture.thumb.url + elsif conference.organization.picture.present? + return conference.organization.picture.thumb.url + else + return DEFAULT_LOGO + end + end end diff --git a/app/models/registration.rb b/app/models/registration.rb index d220e49f..3906f558 100644 --- a/app/models/registration.rb +++ b/app/models/registration.rb @@ -69,7 +69,7 @@ class Registration < ApplicationRecord def send_registration_mail if conference.email_settings.send_on_registration? - Mailbot.registration_mail(conference, user).deliver_now + Mailbot.registration_mail(conference, user).deliver_later end end diff --git a/app/views/layouts/_mailbot_header.html.erb b/app/views/layouts/_mailbot_header.html.erb index 96beec33..e0f182a7 100644 --- a/app/views/layouts/_mailbot_header.html.erb +++ b/app/views/layouts/_mailbot_header.html.erb @@ -13,13 +13,10 @@
- <% if @logo.present? %> - <%= image_tag(@logo, style: "display:block", alt: 'conference logo') %> + <% if @logo_url.present? %> + <%= image_tag(@logo_url, style: "display:block;height:70px;width:auto;", alt: 'conference logo') %> <% end %>
-
-

Snap!Con -- A conference all about Snap!, a programing language from UC Berkeley.

-
From 899d4c91f6d87f34ea6889c51cec96e60a1e2bd2 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 10 Mar 2021 23:09:52 -0800 Subject: [PATCH 10/51] [test] Simplify mailbot.rb; Add corresponding tests --- app/mailers/mailbot.rb | 154 ++++++++++++++++------------------- config/environments/test.rb | 1 + spec/mailers/mailbot_spec.rb | 28 ++++++- 3 files changed, 98 insertions(+), 85 deletions(-) diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index 216bb9f9..22dfb866 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -7,21 +7,23 @@ DEFAULT_LOGO = 'snapcon_logo.png' class Mailbot < ActionMailer::Base default bcc: -> { SNAPCON_BCC_ADDRESS }, - template_name: -> { EMAIL_TEMPLATE } + template_name: -> { EMAIL_TEMPLATE }, + to: -> { @user.email }, + from: -> { @conference.contact.email} def registration_mail(conference, user) - @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.registration_body) - @logo_url = logo_url(conference) + @user = user + @conference = conference + @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.registration_body) + @logo_url = logo_url(@conference) - mail(to: user.email, - from: conference.contact.email, - subject: conference.email_settings.registration_subject) + mail(subject: @conference.email_settings.registration_subject) end def ticket_confirmation_mail(ticket_purchase) @ticket_purchase = ticket_purchase - @conference = ticket_purchase.conference @user = ticket_purchase.user + @conference = ticket_purchase.conference @logo_url = logo_url(@conference) PhysicalTicket.last(ticket_purchase.quantity).each do |physical_ticket| @@ -34,123 +36,111 @@ class Mailbot < ActionMailer::Base template_name = 'young_thinkers_ticket_confirmation_template' end - mail(to: @user.email, - from: @conference.contact.email, - template_name: template_name, - subject: "#{@conference.title} | Ticket Confirmation and PDF!") + mail(subject: "#{@conference.title} | Ticket Confirmation and PDF!", + template_name: template_name) end def acceptance_mail(event) - conference = event.program.conference + @user = event.submitter + @conference = event.program.conference + @logo_url = logo_url(@conference) + @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.accepted_body) - @logo_url = logo_url(conference) - @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.accepted_body) - - mail(to: event.submitter.email, - from: conference.contact.email, - subject: conference.email_settings.accepted_subject) + mail(subject: @conference.email_settings.accepted_subject) end def submitted_proposal_mail(event) - conference = event.program.conference + @user = event.submitter + @conference = event.program.conference + @logo_url = logo_url(@conference) + @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.submitted_proposal_body) - @logo_url = logo_url(conference) - @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.submitted_proposal_body) - - mail(to: event.submitter.email, - from: conference.contact.email, - subject: conference.email_settings.submitted_proposal_subject) + mail(subject: @conference.email_settings.submitted_proposal_subject) end def rejection_mail(event) - conference = event.program.conference + @user = event.submitter + @conference = event.program.conference + @logo_url = logo_url(@conference) + @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.rejected_body) - @logo_url = logo_url(conference) - @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.rejected_body) - - mail(to: event.submitter.email, - from: conference.contact.email, - subject: conference.email_settings.rejected_subject) + mail(subject: @conference.email_settings.rejected_subject) end def confirm_reminder_mail(event) - conference = event.program.conference + @user = event.submitter + @conference = event.program.conference + @logo_url = logo_url(@conference) + @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.confirmed_without_registration_body) - @logo_url = logo_url(conference) - @email_body = conference.email_settings.generate_event_mail(event, conference.email_settings.confirmed_without_registration_body) - - mail(to: event.submitter.email, - from: conference.contact.email, - subject: conference.email_settings.confirmed_without_registration_subject) + mail(subject: @conference.email_settings.confirmed_without_registration_subject) end def conference_date_update_mail(conference, user) - @logo_url = logo_url(conference) - @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.conference_dates_updated_body) + @user = user + @conference = @conference + @logo_url = logo_url(@conference) + @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.conference_dates_updated_body) - mail(to: user.email, - from: conference.contact.email, - subject: conference.email_settings.conference_dates_updated_subject) + mail(subject: @conference.email_settings.conference_dates_updated_subject) end def conference_registration_date_update_mail(conference, user) - @logo_url = logo_url(conference) - @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.conference_registration_dates_updated_body) + @user = user + @conference = conference + @logo_url = logo_url(@conference) + @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.conference_registration_dates_updated_body) - mail(to: user.email, - from: conference.contact.email, - subject: conference.email_settings.conference_registration_dates_updated_subject) + mail(subject: @conference.email_settings.conference_registration_dates_updated_subject) end def conference_venue_update_mail(conference, user) - @logo_url = logo_url(conference) - @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.venue_updated_body) + @user = user + @conference = conference + @logo_url = logo_url(@conference) + @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.venue_updated_body) - mail(to: user.email, - from: conference.contact.email, - subject: conference.email_settings.venue_updated_subject) + mail(subject: @conference.email_settings.venue_updated_subject) end def conference_schedule_update_mail(conference, user) - @logo_url = logo_url(conference) - @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.program_schedule_public_body) + @user = user + @conference = conference + @logo_url = logo_url(@conference) + @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.program_schedule_public_body) - mail(to: user.email, - bcc: nil, - from: conference.contact.email, - subject: conference.email_settings.program_schedule_public_subject) + mail(bcc: nil, + subject: @conference.email_settings.program_schedule_public_subject) end def conference_cfp_update_mail(conference, user) - @logo_url = logo_url(conference) - @email_body = conference.email_settings.generate_email_on_conf_updates(conference, user, conference.email_settings.cfp_dates_updated_body) + @user = user + @conference = conference + @logo_url = logo_url(@conference) + @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.cfp_dates_updated_body) - mail(to: user.email, - bcc: nil, - from: conference.contact.email, - subject: conference.email_settings.cfp_dates_updated_subject) + mail(bcc: nil, + subject: @conference.email_settings.cfp_dates_updated_subject) end def conference_booths_acceptance_mail(booth) - conference = booth.conference - @logo_url = logo_url(conference) - @email_body = conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_acceptance_body) + @user = booth.submitter + @conference = booth.conference + @logo_url = logo_url(@conference) + @email_body = @conference.email_settings.generate_booth_mail(booth, @conference.email_settings.booths_acceptance_body) - mail(to: booth.submitter.email, - bcc: nil, - from: conference.contact.email, - subject: conference.email_settings.booths_acceptance_subject) + mail(bcc: nil, + subject: @conference.email_settings.booths_acceptance_subject) end def conference_booths_rejection_mail(booth) - conference = booth.conference - @logo_url = logo_url(conference) - @email_body = conference.email_settings.generate_booth_mail(booth, conference.email_settings.booths_rejection_body) + @user = booth.submitter + @conference = booth.conference + @logo_url = logo_url(@conference) + @email_body = @conference.email_settings.generate_booth_mail(booth, @conference.email_settings.booths_rejection_body) - mail(to: booth.submitter.email, - bcc: nil, - from: conference.contact.email, - subject: conference.email_settings.booths_rejection_subject) + mail(bcc: nil, + subject: @conference.email_settings.booths_rejection_subject) end def event_comment_mail(comment, user) @@ -160,9 +150,7 @@ class Mailbot < ActionMailer::Base @user = user @logo_url = logo_url(@conference) - mail(to: @user.email, - bcc: nil, - from: @conference.contact.email, + mail(bcc: nil, template_name: 'comment_template', subject: "New comment has been posted for #{@event.title}") end diff --git a/config/environments/test.rb b/config/environments/test.rb index 225ae26f..1a9d4d7b 100644 --- a/config/environments/test.rb +++ b/config/environments/test.rb @@ -52,4 +52,5 @@ Osem::Application.configure do ActiveSupport::Deprecation.silenced = true end + config.assets.precompile += ['mailbot.css'] end diff --git a/spec/mailers/mailbot_spec.rb b/spec/mailers/mailbot_spec.rb index 1f739997..22aade61 100644 --- a/spec/mailers/mailbot_spec.rb +++ b/spec/mailers/mailbot_spec.rb @@ -22,8 +22,8 @@ describe Mailbot do expect(mail.from).to eq ['conf@domain.com'] end - it 'assigns the email body' do - expect(mail.body).to include 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' + it 'assigns the email body with the correct logo' do + expect(mail.body).to include 'snapcon_logo' end it 'delivers the email' do @@ -77,4 +77,28 @@ describe Mailbot do context 'update notifications' do it 'is a pending test' end + + context 'helper methods' do + let(:organization) { create(:organization) } + let(:conference2) { create(:conference, organization: organization) } + + describe '#logo_url' do + it 'gives the correct logo url' do + mailbot = Mailbot.new + expect(mailbot.send(:logo_url, conference2)).to eq('snapcon_logo.png') + + File.open('spec/support/logos/1.png') do |file| + organization.picture = file + end + + expect(mailbot.send(:logo_url, conference2)).to include('1.png') + + File.open('spec/support/logos/2.png') do |file| + conference2.picture = file + end + + expect(mailbot.send(:logo_url, conference2)).to include('2.png') + end + end + end end From ee7c906f1773230e52b544d0767a60709ddc6e8a Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 11 Mar 2021 21:10:26 -0800 Subject: [PATCH 11/51] [feat] Modify alt text for logo; Support user-defined color for header and footer --- app/views/layouts/_mailbot_footer.html.erb | 7 ++++-- app/views/layouts/_mailbot_header.html.erb | 13 ++++++---- app/views/mailbot/comment_template.html.erb | 24 ++++++++++--------- app/views/mailbot/email_template.html.erb | 8 ++++--- .../ticket_confirmation_template.html.erb | 20 +++++++++------- ...kers_ticket_confirmation_template.html.erb | 24 ++++++++++--------- 6 files changed, 55 insertions(+), 41 deletions(-) diff --git a/app/views/layouts/_mailbot_footer.html.erb b/app/views/layouts/_mailbot_footer.html.erb index 4f479cc7..fc3d88a4 100644 --- a/app/views/layouts/_mailbot_footer.html.erb +++ b/app/views/layouts/_mailbot_footer.html.erb @@ -7,8 +7,11 @@ <%= stylesheet_link_tag "mailbot" %> - + <% if @conference.present? && @conference.color.present? %> +
+ <% else %> +
+ <% end %>
-
\ No newline at end of file diff --git a/app/views/layouts/_mailbot_header.html.erb b/app/views/layouts/_mailbot_header.html.erb index e0f182a7..674b56a5 100644 --- a/app/views/layouts/_mailbot_header.html.erb +++ b/app/views/layouts/_mailbot_header.html.erb @@ -9,18 +9,21 @@ <%= stylesheet_link_tag "mailbot" %> - -
+ + <% if @conference.present? && @conference.color.present? %> +
+ <% else %> +
+ <% end %>
<% if @logo_url.present? %> - <%= image_tag(@logo_url, style: "display:block;height:70px;width:auto;", alt: 'conference logo') %> + <%= image_tag(@logo_url, style: "display:block;height:70px;width:auto;", alt: @conference.title + ' logo') %> <% end %>
-
- + \ No newline at end of file diff --git a/app/views/mailbot/comment_template.html.erb b/app/views/mailbot/comment_template.html.erb index 2f5158e8..b9e9cce0 100644 --- a/app/views/mailbot/comment_template.html.erb +++ b/app/views/mailbot/comment_template.html.erb @@ -1,14 +1,16 @@ <%= render partial: "layouts/mailbot_header" %> - - Dear <%= @user.name %>, +
+ + Dear <%= @user.name %>, - User <%= @comment.user.name %> posted a new comment for event <%= @event.title %> of <%= @conference.short_title %> . - - "<%= @comment.body %>" - - To reply to this comment, please go to <%= h(admin_conference_program_event_url(@conference.short_title, @event, only_path: false)) %> - - Best wishes, - <%= @conference.title %> Team - + User <%= @comment.user.name %> posted a new comment for event <%= @event.title %> of <%= @conference.short_title %> . + + "<%= @comment.body %>" + + To reply to this comment, please go to <%= h(admin_conference_program_event_url(@conference.short_title, @event, only_path: false)) %> + + Best wishes, + <%= @conference.title %> Team + +
<%= render partial: "layouts/mailbot_footer" %> \ No newline at end of file diff --git a/app/views/mailbot/email_template.html.erb b/app/views/mailbot/email_template.html.erb index fd8ae362..6176cf08 100644 --- a/app/views/mailbot/email_template.html.erb +++ b/app/views/mailbot/email_template.html.erb @@ -1,5 +1,7 @@ <%= render partial: "layouts/mailbot_header" %> - - <%= @email_body %> - +
+ + <%= @email_body %> + +
<%= render partial: "layouts/mailbot_footer" %> \ No newline at end of file diff --git a/app/views/mailbot/ticket_confirmation_template.html.erb b/app/views/mailbot/ticket_confirmation_template.html.erb index 51e83f9c..f92284d7 100644 --- a/app/views/mailbot/ticket_confirmation_template.html.erb +++ b/app/views/mailbot/ticket_confirmation_template.html.erb @@ -1,12 +1,14 @@ <%= render partial: "layouts/mailbot_header" %> - - Dear <%= @user.name %>, +
+ + Dear <%= @user.name %>, - Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>. - - Please, find the ticket(s) pdf attached. - - Best wishes, - <%= @conference.title %> Team - + Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>. + + Please, find the ticket(s) pdf attached. + + Best wishes, + <%= @conference.title %> Team + +
<%= render partial: "layouts/mailbot_footer" %> \ No newline at end of file diff --git a/app/views/mailbot/young_thinkers_ticket_confirmation_template.html.erb b/app/views/mailbot/young_thinkers_ticket_confirmation_template.html.erb index 44d3c2a0..d35d8a1f 100644 --- a/app/views/mailbot/young_thinkers_ticket_confirmation_template.html.erb +++ b/app/views/mailbot/young_thinkers_ticket_confirmation_template.html.erb @@ -1,14 +1,16 @@ <%= render partial: "layouts/mailbot_header" %> - - Dear <%= @user.name %>, +
+ + Dear <%= @user.name %>, - Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>. - - Please, find the ticket(s) pdf attached. - - The SAP Young Thinkers team will reach out to you with information on how to participate in the event soon. In the meantime, you can check the event page (https://events.sap.com/yt-learning-festival-at-snapcon-2020/en/home) or send an email with your questions to youngthinkers@sap.com. - - Best wishes, - <%= @conference.title %> Team - + Thanks! You have successfully booked <%= @ticket_purchase.quantity %> <%= @ticket_purchase.ticket.title %> ticket(s) for the event <%= @conference.title %>. Your transaction id is <%= @ticket_purchase.id %>. + + Please, find the ticket(s) pdf attached. + + The SAP Young Thinkers team will reach out to you with information on how to participate in the event soon. In the meantime, you can check the event page (https://events.sap.com/yt-learning-festival-at-snapcon-2020/en/home) or send an email with your questions to youngthinkers@sap.com. + + Best wishes, + <%= @conference.title %> Team + +
<%= render partial: "layouts/mailbot_footer" %> \ No newline at end of file From 4856bc718dae8370453827046cd2aa925461fb96 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 11 Mar 2021 22:00:15 -0800 Subject: [PATCH 12/51] [fix] Restore a mistakenly deleted test --- spec/mailers/mailbot_spec.rb | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/spec/mailers/mailbot_spec.rb b/spec/mailers/mailbot_spec.rb index 22aade61..a1281e65 100644 --- a/spec/mailers/mailbot_spec.rb +++ b/spec/mailers/mailbot_spec.rb @@ -22,6 +22,10 @@ describe Mailbot do expect(mail.from).to eq ['conf@domain.com'] end + it 'assigns the email body' do + expect(mail.body).to include 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' + end + it 'assigns the email body with the correct logo' do expect(mail.body).to include 'snapcon_logo' end From 394dc0506f82ae2e54ea2b42c3b59abe35c55941 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 11 Mar 2021 23:15:07 -0800 Subject: [PATCH 13/51] temp --- spec/mailers/mailbot_spec.rb | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/spec/mailers/mailbot_spec.rb b/spec/mailers/mailbot_spec.rb index a1281e65..65ea4213 100644 --- a/spec/mailers/mailbot_spec.rb +++ b/spec/mailers/mailbot_spec.rb @@ -25,7 +25,19 @@ describe Mailbot do it 'assigns the email body' do expect(mail.body).to include 'Lorem ipsum dolor sit amet, consectetuer adipiscing elit' end - + + it 'assigns the email body with the correct color' do + # p mail.body + # expect(mail.body).to have_selector('#border.background-color', '#0B3559') + # Capybara.within_frame(mail.body) do + # color = find('#border').native.css_value('background-color') + # expect(color).to eq('#0B3559') + # end + + # TODO: select border ... + expect(mail.body).to include('background-color: ' + conference.color) + end + it 'assigns the email body with the correct logo' do expect(mail.body).to include 'snapcon_logo' end From 33ce7a61c64bf758fb9fbc36c084334434109a7c Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 11 Mar 2021 23:39:06 -0800 Subject: [PATCH 14/51] [style] Fix style --- app/mailers/mailbot.rb | 50 +++++++++++++++++++++--------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index 22dfb866..8a7cb840 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -6,10 +6,10 @@ YTLF_TICKET_ID = 50 DEFAULT_LOGO = 'snapcon_logo.png' class Mailbot < ActionMailer::Base - default bcc: -> { SNAPCON_BCC_ADDRESS }, - template_name: -> { EMAIL_TEMPLATE }, - to: -> { @user.email }, - from: -> { @conference.contact.email} + default bcc: -> { SNAPCON_BCC_ADDRESS }, + template_name: -> { EMAIL_TEMPLATE }, + to: -> { @user.email }, + from: -> { @conference.contact.email } def registration_mail(conference, user) @user = user @@ -17,7 +17,7 @@ class Mailbot < ActionMailer::Base @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.registration_body) @logo_url = logo_url(@conference) - mail(subject: @conference.email_settings.registration_subject) + mail(subject: @conference.email_settings.registration_subject) end def ticket_confirmation_mail(ticket_purchase) @@ -46,7 +46,7 @@ class Mailbot < ActionMailer::Base @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.accepted_body) - mail(subject: @conference.email_settings.accepted_subject) + mail(subject: @conference.email_settings.accepted_subject) end def submitted_proposal_mail(event) @@ -55,7 +55,7 @@ class Mailbot < ActionMailer::Base @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.submitted_proposal_body) - mail(subject: @conference.email_settings.submitted_proposal_subject) + mail(subject: @conference.email_settings.submitted_proposal_subject) end def rejection_mail(event) @@ -64,7 +64,7 @@ class Mailbot < ActionMailer::Base @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.rejected_body) - mail(subject: @conference.email_settings.rejected_subject) + mail(subject: @conference.email_settings.rejected_subject) end def confirm_reminder_mail(event) @@ -73,16 +73,16 @@ class Mailbot < ActionMailer::Base @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.confirmed_without_registration_body) - mail(subject: @conference.email_settings.confirmed_without_registration_subject) + mail(subject: @conference.email_settings.confirmed_without_registration_subject) end - def conference_date_update_mail(conference, user) + def conference_date_update_mail(_conference, user) @user = user @conference = @conference @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.conference_dates_updated_body) - mail(subject: @conference.email_settings.conference_dates_updated_subject) + mail(subject: @conference.email_settings.conference_dates_updated_subject) end def conference_registration_date_update_mail(conference, user) @@ -91,7 +91,7 @@ class Mailbot < ActionMailer::Base @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.conference_registration_dates_updated_body) - mail(subject: @conference.email_settings.conference_registration_dates_updated_subject) + mail(subject: @conference.email_settings.conference_registration_dates_updated_subject) end def conference_venue_update_mail(conference, user) @@ -100,7 +100,7 @@ class Mailbot < ActionMailer::Base @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.venue_updated_body) - mail(subject: @conference.email_settings.venue_updated_subject) + mail(subject: @conference.email_settings.venue_updated_subject) end def conference_schedule_update_mail(conference, user) @@ -109,8 +109,8 @@ class Mailbot < ActionMailer::Base @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.program_schedule_public_body) - mail(bcc: nil, - subject: @conference.email_settings.program_schedule_public_subject) + mail(bcc: nil, + subject: @conference.email_settings.program_schedule_public_subject) end def conference_cfp_update_mail(conference, user) @@ -119,8 +119,8 @@ class Mailbot < ActionMailer::Base @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.cfp_dates_updated_body) - mail(bcc: nil, - subject: @conference.email_settings.cfp_dates_updated_subject) + mail(bcc: nil, + subject: @conference.email_settings.cfp_dates_updated_subject) end def conference_booths_acceptance_mail(booth) @@ -129,8 +129,8 @@ class Mailbot < ActionMailer::Base @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_booth_mail(booth, @conference.email_settings.booths_acceptance_body) - mail(bcc: nil, - subject: @conference.email_settings.booths_acceptance_subject) + mail(bcc: nil, + subject: @conference.email_settings.booths_acceptance_subject) end def conference_booths_rejection_mail(booth) @@ -139,8 +139,8 @@ class Mailbot < ActionMailer::Base @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_booth_mail(booth, @conference.email_settings.booths_rejection_body) - mail(bcc: nil, - subject: @conference.email_settings.booths_rejection_subject) + mail(bcc: nil, + subject: @conference.email_settings.booths_rejection_subject) end def event_comment_mail(comment, user) @@ -156,14 +156,14 @@ class Mailbot < ActionMailer::Base end private - + def logo_url(conference) if conference.picture.present? - return conference.picture.thumb.url + conference.picture.thumb.url elsif conference.organization.picture.present? - return conference.organization.picture.thumb.url + conference.organization.picture.thumb.url else - return DEFAULT_LOGO + DEFAULT_LOGO end end end From fdb08b0c9a2fd6bf8cdb199aa418852535929f22 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 12 Mar 2021 00:14:29 -0800 Subject: [PATCH 15/51] [refactor] Move Mailbot#logo_url and #conference_color to ConferenceHelper --- app/helpers/conference_helper.rb | 21 ++++++++++++++ app/mailers/mailbot.rb | 33 +++------------------- app/views/layouts/_mailbot_footer.html.erb | 7 +---- app/views/layouts/_mailbot_header.html.erb | 10 ++----- spec/helpers/conference_helper_spec.rb | 22 +++++++++++++++ spec/mailers/mailbot_spec.rb | 25 +--------------- 6 files changed, 52 insertions(+), 66 deletions(-) diff --git a/app/helpers/conference_helper.rb b/app/helpers/conference_helper.rb index 14253b23..417a8d55 100644 --- a/app/helpers/conference_helper.rb +++ b/app/helpers/conference_helper.rb @@ -1,5 +1,8 @@ # frozen_string_literal: true +DEFAULT_LOGO = 'snapcon_logo.png' +DEFAULT_COLOR = '#0B3559' + module ConferenceHelper # Return true if only call_for_papers or call_for_tracks or call_for_booths is open def one_call_open(*calls) @@ -28,6 +31,24 @@ module ConferenceHelper markdown(ticket.description.split("\n").first&.strip) end + def conference_logo_url(conference) + if conference.picture.present? + conference.picture.thumb.url + elsif conference.organization.picture.present? + conference.organization.picture.thumb.url + else + DEFAULT_LOGO + end + end + + def conference_color(conference) + if conference.color.present? + conference.color + else + DEFAULT_COLOR + end + end + # adds events to icalendar for proposals in a conference def icalendar_proposals(calendar, proposals, conference) proposals.each do |proposal| diff --git a/app/mailers/mailbot.rb b/app/mailers/mailbot.rb index 8a7cb840..07249862 100644 --- a/app/mailers/mailbot.rb +++ b/app/mailers/mailbot.rb @@ -3,9 +3,10 @@ SNAPCON_BCC_ADDRESS = 'messages@snap.berkeley.edu' EMAIL_TEMPLATE = 'email_template' YTLF_TICKET_ID = 50 -DEFAULT_LOGO = 'snapcon_logo.png' class Mailbot < ActionMailer::Base + helper ConferenceHelper + default bcc: -> { SNAPCON_BCC_ADDRESS }, template_name: -> { EMAIL_TEMPLATE }, to: -> { @user.email }, @@ -15,7 +16,6 @@ class Mailbot < ActionMailer::Base @user = user @conference = conference @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.registration_body) - @logo_url = logo_url(@conference) mail(subject: @conference.email_settings.registration_subject) end @@ -24,7 +24,6 @@ class Mailbot < ActionMailer::Base @ticket_purchase = ticket_purchase @user = ticket_purchase.user @conference = ticket_purchase.conference - @logo_url = logo_url(@conference) PhysicalTicket.last(ticket_purchase.quantity).each do |physical_ticket| pdf = TicketPdf.new(@conference, @user, physical_ticket, @conference.ticket_layout.to_sym, "ticket_for_#{@conference.short_title}_#{physical_ticket.id}") @@ -43,7 +42,6 @@ class Mailbot < ActionMailer::Base def acceptance_mail(event) @user = event.submitter @conference = event.program.conference - @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.accepted_body) mail(subject: @conference.email_settings.accepted_subject) @@ -52,7 +50,6 @@ class Mailbot < ActionMailer::Base def submitted_proposal_mail(event) @user = event.submitter @conference = event.program.conference - @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.submitted_proposal_body) mail(subject: @conference.email_settings.submitted_proposal_subject) @@ -61,7 +58,6 @@ class Mailbot < ActionMailer::Base def rejection_mail(event) @user = event.submitter @conference = event.program.conference - @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.rejected_body) mail(subject: @conference.email_settings.rejected_subject) @@ -70,16 +66,14 @@ class Mailbot < ActionMailer::Base def confirm_reminder_mail(event) @user = event.submitter @conference = event.program.conference - @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_event_mail(event, @conference.email_settings.confirmed_without_registration_body) mail(subject: @conference.email_settings.confirmed_without_registration_subject) end - def conference_date_update_mail(_conference, user) + def conference_date_update_mail(conference, user) @user = user - @conference = @conference - @logo_url = logo_url(@conference) + @conference = conference @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.conference_dates_updated_body) mail(subject: @conference.email_settings.conference_dates_updated_subject) @@ -88,7 +82,6 @@ class Mailbot < ActionMailer::Base def conference_registration_date_update_mail(conference, user) @user = user @conference = conference - @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.conference_registration_dates_updated_body) mail(subject: @conference.email_settings.conference_registration_dates_updated_subject) @@ -97,7 +90,6 @@ class Mailbot < ActionMailer::Base def conference_venue_update_mail(conference, user) @user = user @conference = conference - @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.venue_updated_body) mail(subject: @conference.email_settings.venue_updated_subject) @@ -106,7 +98,6 @@ class Mailbot < ActionMailer::Base def conference_schedule_update_mail(conference, user) @user = user @conference = conference - @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.program_schedule_public_body) mail(bcc: nil, @@ -116,7 +107,6 @@ class Mailbot < ActionMailer::Base def conference_cfp_update_mail(conference, user) @user = user @conference = conference - @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_email_on_conf_updates(@conference, @user, @conference.email_settings.cfp_dates_updated_body) mail(bcc: nil, @@ -126,7 +116,6 @@ class Mailbot < ActionMailer::Base def conference_booths_acceptance_mail(booth) @user = booth.submitter @conference = booth.conference - @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_booth_mail(booth, @conference.email_settings.booths_acceptance_body) mail(bcc: nil, @@ -136,7 +125,6 @@ class Mailbot < ActionMailer::Base def conference_booths_rejection_mail(booth) @user = booth.submitter @conference = booth.conference - @logo_url = logo_url(@conference) @email_body = @conference.email_settings.generate_booth_mail(booth, @conference.email_settings.booths_rejection_body) mail(bcc: nil, @@ -148,22 +136,9 @@ class Mailbot < ActionMailer::Base @event = @comment.commentable @conference = @event.program.conference @user = user - @logo_url = logo_url(@conference) mail(bcc: nil, template_name: 'comment_template', subject: "New comment has been posted for #{@event.title}") end - - private - - def logo_url(conference) - if conference.picture.present? - conference.picture.thumb.url - elsif conference.organization.picture.present? - conference.organization.picture.thumb.url - else - DEFAULT_LOGO - end - end end diff --git a/app/views/layouts/_mailbot_footer.html.erb b/app/views/layouts/_mailbot_footer.html.erb index fc3d88a4..3cc8b3c3 100644 --- a/app/views/layouts/_mailbot_footer.html.erb +++ b/app/views/layouts/_mailbot_footer.html.erb @@ -7,11 +7,6 @@ <%= stylesheet_link_tag "mailbot" %> - <% if @conference.present? && @conference.color.present? %> -
- <% else %> -
- <% end %> -
+
\ No newline at end of file diff --git a/app/views/layouts/_mailbot_header.html.erb b/app/views/layouts/_mailbot_header.html.erb index 674b56a5..12f9d4a5 100644 --- a/app/views/layouts/_mailbot_header.html.erb +++ b/app/views/layouts/_mailbot_header.html.erb @@ -10,15 +10,11 @@ <%= stylesheet_link_tag "mailbot" %> - <% if @conference.present? && @conference.color.present? %> -
- <% else %> -
- <% end %> +
- <% if @logo_url.present? %> - <%= image_tag(@logo_url, style: "display:block;height:70px;width:auto;", alt: @conference.title + ' logo') %> + <% if @conference.present? %> + <%= image_tag(conference_logo_url(@conference), style: "display:block;height:70px;width:auto;", alt: @conference.title + ' logo') %> <% end %>
diff --git a/spec/helpers/conference_helper_spec.rb b/spec/helpers/conference_helper_spec.rb index 101d083a..996ffeba 100644 --- a/spec/helpers/conference_helper_spec.rb +++ b/spec/helpers/conference_helper_spec.rb @@ -67,4 +67,26 @@ describe ConferenceHelper, type: :helper do expect(sponsorship_mailto(conference)).to match conference.short_title end end + + describe '#conference_logo_url' do + let(:organization) { create(:organization) } + let(:conference2) { create(:conference, organization: organization) } + + it 'gives the correct logo url' do + mailbot = Mailbot.new + expect(conference_logo_url(conference2)).to eq('snapcon_logo.png') + + File.open('spec/support/logos/1.png') do |file| + organization.picture = file + end + + expect(conference_logo_url(conference2)).to include('1.png') + + File.open('spec/support/logos/2.png') do |file| + conference2.picture = file + end + + expect(conference_logo_url(conference2)).to include('2.png') + end + end end diff --git a/spec/mailers/mailbot_spec.rb b/spec/mailers/mailbot_spec.rb index 65ea4213..6d3b64ad 100644 --- a/spec/mailers/mailbot_spec.rb +++ b/spec/mailers/mailbot_spec.rb @@ -38,6 +38,7 @@ describe Mailbot do expect(mail.body).to include('background-color: ' + conference.color) end + # TODO: test on non-default logo it 'assigns the email body with the correct logo' do expect(mail.body).to include 'snapcon_logo' end @@ -93,28 +94,4 @@ describe Mailbot do context 'update notifications' do it 'is a pending test' end - - context 'helper methods' do - let(:organization) { create(:organization) } - let(:conference2) { create(:conference, organization: organization) } - - describe '#logo_url' do - it 'gives the correct logo url' do - mailbot = Mailbot.new - expect(mailbot.send(:logo_url, conference2)).to eq('snapcon_logo.png') - - File.open('spec/support/logos/1.png') do |file| - organization.picture = file - end - - expect(mailbot.send(:logo_url, conference2)).to include('1.png') - - File.open('spec/support/logos/2.png') do |file| - conference2.picture = file - end - - expect(mailbot.send(:logo_url, conference2)).to include('2.png') - end - end - end end From 72dd36993bf6500e53491c18910b328b019e1606 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 12 Mar 2021 00:20:30 -0800 Subject: [PATCH 16/51] [style] Remove unused variable --- spec/helpers/conference_helper_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/helpers/conference_helper_spec.rb b/spec/helpers/conference_helper_spec.rb index 996ffeba..e569be09 100644 --- a/spec/helpers/conference_helper_spec.rb +++ b/spec/helpers/conference_helper_spec.rb @@ -73,7 +73,6 @@ describe ConferenceHelper, type: :helper do let(:conference2) { create(:conference, organization: organization) } it 'gives the correct logo url' do - mailbot = Mailbot.new expect(conference_logo_url(conference2)).to eq('snapcon_logo.png') File.open('spec/support/logos/1.png') do |file| From 2bcd7d39b33f14e0aef7bc43ffe781ca91f2e61f Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 12 Mar 2021 07:49:55 -0800 Subject: [PATCH 17/51] [test] Add unit test for conference_helper#conference_color --- spec/factories/conferences.rb | 1 + spec/helpers/conference_helper_spec.rb | 11 +++++++++++ 2 files changed, 12 insertions(+) diff --git a/spec/factories/conferences.rb b/spec/factories/conferences.rb index d1ac5032..1968e54e 100644 --- a/spec/factories/conferences.rb +++ b/spec/factories/conferences.rb @@ -49,6 +49,7 @@ FactoryBot.define do ticket_layout { 'portrait' } description { Faker::Hipster.paragraph } organization + color { '#FFFFFF' } after(:create) do |conference| Role.where(name: 'organizer', resource: conference).first_or_create(description: 'For the organizers of the conference (who shall have full access)') Role.where(name: 'cfp', resource: conference).first_or_create(description: 'For the members of the CfP team') diff --git a/spec/helpers/conference_helper_spec.rb b/spec/helpers/conference_helper_spec.rb index e569be09..4ea48496 100644 --- a/spec/helpers/conference_helper_spec.rb +++ b/spec/helpers/conference_helper_spec.rb @@ -88,4 +88,15 @@ describe ConferenceHelper, type: :helper do expect(conference_logo_url(conference2)).to include('2.png') end end + + describe '#conference_color' do + let(:conference2) { create(:conference, color: '#000000') } + + it 'gives the correct conference color' do + expect(conference_color(conference2)).to eq('#000000') + + conference2.color = '' + expect(conference_color(conference2)).to eq('#0B3559') + end + end end From fcb3dc96c0fc0ef7f0b11bd158d3b1cf0df22e4e Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 12 Mar 2021 21:16:21 -0800 Subject: [PATCH 18/51] [style] Delete comments --- spec/mailers/mailbot_spec.rb | 9 --------- 1 file changed, 9 deletions(-) diff --git a/spec/mailers/mailbot_spec.rb b/spec/mailers/mailbot_spec.rb index 6d3b64ad..4c4bd699 100644 --- a/spec/mailers/mailbot_spec.rb +++ b/spec/mailers/mailbot_spec.rb @@ -27,18 +27,9 @@ describe Mailbot do end it 'assigns the email body with the correct color' do - # p mail.body - # expect(mail.body).to have_selector('#border.background-color', '#0B3559') - # Capybara.within_frame(mail.body) do - # color = find('#border').native.css_value('background-color') - # expect(color).to eq('#0B3559') - # end - - # TODO: select border ... expect(mail.body).to include('background-color: ' + conference.color) end - # TODO: test on non-default logo it 'assigns the email body with the correct logo' do expect(mail.body).to include 'snapcon_logo' end From 1936e4373588925bcbef1101632711e3708eafbc Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 12 Mar 2021 00:47:29 -0800 Subject: [PATCH 19/51] Switch CodeCov badge to Code Climate badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71f3ac37..1a549b45 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### Spring 2021 Student Project [![Build Status](https://travis-ci.com/CactusPuppy/snapcon.svg?branch=master)](https://travis-ci.com/CactusPuppy/snapcon) [![Maintainability](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/maintainability)](https://codeclimate.com/github/CactusPuppy/snapcon/maintainability) -[![codecov](https://codecov.io/gh/CactusPuppy/snapcon/branch/master/graph/badge.svg?token=y4aEAtw6KJ)](https://codecov.io/gh/CactusPuppy/snapcon) +[![Test Coverage](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/test_coverage)](https://codeclimate.com/github/CactusPuppy/snapcon/test_coverage) [![Security Status](https://hakiri.io/github/CactusPuppy/snapcon/master.svg)](https://hakiri.io/github/CactusPuppy/snapcon/master) [![Depfu](https://badges.depfu.com/badges/16eb1ffb3a9f1a36c4e595a5ae2a1dca/overview.svg)](https://depfu.com/github/CactusPuppy/snapcon?project_id=22682) [![Bluejay Dashboard](https://img.shields.io/badge/Bluejay-Dashboard_5-blue.svg)](http://dashboard.bluejay.governify.io/dashboard/script/dashboardLoader.js?dashboardURL=https://reporter.bluejay.governify.io/api/v4/dashboards/tpa-CS169L-GH-CactusPuppy_snapcon/main) From fd0931f9c2f3973f88ddee119c7f6be7fd250ea2 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 14:12:29 -0700 Subject: [PATCH 20/51] Switch to using Codacy for code coverage (following OSEM example) --- .travis.yml | 12 +++--------- README.md | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e6985a3..d7ddbded 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,6 @@ before_install: - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true - gem install bundler -v $(tail -n 1 Gemfile.lock) - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $CCTR - - chmod +x $CCTR notifications: email: on_success: change @@ -30,15 +28,11 @@ notifications: before_script: - RAILS_ENV=test bundle exec rake db:bootstrap --trace - RAILS_ENV=test bundle exec bin/rails webdrivers:chromedriver:update - - $CCTR before-build + - bash <(curl -Ls https://coverage.codacy.com/get.sh) download script: - "bin/travis_script.sh $TEST_SUITE" - # TODO Get this working. -after_script: - # combine coverage from all suites, and upload3 to CodeClimate - - $CCTR format-coverage -t simplecov --output coverage/codeclimate.$TEST_SUITE.json - - $CCTR sum-coverage coverage/codeclimate.*.json - - if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then $CCTR upload-coverage; fi +after_success: + - - bash <(curl -Ls https://coverage.codacy.com/get.sh) env: global: diff --git a/README.md b/README.md index 1a549b45..9d332d36 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### Spring 2021 Student Project [![Build Status](https://travis-ci.com/CactusPuppy/snapcon.svg?branch=master)](https://travis-ci.com/CactusPuppy/snapcon) [![Maintainability](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/maintainability)](https://codeclimate.com/github/CactusPuppy/snapcon/maintainability) -[![Test Coverage](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/test_coverage)](https://codeclimate.com/github/CactusPuppy/snapcon/test_coverage) +[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/fd87bbd10aff42fb9f0a16755e78968f)](https://www.codacy.com/gh/CactusPuppy/snapcon/dashboard?utm_source=github.com&utm_medium=referral&utm_content=CactusPuppy/snapcon&utm_campaign=Badge_Coverage) [![Security Status](https://hakiri.io/github/CactusPuppy/snapcon/master.svg)](https://hakiri.io/github/CactusPuppy/snapcon/master) [![Depfu](https://badges.depfu.com/badges/16eb1ffb3a9f1a36c4e595a5ae2a1dca/overview.svg)](https://depfu.com/github/CactusPuppy/snapcon?project_id=22682) [![Bluejay Dashboard](https://img.shields.io/badge/Bluejay-Dashboard_5-blue.svg)](http://dashboard.bluejay.governify.io/dashboard/script/dashboardLoader.js?dashboardURL=https://reporter.bluejay.governify.io/api/v4/dashboards/tpa-CS169L-GH-CactusPuppy_snapcon/main) From 584e5827a1847038ab6db3024060ec027dde301b Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 14:25:43 -0700 Subject: [PATCH 21/51] Specify where the coverage report is --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d7ddbded..c03f8287 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ before_script: script: - "bin/travis_script.sh $TEST_SUITE" after_success: - - - bash <(curl -Ls https://coverage.codacy.com/get.sh) + - - bash <(curl -Ls https://coverage.codacy.com/get.sh) -r coverage/coverage.xml env: global: From 9357c71eee05e28121f79695af6bbee981340136 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 14:27:25 -0700 Subject: [PATCH 22/51] Fix minor typo in .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c03f8287..789439ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ before_script: script: - "bin/travis_script.sh $TEST_SUITE" after_success: - - - bash <(curl -Ls https://coverage.codacy.com/get.sh) -r coverage/coverage.xml + - bash <(curl -Ls https://coverage.codacy.com/get.sh) -r coverage/coverage.xml env: global: From 1a56c9c984728fd370074f0fe34e1715635f7b35 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 15:50:37 -0700 Subject: [PATCH 23/51] Actually properly report parallel stages --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 789439ef..d95e947c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,12 @@ before_script: script: - "bin/travis_script.sh $TEST_SUITE" after_success: - - bash <(curl -Ls https://coverage.codacy.com/get.sh) -r coverage/coverage.xml + - bash <(curl -Ls https://coverage.codacy.com/get.sh) report --partial -l Ruby -r coverage/coverage.xml + +jobs: + include: + - stage: finalize + script: bash <(curl -Ls https://coverage.codacy.com/get.sh) final env: global: @@ -40,8 +45,6 @@ env: - OSEM_DB_HOST='' - OSEM_DB_PORT='' - OSEM_DB_NAME='osem_test' - - CC_TEST_REPORTER_ID=$CC_TEST_REPORTER - - CCTR=./cc-test-reporter matrix: - TEST_SUITE=ability - TEST_SUITE=features From 0e28b5694a43a915f1a2fac17406afd9b588d394 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 15:56:50 -0700 Subject: [PATCH 24/51] Prevent overwriting of jobs by matrix --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d95e947c..4991fea1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,7 @@ after_success: - bash <(curl -Ls https://coverage.codacy.com/get.sh) report --partial -l Ruby -r coverage/coverage.xml jobs: + fast_finish: false include: - stage: finalize script: bash <(curl -Ls https://coverage.codacy.com/get.sh) final @@ -45,11 +46,9 @@ env: - OSEM_DB_HOST='' - OSEM_DB_PORT='' - OSEM_DB_NAME='osem_test' - matrix: + jobs: - TEST_SUITE=ability - TEST_SUITE=features - TEST_SUITE=models - TEST_SUITE=controllers - TEST_SUITE=rest -matrix: - fast_finish: false From c7482bef1bf3c418b5757ec299878529c97cca8e Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 16:14:33 -0700 Subject: [PATCH 25/51] Ensure coverage.xml is generated on Travis --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d3e17427..2d680fb2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,7 +3,7 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' require 'simplecov' -if ENV['GITHUB_ACTIONS'] +if ENV['GITHUB_ACTIONS'] || ENV['TRAVIS'] require 'simplecov-cobertura' SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter end From 8342b4c283f751b63200ac007439dc8fa8d22c47 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 20:38:14 -0700 Subject: [PATCH 26/51] Try an experimental .travis.yml which uploads coverage to CodeClimate --- .travis.yml | 106 +++++++++++++++++++++++++++++++++++++++------------- 1 file changed, 80 insertions(+), 26 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4991fea1..67ce4176 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,8 +1,9 @@ +os: linux +dist: bionic language: ruby cache: bundler rvm: - 2.6.6 -dist: bionic addons: apt: packages: @@ -12,10 +13,6 @@ services: branches: except: - /^depfu/.*$/ -before_install: - - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" - - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true - - gem install bundler -v $(tail -n 1 Gemfile.lock) notifications: email: on_success: change @@ -25,30 +22,87 @@ notifications: - "chat.freenode.net#osem" on_success: change on_failure: change -before_script: - - RAILS_ENV=test bundle exec rake db:bootstrap --trace - - RAILS_ENV=test bundle exec bin/rails webdrivers:chromedriver:update - - bash <(curl -Ls https://coverage.codacy.com/get.sh) download -script: - - "bin/travis_script.sh $TEST_SUITE" -after_success: - - bash <(curl -Ls https://coverage.codacy.com/get.sh) report --partial -l Ruby -r coverage/coverage.xml - -jobs: - fast_finish: false - include: - - stage: finalize - script: bash <(curl -Ls https://coverage.codacy.com/get.sh) final - +stages: + - test + - finalize env: global: - OSEM_DB_ADAPTER=sqlite3 - OSEM_DB_HOST='' - OSEM_DB_PORT='' - OSEM_DB_NAME='osem_test' - jobs: - - TEST_SUITE=ability - - TEST_SUITE=features - - TEST_SUITE=models - - TEST_SUITE=controllers - - TEST_SUITE=rest + - CC_TEST_REPORTER_ID=$CC_TEST_REPORTER + - CCTR=./cc-test-reporter + - TOTAL_TEST_SUITES=5 +jobs: + - &tests + before_install: + - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" + - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true + - gem install bundler -v $(tail -n 1 Gemfile.lock) + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $CCTR + - chmod +x $CCTR + before_script: + - RAILS_ENV=test bundle exec rake db:bootstrap --trace + - RAILS_ENV=test bundle exec bin/rails webdrivers:chromedriver:update + - $CCTR before-build + script: + - "bin/travis_script.sh $TEST_SUITE" + after_success: + - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.1.json ./coverage/spec/.resultset.json + env: + - TEST_SUITE=ability + workspaces: + create: + name: ws1 + paths: + - coverage/codeclimate.1.json + - <<: *tests + env: + - TEST_SUITE=features + after_success: + - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.2.json ./coverage/spec/.resultset.json + workspaces: + create: + name: ws2 + paths: + - coverage/codeclimate.2.json + - <<: *tests + env: + - TEST_SUITE=models + after_success: + - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.3.json ./coverage/spec/.resultset.json + workspaces: + create: + name: ws3 + paths: + - coverage/codeclimate.3.json + - <<: *tests + env: + - TEST_SUITE=controllers + after_success: + - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.4.json ./coverage/spec/.resultset.json + workspaces: + create: + name: ws4 + paths: + - coverage/codeclimate.4.json + - <<: *tests + env: + - TEST_SUITE=features + after_success: + - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.5.json ./coverage/spec/.resultset.json + workspaces: + create: + name: ws5 + paths: + - coverage/codeclimate.5.json + - stage: finalize + workspaces: + use: + - ws1 + - ws2 + - ws3 + - ws4 + - ws5 + script: $CCTR sum-coverage --output - --parts $TOTAL_TEST_SUITES coverage/codeclimate.*.json | $CCTR upload-coverage --input - From 8f1df20c543b86383087f49444abf079fd9fe303 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 20:41:13 -0700 Subject: [PATCH 27/51] Properly format jobs list --- .travis.yml | 143 ++++++++++++++++++++++++++-------------------------- 1 file changed, 72 insertions(+), 71 deletions(-) diff --git a/.travis.yml b/.travis.yml index 67ce4176..f3edd2a4 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,74 +35,75 @@ env: - CCTR=./cc-test-reporter - TOTAL_TEST_SUITES=5 jobs: - - &tests - before_install: - - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" - - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true - - gem install bundler -v $(tail -n 1 Gemfile.lock) - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $CCTR - - chmod +x $CCTR - before_script: - - RAILS_ENV=test bundle exec rake db:bootstrap --trace - - RAILS_ENV=test bundle exec bin/rails webdrivers:chromedriver:update - - $CCTR before-build - script: - - "bin/travis_script.sh $TEST_SUITE" - after_success: - - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.1.json ./coverage/spec/.resultset.json - env: - - TEST_SUITE=ability - workspaces: - create: - name: ws1 - paths: - - coverage/codeclimate.1.json - - <<: *tests - env: - - TEST_SUITE=features - after_success: - - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.2.json ./coverage/spec/.resultset.json - workspaces: - create: - name: ws2 - paths: - - coverage/codeclimate.2.json - - <<: *tests - env: - - TEST_SUITE=models - after_success: - - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.3.json ./coverage/spec/.resultset.json - workspaces: - create: - name: ws3 - paths: - - coverage/codeclimate.3.json - - <<: *tests - env: - - TEST_SUITE=controllers - after_success: - - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.4.json ./coverage/spec/.resultset.json - workspaces: - create: - name: ws4 - paths: - - coverage/codeclimate.4.json - - <<: *tests - env: - - TEST_SUITE=features - after_success: - - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.5.json ./coverage/spec/.resultset.json - workspaces: - create: - name: ws5 - paths: - - coverage/codeclimate.5.json - - stage: finalize - workspaces: - use: - - ws1 - - ws2 - - ws3 - - ws4 - - ws5 - script: $CCTR sum-coverage --output - --parts $TOTAL_TEST_SUITES coverage/codeclimate.*.json | $CCTR upload-coverage --input - + include: + - &tests + before_install: + - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" + - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true + - gem install bundler -v $(tail -n 1 Gemfile.lock) + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $CCTR + - chmod +x $CCTR + before_script: + - RAILS_ENV=test bundle exec rake db:bootstrap --trace + - RAILS_ENV=test bundle exec bin/rails webdrivers:chromedriver:update + - $CCTR before-build + script: + - "bin/travis_script.sh $TEST_SUITE" + after_success: + - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.1.json ./coverage/spec/.resultset.json + env: + - TEST_SUITE=ability + workspaces: + create: + name: ws1 + paths: + - coverage/codeclimate.1.json + - <<: *tests + env: + - TEST_SUITE=features + after_success: + - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.2.json ./coverage/spec/.resultset.json + workspaces: + create: + name: ws2 + paths: + - coverage/codeclimate.2.json + - <<: *tests + env: + - TEST_SUITE=models + after_success: + - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.3.json ./coverage/spec/.resultset.json + workspaces: + create: + name: ws3 + paths: + - coverage/codeclimate.3.json + - <<: *tests + env: + - TEST_SUITE=controllers + after_success: + - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.4.json ./coverage/spec/.resultset.json + workspaces: + create: + name: ws4 + paths: + - coverage/codeclimate.4.json + - <<: *tests + env: + - TEST_SUITE=features + after_success: + - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.5.json ./coverage/spec/.resultset.json + workspaces: + create: + name: ws5 + paths: + - coverage/codeclimate.5.json + - stage: finalize + workspaces: + use: + - ws1 + - ws2 + - ws3 + - ws4 + - ws5 + script: $CCTR sum-coverage --output - --parts $TOTAL_TEST_SUITES coverage/codeclimate.*.json | $CCTR upload-coverage --input - From 728b6084f91edae5d3d275933afa218ee98b7557 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 16:10:24 -0700 Subject: [PATCH 28/51] Try CodeClimate reporting again --- .travis.yml | 23 ++++++++++++----------- 1 file changed, 12 insertions(+), 11 deletions(-) diff --git a/.travis.yml b/.travis.yml index f3edd2a4..5de44c20 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,9 +48,7 @@ jobs: - RAILS_ENV=test bundle exec bin/rails webdrivers:chromedriver:update - $CCTR before-build script: - - "bin/travis_script.sh $TEST_SUITE" - after_success: - - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.1.json ./coverage/spec/.resultset.json + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.1.json ./coverage/spec/.resultset.json" env: - TEST_SUITE=ability workspaces: @@ -61,8 +59,8 @@ jobs: - <<: *tests env: - TEST_SUITE=features - after_success: - - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.2.json ./coverage/spec/.resultset.json + script: + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.2.json ./coverage/spec/.resultset.json" workspaces: create: name: ws2 @@ -71,8 +69,8 @@ jobs: - <<: *tests env: - TEST_SUITE=models - after_success: - - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.3.json ./coverage/spec/.resultset.json + script: + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.3.json ./coverage/spec/.resultset.json" workspaces: create: name: ws3 @@ -81,8 +79,8 @@ jobs: - <<: *tests env: - TEST_SUITE=controllers - after_success: - - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.4.json ./coverage/spec/.resultset.json + script: + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.4.json ./coverage/spec/.resultset.json" workspaces: create: name: ws4 @@ -91,14 +89,17 @@ jobs: - <<: *tests env: - TEST_SUITE=features - after_success: - - $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.5.json ./coverage/spec/.resultset.json + script: + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.5.json ./coverage/spec/.resultset.json" workspaces: create: name: ws5 paths: - coverage/codeclimate.5.json - stage: finalize + before_install: + - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $CCTR + - chmod +x $CCTR workspaces: use: - ws1 From 1c0b477c1b9c26d91b5703f49adfa6fbe4ef6c2b Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 16:24:01 -0700 Subject: [PATCH 29/51] Try using Cobertura output instead of resultset.json --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index 5de44c20..d65ebe53 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ jobs: - RAILS_ENV=test bundle exec bin/rails webdrivers:chromedriver:update - $CCTR before-build script: - - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.1.json ./coverage/spec/.resultset.json" + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.1.json ./coverage/spec/coverage.xml" env: - TEST_SUITE=ability workspaces: @@ -60,7 +60,7 @@ jobs: env: - TEST_SUITE=features script: - - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.2.json ./coverage/spec/.resultset.json" + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.2.json ./coverage/spec/coverage.xml" workspaces: create: name: ws2 @@ -70,7 +70,7 @@ jobs: env: - TEST_SUITE=models script: - - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.3.json ./coverage/spec/.resultset.json" + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.3.json ./coverage/spec/coverage.xml" workspaces: create: name: ws3 @@ -80,7 +80,7 @@ jobs: env: - TEST_SUITE=controllers script: - - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.4.json ./coverage/spec/.resultset.json" + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.4.json ./coverage/spec/coverage.xml" workspaces: create: name: ws4 @@ -90,7 +90,7 @@ jobs: env: - TEST_SUITE=features script: - - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t simplecov -o ./coverage/codeclimate.5.json ./coverage/spec/.resultset.json" + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.5.json ./coverage/spec/coverage.xml" workspaces: create: name: ws5 From f5b9806aca4e1642725a22ffed07ba4f4a3587c8 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 16:32:45 -0700 Subject: [PATCH 30/51] Correct path to Cobertura output --- .travis.yml | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/.travis.yml b/.travis.yml index d65ebe53..7edccc32 100644 --- a/.travis.yml +++ b/.travis.yml @@ -48,7 +48,7 @@ jobs: - RAILS_ENV=test bundle exec bin/rails webdrivers:chromedriver:update - $CCTR before-build script: - - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.1.json ./coverage/spec/coverage.xml" + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.1.json ./coverage/coverage.xml" env: - TEST_SUITE=ability workspaces: @@ -60,7 +60,7 @@ jobs: env: - TEST_SUITE=features script: - - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.2.json ./coverage/spec/coverage.xml" + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.2.json ./coverage/coverage.xml" workspaces: create: name: ws2 @@ -70,7 +70,7 @@ jobs: env: - TEST_SUITE=models script: - - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.3.json ./coverage/spec/coverage.xml" + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.3.json ./coverage/coverage.xml" workspaces: create: name: ws3 @@ -80,7 +80,7 @@ jobs: env: - TEST_SUITE=controllers script: - - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.4.json ./coverage/spec/coverage.xml" + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.4.json ./coverage/coverage.xml" workspaces: create: name: ws4 @@ -90,7 +90,7 @@ jobs: env: - TEST_SUITE=features script: - - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.5.json ./coverage/spec/coverage.xml" + - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.5.json ./coverage/coverage.xml" workspaces: create: name: ws5 From fb741ca28d25b4de82f469f22204e46eceb57465 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 16:44:38 -0700 Subject: [PATCH 31/51] Restore Code Coverage badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 9d332d36..1a549b45 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### Spring 2021 Student Project [![Build Status](https://travis-ci.com/CactusPuppy/snapcon.svg?branch=master)](https://travis-ci.com/CactusPuppy/snapcon) [![Maintainability](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/maintainability)](https://codeclimate.com/github/CactusPuppy/snapcon/maintainability) -[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/fd87bbd10aff42fb9f0a16755e78968f)](https://www.codacy.com/gh/CactusPuppy/snapcon/dashboard?utm_source=github.com&utm_medium=referral&utm_content=CactusPuppy/snapcon&utm_campaign=Badge_Coverage) +[![Test Coverage](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/test_coverage)](https://codeclimate.com/github/CactusPuppy/snapcon/test_coverage) [![Security Status](https://hakiri.io/github/CactusPuppy/snapcon/master.svg)](https://hakiri.io/github/CactusPuppy/snapcon/master) [![Depfu](https://badges.depfu.com/badges/16eb1ffb3a9f1a36c4e595a5ae2a1dca/overview.svg)](https://depfu.com/github/CactusPuppy/snapcon?project_id=22682) [![Bluejay Dashboard](https://img.shields.io/badge/Bluejay-Dashboard_5-blue.svg)](http://dashboard.bluejay.governify.io/dashboard/script/dashboardLoader.js?dashboardURL=https://reporter.bluejay.governify.io/api/v4/dashboards/tpa-CS169L-GH-CactusPuppy_snapcon/main) From 554f897b27d55d27e5145d0147e2003fed88477e Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 17:16:28 -0700 Subject: [PATCH 32/51] Ensure finalize stage does not have unecessary installation to do --- .travis.yml | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 7edccc32..60fd1b3d 100644 --- a/.travis.yml +++ b/.travis.yml @@ -1,15 +1,5 @@ os: linux dist: bionic -language: ruby -cache: bundler -rvm: - - 2.6.6 -addons: - apt: - packages: - - chromium-browser -services: - - postgresql branches: except: - /^depfu/.*$/ @@ -37,6 +27,16 @@ env: jobs: include: - &tests + language: ruby + cache: bundler + rvm: + - 2.6.6 + addons: + apt: + packages: + - chromium-browser + services: + - postgresql before_install: - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true From 4989b0e4e908cf87ce79e74feed0d71a1ec7feb4 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 17:23:12 -0700 Subject: [PATCH 33/51] Avoid installing Ruby in finalize stage --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index 60fd1b3d..0205ad21 100644 --- a/.travis.yml +++ b/.travis.yml @@ -97,6 +97,7 @@ jobs: paths: - coverage/codeclimate.5.json - stage: finalize + language: minimal before_install: - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $CCTR - chmod +x $CCTR From 89149d53d6c79a43cfad62c98fdc50bd4d1b4b82 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 12 Mar 2021 00:47:29 -0800 Subject: [PATCH 34/51] Switch CodeCov badge to Code Climate badge --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 71f3ac37..1a549b45 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### Spring 2021 Student Project [![Build Status](https://travis-ci.com/CactusPuppy/snapcon.svg?branch=master)](https://travis-ci.com/CactusPuppy/snapcon) [![Maintainability](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/maintainability)](https://codeclimate.com/github/CactusPuppy/snapcon/maintainability) -[![codecov](https://codecov.io/gh/CactusPuppy/snapcon/branch/master/graph/badge.svg?token=y4aEAtw6KJ)](https://codecov.io/gh/CactusPuppy/snapcon) +[![Test Coverage](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/test_coverage)](https://codeclimate.com/github/CactusPuppy/snapcon/test_coverage) [![Security Status](https://hakiri.io/github/CactusPuppy/snapcon/master.svg)](https://hakiri.io/github/CactusPuppy/snapcon/master) [![Depfu](https://badges.depfu.com/badges/16eb1ffb3a9f1a36c4e595a5ae2a1dca/overview.svg)](https://depfu.com/github/CactusPuppy/snapcon?project_id=22682) [![Bluejay Dashboard](https://img.shields.io/badge/Bluejay-Dashboard_5-blue.svg)](http://dashboard.bluejay.governify.io/dashboard/script/dashboardLoader.js?dashboardURL=https://reporter.bluejay.governify.io/api/v4/dashboards/tpa-CS169L-GH-CactusPuppy_snapcon/main) From d8168559beed05923fcefce39c9bf2c99b6eb200 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 14:12:29 -0700 Subject: [PATCH 35/51] Switch to using Codacy for code coverage (following OSEM example) --- .travis.yml | 12 +++--------- README.md | 2 +- 2 files changed, 4 insertions(+), 10 deletions(-) diff --git a/.travis.yml b/.travis.yml index 4e6985a3..d7ddbded 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,8 +16,6 @@ before_install: - "echo 'gem: --no-ri --no-rdoc' > ~/.gemrc" - gem uninstall -v '>= 2' -i $(rvm gemdir)@global -ax bundler || true - gem install bundler -v $(tail -n 1 Gemfile.lock) - - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $CCTR - - chmod +x $CCTR notifications: email: on_success: change @@ -30,15 +28,11 @@ notifications: before_script: - RAILS_ENV=test bundle exec rake db:bootstrap --trace - RAILS_ENV=test bundle exec bin/rails webdrivers:chromedriver:update - - $CCTR before-build + - bash <(curl -Ls https://coverage.codacy.com/get.sh) download script: - "bin/travis_script.sh $TEST_SUITE" - # TODO Get this working. -after_script: - # combine coverage from all suites, and upload3 to CodeClimate - - $CCTR format-coverage -t simplecov --output coverage/codeclimate.$TEST_SUITE.json - - $CCTR sum-coverage coverage/codeclimate.*.json - - if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then $CCTR upload-coverage; fi +after_success: + - - bash <(curl -Ls https://coverage.codacy.com/get.sh) env: global: diff --git a/README.md b/README.md index 1a549b45..9d332d36 100644 --- a/README.md +++ b/README.md @@ -1,7 +1,7 @@ ### Spring 2021 Student Project [![Build Status](https://travis-ci.com/CactusPuppy/snapcon.svg?branch=master)](https://travis-ci.com/CactusPuppy/snapcon) [![Maintainability](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/maintainability)](https://codeclimate.com/github/CactusPuppy/snapcon/maintainability) -[![Test Coverage](https://api.codeclimate.com/v1/badges/6c7fc446b3b10866ba71/test_coverage)](https://codeclimate.com/github/CactusPuppy/snapcon/test_coverage) +[![Codacy Badge](https://app.codacy.com/project/badge/Coverage/fd87bbd10aff42fb9f0a16755e78968f)](https://www.codacy.com/gh/CactusPuppy/snapcon/dashboard?utm_source=github.com&utm_medium=referral&utm_content=CactusPuppy/snapcon&utm_campaign=Badge_Coverage) [![Security Status](https://hakiri.io/github/CactusPuppy/snapcon/master.svg)](https://hakiri.io/github/CactusPuppy/snapcon/master) [![Depfu](https://badges.depfu.com/badges/16eb1ffb3a9f1a36c4e595a5ae2a1dca/overview.svg)](https://depfu.com/github/CactusPuppy/snapcon?project_id=22682) [![Bluejay Dashboard](https://img.shields.io/badge/Bluejay-Dashboard_5-blue.svg)](http://dashboard.bluejay.governify.io/dashboard/script/dashboardLoader.js?dashboardURL=https://reporter.bluejay.governify.io/api/v4/dashboards/tpa-CS169L-GH-CactusPuppy_snapcon/main) From 3b768dda4bb12d8682222b3dd7fc557059023bed Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 14:25:43 -0700 Subject: [PATCH 36/51] Specify where the coverage report is --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index d7ddbded..c03f8287 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ before_script: script: - "bin/travis_script.sh $TEST_SUITE" after_success: - - - bash <(curl -Ls https://coverage.codacy.com/get.sh) + - - bash <(curl -Ls https://coverage.codacy.com/get.sh) -r coverage/coverage.xml env: global: From c4e07e858f6cad810c132eca1c363aa7c09e219d Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 14:27:25 -0700 Subject: [PATCH 37/51] Fix minor typo in .travis.yml --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index c03f8287..789439ef 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,7 @@ before_script: script: - "bin/travis_script.sh $TEST_SUITE" after_success: - - - bash <(curl -Ls https://coverage.codacy.com/get.sh) -r coverage/coverage.xml + - bash <(curl -Ls https://coverage.codacy.com/get.sh) -r coverage/coverage.xml env: global: From 9ad9a24d74be4a03485c11de1649143005de55ed Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 15:50:37 -0700 Subject: [PATCH 38/51] Actually properly report parallel stages --- .travis.yml | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index 789439ef..d95e947c 100644 --- a/.travis.yml +++ b/.travis.yml @@ -32,7 +32,12 @@ before_script: script: - "bin/travis_script.sh $TEST_SUITE" after_success: - - bash <(curl -Ls https://coverage.codacy.com/get.sh) -r coverage/coverage.xml + - bash <(curl -Ls https://coverage.codacy.com/get.sh) report --partial -l Ruby -r coverage/coverage.xml + +jobs: + include: + - stage: finalize + script: bash <(curl -Ls https://coverage.codacy.com/get.sh) final env: global: @@ -40,8 +45,6 @@ env: - OSEM_DB_HOST='' - OSEM_DB_PORT='' - OSEM_DB_NAME='osem_test' - - CC_TEST_REPORTER_ID=$CC_TEST_REPORTER - - CCTR=./cc-test-reporter matrix: - TEST_SUITE=ability - TEST_SUITE=features From 2e9150887e55b4a4e9f19a09540c95d4493046a1 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 15:56:50 -0700 Subject: [PATCH 39/51] Prevent overwriting of jobs by matrix --- .travis.yml | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/.travis.yml b/.travis.yml index d95e947c..4991fea1 100644 --- a/.travis.yml +++ b/.travis.yml @@ -35,6 +35,7 @@ after_success: - bash <(curl -Ls https://coverage.codacy.com/get.sh) report --partial -l Ruby -r coverage/coverage.xml jobs: + fast_finish: false include: - stage: finalize script: bash <(curl -Ls https://coverage.codacy.com/get.sh) final @@ -45,11 +46,9 @@ env: - OSEM_DB_HOST='' - OSEM_DB_PORT='' - OSEM_DB_NAME='osem_test' - matrix: + jobs: - TEST_SUITE=ability - TEST_SUITE=features - TEST_SUITE=models - TEST_SUITE=controllers - TEST_SUITE=rest -matrix: - fast_finish: false From 039a931c901a473e5ab247591f6b5998f8860b1e Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Wed, 17 Mar 2021 16:14:33 -0700 Subject: [PATCH 40/51] Ensure coverage.xml is generated on Travis --- spec/spec_helper.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb index d3e17427..2d680fb2 100644 --- a/spec/spec_helper.rb +++ b/spec/spec_helper.rb @@ -3,7 +3,7 @@ # This file is copied to spec/ when you run 'rails generate rspec:install' require 'simplecov' -if ENV['GITHUB_ACTIONS'] +if ENV['GITHUB_ACTIONS'] || ENV['TRAVIS'] require 'simplecov-cobertura' SimpleCov.formatter = SimpleCov::Formatter::CoberturaFormatter end From ee8de1ce2d0e08c7e4ac2ee544621069ac25269b Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 20:31:40 -0700 Subject: [PATCH 41/51] Temp pend failing test, as it does not reflect local verification --- spec/features/proposals_spec.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 18297d2d..2c9fff09 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -193,6 +193,7 @@ feature Event do end scenario 'can reset to text template', feature: true, js: true do + skip('Something with Selenium or Capybara is not picking up the JavaScript popup modal. Must investigate further.') event_type = conference.program.event_types[-1] event_type.description = 'Example event description' event_type.save! From 652381a0b8dd9b44432da02b96307c9e7b2e85c0 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 20:36:39 -0700 Subject: [PATCH 42/51] Update annotate_models comments --- app/models/event.rb | 1 - app/serializers/event_serializer.rb | 1 - spec/factories/events.rb | 1 - spec/models/event_spec.rb | 1 - spec/serializers/event_serializer_spec.rb | 1 - 5 files changed, 5 deletions(-) diff --git a/app/models/event.rb b/app/models/event.rb index d10ae1a1..ba04ba20 100644 --- a/app/models/event.rb +++ b/app/models/event.rb @@ -7,7 +7,6 @@ # id :bigint not null, primary key # abstract :text # comments_count :integer default(0), not null -# committee_review :text # description :text # guid :string not null # is_highlight :boolean default(FALSE) diff --git a/app/serializers/event_serializer.rb b/app/serializers/event_serializer.rb index 9bf196f2..8c30b1a1 100644 --- a/app/serializers/event_serializer.rb +++ b/app/serializers/event_serializer.rb @@ -7,7 +7,6 @@ # id :bigint not null, primary key # abstract :text # comments_count :integer default(0), not null -# committee_review :text # description :text # guid :string not null # is_highlight :boolean default(FALSE) diff --git a/spec/factories/events.rb b/spec/factories/events.rb index 2f68c311..c8360449 100644 --- a/spec/factories/events.rb +++ b/spec/factories/events.rb @@ -7,7 +7,6 @@ # id :bigint not null, primary key # abstract :text # comments_count :integer default(0), not null -# committee_review :text # description :text # guid :string not null # is_highlight :boolean default(FALSE) diff --git a/spec/models/event_spec.rb b/spec/models/event_spec.rb index 030ad382..2beb3a20 100644 --- a/spec/models/event_spec.rb +++ b/spec/models/event_spec.rb @@ -7,7 +7,6 @@ # id :bigint not null, primary key # abstract :text # comments_count :integer default(0), not null -# committee_review :text # description :text # guid :string not null # is_highlight :boolean default(FALSE) diff --git a/spec/serializers/event_serializer_spec.rb b/spec/serializers/event_serializer_spec.rb index 3ad68cad..506134cf 100644 --- a/spec/serializers/event_serializer_spec.rb +++ b/spec/serializers/event_serializer_spec.rb @@ -7,7 +7,6 @@ # id :bigint not null, primary key # abstract :text # comments_count :integer default(0), not null -# committee_review :text # description :text # guid :string not null # is_highlight :boolean default(FALSE) From 4fbe48692e87047deba26eeccb1c18e7fd613eee Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 23:01:24 -0700 Subject: [PATCH 43/51] Actually run rest tests instead of features twice --- .travis.yml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 0205ad21..e3cd9f9a 100644 --- a/.travis.yml +++ b/.travis.yml @@ -88,7 +88,7 @@ jobs: - coverage/codeclimate.4.json - <<: *tests env: - - TEST_SUITE=features + - TEST_SUITE=rest script: - "bin/travis_script.sh $TEST_SUITE && $CCTR format-coverage -t cobertura -o ./coverage/codeclimate.5.json ./coverage/coverage.xml" workspaces: From e51dcc6d0551584fee1b84254afc49cdd7ec53ae Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 23:01:54 -0700 Subject: [PATCH 44/51] Pend test so that error is exposed instead of skipping --- spec/features/proposals_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 2c9fff09..df56a572 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -193,7 +193,7 @@ feature Event do end scenario 'can reset to text template', feature: true, js: true do - skip('Something with Selenium or Capybara is not picking up the JavaScript popup modal. Must investigate further.') + pending('Something with Selenium or Capybara is not picking up the JavaScript popup modal. Must investigate further.') event_type = conference.program.event_types[-1] event_type.description = 'Example event description' event_type.save! From 9167f2f2e69dedaefa787220311cd24128ff0a75 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 23:21:51 -0700 Subject: [PATCH 45/51] Unpend test because I guess it works on Travis --- spec/features/proposals_spec.rb | 1 - 1 file changed, 1 deletion(-) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index df56a572..18297d2d 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -193,7 +193,6 @@ feature Event do end scenario 'can reset to text template', feature: true, js: true do - pending('Something with Selenium or Capybara is not picking up the JavaScript popup modal. Must investigate further.') event_type = conference.program.event_types[-1] event_type.description = 'Example event description' event_type.save! From 8b7f0551aefc41564e300522130f37ea95a6be9a Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 18 Mar 2021 23:48:06 -0700 Subject: [PATCH 46/51] Only upload coverage reports from Travis if based in master --- .travis.yml | 1 + 1 file changed, 1 insertion(+) diff --git a/.travis.yml b/.travis.yml index e3cd9f9a..b35784c6 100644 --- a/.travis.yml +++ b/.travis.yml @@ -97,6 +97,7 @@ jobs: paths: - coverage/codeclimate.5.json - stage: finalize + if: branch = master language: minimal before_install: - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $CCTR From 8adc70ffa8380f7d68bd2e651f393b538811922e Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 19 Mar 2021 00:31:14 -0700 Subject: [PATCH 47/51] Ensure sqlite isn't trying to be loaded on Heroku --- Gemfile | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Gemfile b/Gemfile index 97bf9ba6..87a01972 100644 --- a/Gemfile +++ b/Gemfile @@ -280,6 +280,9 @@ group :development, :test, :linters do gem 'rubocop-rspec', require: false gem 'haml-lint', require: false +end + +group :development, :test do # as development/test database gem 'sqlite3' end From f5a8587b4cded2577f81692ae84302d5b2041c19 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 19 Mar 2021 01:16:43 -0700 Subject: [PATCH 48/51] Avoid using ES6 syntax to prevent Heroku asset compilation from failing --- app/assets/javascripts/osem.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index 636ed959..30993bd7 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -148,7 +148,7 @@ function word_count(text, divId, maxcount) { }; function fill_if_empty(text_area, filler) { - let area = $('#' + text_area); + var area = $('#' + text_area); if (!area.val()) { area.val(filler); @@ -192,11 +192,11 @@ $( document ).ready(function() { /* Listen for reset template button, wait for confirm, and reset. */ $('#sub_text_reset').click((e) => { - let $selected = $("#event_event_type_id option:selected"); - let $this = $(e.target); - let affirm = confirm($this.data('confirm')); + var $selected = $("#event_event_type_id option:selected"); + var $this = $(e.target); + var affirm = confirm($this.data('confirm')); if (affirm) { - let sub_text = $('#event_submission_text'); + var sub_text = $('#event_submission_text'); sub_text.val($selected.data('help')); sub_text.trigger('change'); } From 28e45d6162e08047913b4c281ac0482723af36a6 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 19 Mar 2021 01:21:26 -0700 Subject: [PATCH 49/51] Revert "Avoid using ES6 syntax to prevent Heroku asset compilation from failing" This reverts commit f5a8587b4cded2577f81692ae84302d5b2041c19. --- app/assets/javascripts/osem.js | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index 30993bd7..636ed959 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -148,7 +148,7 @@ function word_count(text, divId, maxcount) { }; function fill_if_empty(text_area, filler) { - var area = $('#' + text_area); + let area = $('#' + text_area); if (!area.val()) { area.val(filler); @@ -192,11 +192,11 @@ $( document ).ready(function() { /* Listen for reset template button, wait for confirm, and reset. */ $('#sub_text_reset').click((e) => { - var $selected = $("#event_event_type_id option:selected"); - var $this = $(e.target); - var affirm = confirm($this.data('confirm')); + let $selected = $("#event_event_type_id option:selected"); + let $this = $(e.target); + let affirm = confirm($this.data('confirm')); if (affirm) { - var sub_text = $('#event_submission_text'); + let sub_text = $('#event_submission_text'); sub_text.val($selected.data('help')); sub_text.trigger('change'); } From 33af94baddc14d8cc3f92e06f211753b72d7f8a7 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 19 Mar 2021 01:22:22 -0700 Subject: [PATCH 50/51] Allow ES6 JS syntax --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 536a8aef..3893e77c 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -26,7 +26,7 @@ Osem::Application.configure do config.assets.digest = true config.assets.css_compressor = :sass - config.assets.js_compressor = :uglifier + config.assets.js_compressor = Uglifier.new(:harmony => true) config.assets.gzip = true # Defaults to nil and saved in location specified by config.assets.prefix From 8110d06ca7f9fa5ec52c67acaa390b0d03eaaad4 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 19 Mar 2021 01:26:53 -0700 Subject: [PATCH 51/51] Fix Rubocop linting issue --- config/environments/production.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/environments/production.rb b/config/environments/production.rb index 3893e77c..d41774af 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -26,7 +26,7 @@ Osem::Application.configure do config.assets.digest = true config.assets.css_compressor = :sass - config.assets.js_compressor = Uglifier.new(:harmony => true) + config.assets.js_compressor = Uglifier.new(harmony: true) config.assets.gzip = true # Defaults to nil and saved in location specified by config.assets.prefix