From abe017fc4e2d3a01b1c441120759fb5e16396725 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Tue, 2 Mar 2021 15:09:34 -0800 Subject: [PATCH 01/99] Make 'all' option actually fire all rspec tests --- travis_script.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/travis_script.sh b/travis_script.sh index 3f4f52cf..57ca8aa5 100755 --- a/travis_script.sh +++ b/travis_script.sh @@ -15,20 +15,20 @@ case $TEST_SUITE in linters) bundle exec rubocop -Dc .rubocop.yml bundle exec haml-lint app/views - ;; - models) + ;;& + models|all) bundle exec rspec --format documentation spec/models - ;; - features) + ;;& + features|all) bundle exec rspec --format documentation spec/features - ;; - controllers) + ;;& + controllers|all) bundle exec rspec --format documentation spec/controllers - ;; - ability) + ;;& + ability|all) bundle exec rspec --format documentation spec/ability - ;; - rest) + ;;& + rest|all) bundle exec rspec --format documentation --exclude-pattern "spec/{models,features,controllers,ability}/**/*_spec.rb" ;; esac From 5e0848ef4e92e032ee7bf1eac9ae0b638453703d Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 3 Mar 2021 06:04:48 +0000 Subject: [PATCH 02/99] Update cocoon to version 1.2.15 --- Gemfile.lock | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile.lock b/Gemfile.lock index b07d289e..c963a368 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -126,7 +126,7 @@ GEM cloudinary (1.11.1) aws_cf_signer rest-client - cocoon (1.2.14) + cocoon (1.2.15) codecov (0.5.0) simplecov (>= 0.15, < 0.22) coderay (1.1.1) From 3f7f5b6bf4d122e98c8c9bacb869b296865186b4 Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Wed, 3 Mar 2021 13:06:38 -0800 Subject: [PATCH 03/99] change to conditions --- app/controllers/ticket_purchases_controller.rb | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 1a1bc449..e165cd78 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -8,19 +8,20 @@ class TicketPurchasesController < ApplicationController def create current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all + if current_user.ticket_purchases.by_conference(@conference).paid.any? + redirect_to conference_physical_tickets_path, + notice: 'You already have tickets for the conference.' + end message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first)) if message.blank? if current_user.ticket_purchases.by_conference(@conference).unpaid.any? redirect_to new_conference_payment_path, notice: 'Please pay here to get tickets.' - elsif current_user.ticket_purchases.by_conference(@conference).paid.any? - redirect_to conference_physical_tickets_path, - notice: 'You already have tickets for the conference.' elsif @conference.tickets.for_registration.any? redirect_to conference_tickets_path(@conference.short_title), error: 'Please get at least one ticket to continue.' else - redirect_to conference_conference_registration_path(@conference.short_title) + redirect_to new_conference_conference_registration_path(@conference.short_title) end else redirect_to conference_tickets_path(@conference.short_title), From 48a689d4522695ba0061e57cc68f9ba2ebc9c624 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 3 Mar 2021 13:29:54 -0800 Subject: [PATCH 04/99] temp --- .../ticket_purchases_controller.rb | 49 ++++++++++++++----- 1 file changed, 36 insertions(+), 13 deletions(-) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index e165cd78..4cbfeac2 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -8,25 +8,48 @@ class TicketPurchasesController < ApplicationController def create current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all + + # Create a ticket purchase which can be paid or unpaid + message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first)) + + # Failed to create ticket purchase + if !message.blank? + redirect_to conference_tickets_path(@conference.short_title), + error: "Oops, something went wrong with your purchase! #{message}" + return + end + + # Ticket purchase created but not paid + if current_user.ticket_purchases.by_conference(@conference).unpaid.any? + redirect_to new_conference_payment_path, + notice: 'Please pay here to get tickets.' + return + end + + # TODO: User already paid for a registration ticket and ticket purchase contains one + # BUG: When the ticket is free, user will see the notice after they click `Continue` + + # Two types of ticket? + + # TODO: Need to check if current_user.ticket_purchases.by_conference(@conference).paid.any? redirect_to conference_physical_tickets_path, notice: 'You already have tickets for the conference.' + return end - message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first)) - if message.blank? - if current_user.ticket_purchases.by_conference(@conference).unpaid.any? - redirect_to new_conference_payment_path, - notice: 'Please pay here to get tickets.' - elsif @conference.tickets.for_registration.any? - redirect_to conference_tickets_path(@conference.short_title), - error: 'Please get at least one ticket to continue.' - else - redirect_to new_conference_conference_registration_path(@conference.short_title) - end - else + + # TODO: User wants to purchase a non-registration ticket but does not have a registration ticket but conference requires one + # BUG: When the user only purchases a non-registration ticket, + if @conference.registration_ticket_required? redirect_to conference_tickets_path(@conference.short_title), - error: "Oops, something went wrong with your purchase! #{message}" + error: 'Please get at least one ticket to continue.' + return end + + # TODO: Need to check if the current user didn't a registration ticket and is purchasing one + redirect_to new_conference_conference_registration_path(@conference.short_title) + # # otherwise + # redirect_to conference_physical_tickets_path end def index From 8c230352f919a7f1a9e7a7305fdc3d5f0c01c8bb Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Wed, 3 Mar 2021 13:58:36 -0800 Subject: [PATCH 05/99] added more conditions --- .../ticket_purchases_controller.rb | 34 ++++++++++++++----- 1 file changed, 26 insertions(+), 8 deletions(-) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 4cbfeac2..bb60d00f 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -29,24 +29,42 @@ class TicketPurchasesController < ApplicationController # TODO: User already paid for a registration ticket and ticket purchase contains one # BUG: When the ticket is free, user will see the notice after they click `Continue` - # Two types of ticket? + # this works? maybe # TODO: Need to check if current_user.ticket_purchases.by_conference(@conference).paid.any? - redirect_to conference_physical_tickets_path, - notice: 'You already have tickets for the conference.' - return + for ticket_purchase in current_user.ticket_purchases.by_conference(@conference) + if ticket_purchase.paid? + for physical_ticket in ticket_purchase.physical_tickets + if physical_ticket.ticket.registration_ticket? + redirect_to conference_physical_tickets_path, + notice: 'You already have tickets for the conference.' + return + end + end + end end # TODO: User wants to purchase a non-registration ticket but does not have a registration ticket but conference requires one # BUG: When the user only purchases a non-registration ticket, if @conference.registration_ticket_required? - redirect_to conference_tickets_path(@conference.short_title), - error: 'Please get at least one ticket to continue.' - return + seen_registration = false + for ticket_purchase in current_user.ticket_purchases.by_conference(@conference) + for physical_ticket in ticket_purchase.physical_tickets + if physical_ticket.ticket.registration_ticket + seen = true + break + end + end + end + if !seen + redirect_to conference_tickets_path(@conference.short_title), + error: 'Please get at least one registration ticket to continue.' + return + end end - # TODO: Need to check if the current user didn't a registration ticket and is purchasing one + # TODO: Need to check if the current user didn't have a registration ticket and is purchasing one redirect_to new_conference_conference_registration_path(@conference.short_title) # # otherwise # redirect_to conference_physical_tickets_path From c1fe73df03dc6c24b066ed24438fe8987864f250 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 4 Mar 2021 11:33:27 -0800 Subject: [PATCH 06/99] temp --- .../ticket_purchases_controller.rb | 33 +++++++++++-------- app/models/ticket_purchase.rb | 5 +++ app/models/user.rb | 14 ++++++++ 3 files changed, 38 insertions(+), 14 deletions(-) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index bb60d00f..32d04b4b 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -11,6 +11,7 @@ class TicketPurchasesController < ApplicationController # Create a ticket purchase which can be paid or unpaid message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first)) + current_ticket_purchase = ? # Failed to create ticket purchase if !message.blank? @@ -32,7 +33,14 @@ class TicketPurchasesController < ApplicationController # this works? maybe # TODO: Need to check + + # user has a registration ticket + # current_user.tickets.for_registration(@conference).present? + + # current ticket purchase if current_user.ticket_purchases.by_conference(@conference).paid.any? + && current_user.has_registration_ticket_for?(@conference) == true + end for ticket_purchase in current_user.ticket_purchases.by_conference(@conference) if ticket_purchase.paid? for physical_ticket in ticket_purchase.physical_tickets @@ -47,17 +55,8 @@ class TicketPurchasesController < ApplicationController # TODO: User wants to purchase a non-registration ticket but does not have a registration ticket but conference requires one # BUG: When the user only purchases a non-registration ticket, - if @conference.registration_ticket_required? - seen_registration = false - for ticket_purchase in current_user.ticket_purchases.by_conference(@conference) - for physical_ticket in ticket_purchase.physical_tickets - if physical_ticket.ticket.registration_ticket - seen = true - break - end - end - end - if !seen + if @conference.registration_ticket_required? + && current_user.has_registration_ticket_for?(@conference) == false redirect_to conference_tickets_path(@conference.short_title), error: 'Please get at least one registration ticket to continue.' return @@ -65,9 +64,15 @@ class TicketPurchasesController < ApplicationController end # TODO: Need to check if the current user didn't have a registration ticket and is purchasing one - redirect_to new_conference_conference_registration_path(@conference.short_title) - # # otherwise - # redirect_to conference_physical_tickets_path + if current_user.tickets.for_registration(@conference).nil? + if current_user.has_registration_ticket_for?(@conference) == true + redirect_to new_conference_conference_registration_path(@conference.short_title) + else + redirect_to conference_physical_tickets_path + end + else + redirect_to conference_physical_tickets_path + end end def index diff --git a/app/models/ticket_purchase.rb b/app/models/ticket_purchase.rb index 46a5befe..74266d91 100644 --- a/app/models/ticket_purchase.rb +++ b/app/models/ticket_purchase.rb @@ -110,6 +110,11 @@ class TicketPurchase < ApplicationRecord errors.add(:quantity, 'cannot be greater than one for registration tickets.') end end + + # def has_registration_ticket_for?(conference) + # # BUG: ticket_purchase has only one ticket? + # ticket.try(:registration_ticket?) + # end end private diff --git a/app/models/user.rb b/app/models/user.rb index 9bd1bf80..782e82e3 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -346,6 +346,20 @@ class User < ApplicationRecord events.where(program_id: conference.program.id, 'event_users.event_role': 'volunteer') end + def has_registration_ticket_for?(conference) + seen_registration = false + for ticket_purchase in current_user.ticket_purchases.by_conference(@conference) + for physical_ticket in ticket_purchase.physical_tickets + if physical_ticket.ticket.registration_ticket + seen_registration = true + break + end + end + end + + return seen_registration + end + def self.empty? User.count == 1 && User.first.email == 'deleted@localhost.osem' end From 7e37b52e20032d0ebeb0082e32c16bd4cd5d34df Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 4 Mar 2021 11:37:16 -0800 Subject: [PATCH 07/99] temp --- app/controllers/ticket_purchases_controller.rb | 1 + 1 file changed, 1 insertion(+) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 32d04b4b..8362510c 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -11,6 +11,7 @@ class TicketPurchasesController < ApplicationController # Create a ticket purchase which can be paid or unpaid message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first)) + # The new ticket_purchase has been added to the database. current_user.ticket_purchases contains the new one. current_ticket_purchase = ? # Failed to create ticket purchase From b72dfdabf84d727ecc214b0799b45470d288a04b Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Thu, 4 Mar 2021 11:55:45 -0800 Subject: [PATCH 08/99] conditions completed --- .../ticket_purchases_controller.rb | 61 ++++++------------- app/models/user.rb | 9 ++- 2 files changed, 23 insertions(+), 47 deletions(-) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 8362510c..90b0c484 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -10,10 +10,11 @@ class TicketPurchasesController < ApplicationController current_user.ticket_purchases.by_conference(@conference).unpaid.destroy_all # Create a ticket purchase which can be paid or unpaid + count_registration_tickets_before = current_user.count_registration_tickets(@conference) message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first)) # The new ticket_purchase has been added to the database. current_user.ticket_purchases contains the new one. - current_ticket_purchase = ? - + count_registration_tickets_after = current_user.count_registration_tickets(@conference) + # Failed to create ticket purchase if !message.blank? redirect_to conference_tickets_path(@conference.short_title), @@ -28,52 +29,28 @@ class TicketPurchasesController < ApplicationController return end - # TODO: User already paid for a registration ticket and ticket purchase contains one - # BUG: When the ticket is free, user will see the notice after they click `Continue` - - # this works? maybe - - # TODO: Need to check - - # user has a registration ticket - # current_user.tickets.for_registration(@conference).present? - - # current ticket purchase - if current_user.ticket_purchases.by_conference(@conference).paid.any? - && current_user.has_registration_ticket_for?(@conference) == true - end - for ticket_purchase in current_user.ticket_purchases.by_conference(@conference) - if ticket_purchase.paid? - for physical_ticket in ticket_purchase.physical_tickets - if physical_ticket.ticket.registration_ticket? - redirect_to conference_physical_tickets_path, - notice: 'You already have tickets for the conference.' - return - end - end - end + # Current user already paid for a registration ticket and the current ticket purchase contains one + if count_registration_tickets_before == 1 && count_registration_tickets_after > 1 + redirect_to conference_physical_tickets_path, + notice: 'You already have tickets for the conference.' + return end - # TODO: User wants to purchase a non-registration ticket but does not have a registration ticket but conference requires one - # BUG: When the user only purchases a non-registration ticket, - if @conference.registration_ticket_required? - && current_user.has_registration_ticket_for?(@conference) == false - redirect_to conference_tickets_path(@conference.short_title), - error: 'Please get at least one registration ticket to continue.' - return - end + # Conference requires a registration ticket but the current user wants to purchase a non-registration ticket + # and does not have a registration ticket + if @conference.registration_ticket_required? && count_registration_tickets_after == 0 + redirect_to conference_tickets_path(@conference.short_title), + error: 'Please get at least one registration ticket to continue.' + return end - # TODO: Need to check if the current user didn't have a registration ticket and is purchasing one - if current_user.tickets.for_registration(@conference).nil? - if current_user.has_registration_ticket_for?(@conference) == true - redirect_to new_conference_conference_registration_path(@conference.short_title) - else - redirect_to conference_physical_tickets_path - end + # Current user didn't have a registration ticket and is purchasing one + if count_registration_tickets_before == 0 && count_registration_tickets_after == 1 + redirect_to new_conference_conference_registration_path(@conference.short_title) + else redirect_to conference_physical_tickets_path - end + end end def index diff --git a/app/models/user.rb b/app/models/user.rb index 782e82e3..d5281b8e 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -346,18 +346,17 @@ class User < ApplicationRecord events.where(program_id: conference.program.id, 'event_users.event_role': 'volunteer') end - def has_registration_ticket_for?(conference) - seen_registration = false + def count_registration_tickets(conference) + count = 0 for ticket_purchase in current_user.ticket_purchases.by_conference(@conference) for physical_ticket in ticket_purchase.physical_tickets if physical_ticket.ticket.registration_ticket - seen_registration = true - break + count += 1 end end end - return seen_registration + return count end def self.empty? From 189c2ec75f03ebc09ae89a1decd6ae3e01a497b5 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 4 Mar 2021 15:34:06 -0800 Subject: [PATCH 09/99] [fix] Fix user.count_registration_tickets --- app/controllers/ticket_purchases_controller.rb | 1 - app/models/user.rb | 2 +- 2 files changed, 1 insertion(+), 2 deletions(-) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 90b0c484..60ea5b98 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -47,7 +47,6 @@ class TicketPurchasesController < ApplicationController # Current user didn't have a registration ticket and is purchasing one if count_registration_tickets_before == 0 && count_registration_tickets_after == 1 redirect_to new_conference_conference_registration_path(@conference.short_title) - else redirect_to conference_physical_tickets_path end diff --git a/app/models/user.rb b/app/models/user.rb index d5281b8e..bb68fc0d 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -348,7 +348,7 @@ class User < ApplicationRecord def count_registration_tickets(conference) count = 0 - for ticket_purchase in current_user.ticket_purchases.by_conference(@conference) + for ticket_purchase in ticket_purchases.by_conference(conference) for physical_ticket in ticket_purchase.physical_tickets if physical_ticket.ticket.registration_ticket count += 1 From 7d7046254285f9dfe5ac61d33f6f960a19c75570 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 4 Mar 2021 15:47:48 -0800 Subject: [PATCH 10/99] [refactor] Clean up unused code --- app/controllers/ticket_purchases_controller.rb | 6 +++--- app/models/ticket_purchase.rb | 5 ----- 2 files changed, 3 insertions(+), 8 deletions(-) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 60ea5b98..83c53ad0 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -41,15 +41,15 @@ class TicketPurchasesController < ApplicationController if @conference.registration_ticket_required? && count_registration_tickets_after == 0 redirect_to conference_tickets_path(@conference.short_title), error: 'Please get at least one registration ticket to continue.' - return + return end # Current user didn't have a registration ticket and is purchasing one if count_registration_tickets_before == 0 && count_registration_tickets_after == 1 redirect_to new_conference_conference_registration_path(@conference.short_title) - else + else redirect_to conference_physical_tickets_path - end + end end def index diff --git a/app/models/ticket_purchase.rb b/app/models/ticket_purchase.rb index 74266d91..46a5befe 100644 --- a/app/models/ticket_purchase.rb +++ b/app/models/ticket_purchase.rb @@ -110,11 +110,6 @@ class TicketPurchase < ApplicationRecord errors.add(:quantity, 'cannot be greater than one for registration tickets.') end end - - # def has_registration_ticket_for?(conference) - # # BUG: ticket_purchase has only one ticket? - # ticket.try(:registration_ticket?) - # end end private From a599980046eb52483e52ac832ee82eac795508ea Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 4 Mar 2021 16:32:36 -0800 Subject: [PATCH 11/99] [fix] Fix check for non-free tickets --- app/controllers/ticket_purchases_controller.rb | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 83c53ad0..e8b33fb0 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -22,13 +22,6 @@ class TicketPurchasesController < ApplicationController return end - # Ticket purchase created but not paid - if current_user.ticket_purchases.by_conference(@conference).unpaid.any? - redirect_to new_conference_payment_path, - notice: 'Please pay here to get tickets.' - return - end - # Current user already paid for a registration ticket and the current ticket purchase contains one if count_registration_tickets_before == 1 && count_registration_tickets_after > 1 redirect_to conference_physical_tickets_path, @@ -44,10 +37,17 @@ class TicketPurchasesController < ApplicationController return end + # Ticket purchase created but not paid + if current_user.ticket_purchases.by_conference(@conference).unpaid.any? + redirect_to new_conference_payment_path, + notice: 'Please pay here to get tickets.' + return + end + # Current user didn't have a registration ticket and is purchasing one if count_registration_tickets_before == 0 && count_registration_tickets_after == 1 redirect_to new_conference_conference_registration_path(@conference.short_title) - else + else redirect_to conference_physical_tickets_path end end From 1ca58961c1501db878eb37dcd61432566820c649 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 4 Mar 2021 16:34:47 -0800 Subject: [PATCH 12/99] [style] Rubocop --- app/controllers/ticket_purchases_controller.rb | 14 +++++++------- app/models/user.rb | 6 +++--- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index e8b33fb0..865459f4 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -14,9 +14,9 @@ class TicketPurchasesController < ApplicationController message = TicketPurchase.purchase(@conference, current_user, params[:tickets].try(:first)) # The new ticket_purchase has been added to the database. current_user.ticket_purchases contains the new one. count_registration_tickets_after = current_user.count_registration_tickets(@conference) - + # Failed to create ticket purchase - if !message.blank? + unless message.blank? redirect_to conference_tickets_path(@conference.short_title), error: "Oops, something went wrong with your purchase! #{message}" return @@ -25,15 +25,15 @@ class TicketPurchasesController < ApplicationController # Current user already paid for a registration ticket and the current ticket purchase contains one if count_registration_tickets_before == 1 && count_registration_tickets_after > 1 redirect_to conference_physical_tickets_path, - notice: 'You already have tickets for the conference.' + notice: 'You already have tickets for the conference.' return end - # Conference requires a registration ticket but the current user wants to purchase a non-registration ticket - # and does not have a registration ticket + # Conference requires a registration ticket but the current user wants to purchase a non-registration ticket + # and does not have a registration ticket if @conference.registration_ticket_required? && count_registration_tickets_after == 0 redirect_to conference_tickets_path(@conference.short_title), - error: 'Please get at least one registration ticket to continue.' + error: 'Please get at least one registration ticket to continue.' return end @@ -47,7 +47,7 @@ class TicketPurchasesController < ApplicationController # Current user didn't have a registration ticket and is purchasing one if count_registration_tickets_before == 0 && count_registration_tickets_after == 1 redirect_to new_conference_conference_registration_path(@conference.short_title) - else + else redirect_to conference_physical_tickets_path end end diff --git a/app/models/user.rb b/app/models/user.rb index bb68fc0d..85584955 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -348,15 +348,15 @@ class User < ApplicationRecord def count_registration_tickets(conference) count = 0 - for ticket_purchase in ticket_purchases.by_conference(conference) - for physical_ticket in ticket_purchase.physical_tickets + ticket_purchases.by_conference(conference).each do |ticket_purchase| + ticket_purchase.physical_tickets.each do |physical_ticket| if physical_ticket.ticket.registration_ticket count += 1 end end end - return count + count end def self.empty? From da8939dd3a4c8373d62c3c2c072384331f1bf64d Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 4 Mar 2021 21:50:26 -0800 Subject: [PATCH 13/99] [feat] remove unintended check; add auto-redirect to non-free ticket --- app/controllers/payments_controller.rb | 14 +++++++++-- .../ticket_purchases_controller.rb | 23 ++++++++----------- app/models/user.rb | 6 ++--- app/views/payments/_payment.html.haml | 2 +- 4 files changed, 24 insertions(+), 21 deletions(-) diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index 5dae6d19..d2317bbc 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -16,6 +16,7 @@ class PaymentsController < ApplicationController raise CanCan::AccessDenied.new('Nothing to pay for!', :new, Payment) end + @has_registration_ticket = params[:has_registration_ticket] @unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference) end @@ -24,8 +25,17 @@ class PaymentsController < ApplicationController if @payment.purchase && @payment.save update_purchased_ticket_purchases - redirect_to conference_physical_tickets_path, - notice: 'Thanks! Your ticket is booked successfully.' + + has_registration_ticket = params[:has_registration_ticket] + if has_registration_ticket.present? && has_registration_ticket == 'true' + redirect_to new_conference_conference_registration_path(@conference.short_title), + notice: 'Thanks! Your ticket is booked successfully. Please register for the conference.' + else + redirect_to conference_physical_tickets_path, + notice: 'Thanks! Your ticket is booked successfully.' + end + + @has_registration_ticket = nil else @total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false) @unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 865459f4..58e32feb 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -25,30 +25,25 @@ class TicketPurchasesController < ApplicationController # Current user already paid for a registration ticket and the current ticket purchase contains one if count_registration_tickets_before == 1 && count_registration_tickets_after > 1 redirect_to conference_physical_tickets_path, - notice: 'You already have tickets for the conference.' + error: 'You already have one registration ticket for the conference.' return end - # Conference requires a registration ticket but the current user wants to purchase a non-registration ticket - # and does not have a registration ticket - if @conference.registration_ticket_required? && count_registration_tickets_after == 0 - redirect_to conference_tickets_path(@conference.short_title), - error: 'Please get at least one registration ticket to continue.' - return - end - - # Ticket purchase created but not paid + # User needs to pay for tickets if any of them is not free. if current_user.ticket_purchases.by_conference(@conference).unpaid.any? - redirect_to new_conference_payment_path, + has_registration_ticket = count_registration_tickets_before == 0 && count_registration_tickets_after == 1 + redirect_to new_conference_payment_path(has_registration_ticket: has_registration_ticket), notice: 'Please pay here to get tickets.' return end - # Current user didn't have a registration ticket and is purchasing one + # Redirect to registration page for a user who didn't have a registration ticket and is purchasing one if count_registration_tickets_before == 0 && count_registration_tickets_after == 1 - redirect_to new_conference_conference_registration_path(@conference.short_title) + redirect_to new_conference_conference_registration_path(@conference.short_title), + notice: 'Thanks! Your ticket is booked successfully. Please register for the conference.' else - redirect_to conference_physical_tickets_path + redirect_to conference_physical_tickets_path, + notice: 'Thanks! Your ticket is booked successfully.' end end diff --git a/app/models/user.rb b/app/models/user.rb index 85584955..955c76d1 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -349,10 +349,8 @@ class User < ApplicationRecord def count_registration_tickets(conference) count = 0 ticket_purchases.by_conference(conference).each do |ticket_purchase| - ticket_purchase.physical_tickets.each do |physical_ticket| - if physical_ticket.ticket.registration_ticket - count += 1 - end + if ticket_purchase.ticket.registration_ticket + count += 1 end end diff --git a/app/views/payments/_payment.html.haml b/app/views/payments/_payment.html.haml index 440f9985..bd70d8e8 100644 --- a/app/views/payments/_payment.html.haml +++ b/app/views/payments/_payment.html.haml @@ -19,7 +19,7 @@ %td = humanized_money_with_symbol ticket.quantity * ticket.price -= form_tag conference_payments_path do += form_tag conference_payments_path(@conference.short_title, :has_registration_ticket => @has_registration_ticket) do %script.stripe-button{'src': "https://checkout.stripe.com/checkout.js", 'data': {amount: @total_amount_to_pay.cents, label: "Pay #{humanized_money_with_symbol @total_amount_to_pay}", From 6e3cdc261414c18def27e6eb248098ec99f88d1a Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 4 Mar 2021 22:05:55 -0800 Subject: [PATCH 14/99] [test] Add test for auto-redirect --- spec/features/ticket_purchases_spec.rb | 58 +++++++++++++++++++++++++- 1 file changed, 57 insertions(+), 1 deletion(-) diff --git a/spec/features/ticket_purchases_spec.rb b/spec/features/ticket_purchases_spec.rb index 7d6f49ca..760472c5 100644 --- a/spec/features/ticket_purchases_spec.rb +++ b/spec/features/ticket_purchases_spec.rb @@ -7,7 +7,8 @@ feature Registration, feature: true, js: true do let!(:free_ticket) { create(:ticket, price_cents: 0) } let!(:first_registration_ticket) { create(:registration_ticket, price_cents: 0) } let!(:second_registration_ticket) { create(:registration_ticket, price_cents: 0) } - let!(:conference) { create(:conference, title: 'ExampleCon', tickets: [ticket, free_ticket, first_registration_ticket, second_registration_ticket], registration_period: create(:registration_period, start_date: 3.days.ago)) } + let!(:third_registration_ticket) { create(:registration_ticket, price_cents: 10) } + let!(:conference) { create(:conference, title: 'ExampleCon', tickets: [ticket, free_ticket, first_registration_ticket, second_registration_ticket, third_registration_ticket], registration_period: create(:registration_period, start_date: 3.days.ago)) } let!(:participant) { create(:user) } context 'as a participant' do @@ -111,6 +112,61 @@ feature Registration, feature: true, js: true do expect(purchase.paid).to be true end + scenario 'purchases a free registartion ticket' do + visit root_path + click_link 'Register' + + expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title)) + click_button 'Register' + + fill_in "tickets__#{first_registration_ticket.id}", with: '1' + expect(current_path).to eq(conference_tickets_path(conference.short_title)) + + click_button 'Continue' + expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title)) + expect(flash).to eq('Thanks! Your ticket is booked successfully. Please register for the conference.') + + purchase = TicketPurchase.where(user_id: participant.id, ticket_id: first_registration_ticket.id).first + expect(purchase.quantity).to eq(1) + expect(purchase.paid).to be true + end + + scenario 'purchases a non-free registartion ticket' do + visit root_path + click_link 'Register' + + expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title)) + click_button 'Register' + + fill_in "tickets__#{third_registration_ticket.id}", with: '1' + expect(current_path).to eq(conference_tickets_path(conference.short_title)) + + click_button 'Continue' + page.find('#flash') + expect(current_path).to eq(new_conference_payment_path(conference.short_title)) + expect(flash).to eq('Please pay here to get tickets.') + purchase = TicketPurchase.where(user_id: participant.id, ticket_id: third_registration_ticket.id).first + expect(purchase.quantity).to eq(1) + + if Rails.application.secrets.stripe_publishable_key + find('.stripe-button-el').click + + stripe_iframe = all('iframe[name=stripe_checkout_app]').last + sleep(5) + Capybara.within_frame stripe_iframe do + expect(page).to have_content('book your tickets') + page.execute_script(%{ $('input#card_number').val('4242424242424242'); }) + page.execute_script(%{ $('input#cc-exp').val('08/22'); }) + page.execute_script(%{ $('input#cc-csc').val('123'); }) + page.execute_script(%{ $('#submitButton').click(); }) + sleep(20) + end + + expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title)) + expect(flash).to eq('Thanks! Your ticket is booked successfully. Please register for the conference.') + end + end + scenario 'purchases more than one registration tickets of a single type' do visit root_path click_link 'Register' From 247beb172b8aa0dbea3dd85a62ed9e25774f8875 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 4 Mar 2021 22:16:16 -0800 Subject: [PATCH 15/99] Allow coverage to drop by a small threshold without failing CI --- .codecov.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index db247200..9c6a4c0d 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1 +1,6 @@ +coverage: + status: + project: + default: + threshold: 0.5% comment: off From d413da13811786c73d7f8cd795d77779b0676075 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 4 Mar 2021 22:28:29 -0800 Subject: [PATCH 16/99] Revert "Allow coverage to drop by a small threshold without failing CI" Small changes in coverage may be indicative of a larger issue with unintentional changes in behavior. Thus, reverting the threshold change. This reverts commit 247beb172b8aa0dbea3dd85a62ed9e25774f8875. --- .codecov.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 9c6a4c0d..db247200 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,6 +1 @@ -coverage: - status: - project: - default: - threshold: 0.5% comment: off From aced0925b33add05b1cc2ff38ad1867d5022f4ad Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 4 Mar 2021 22:50:37 -0800 Subject: [PATCH 17/99] Include linters in all suites --- bin/travis_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/travis_script.sh b/bin/travis_script.sh index 57ca8aa5..dfcbfcac 100755 --- a/bin/travis_script.sh +++ b/bin/travis_script.sh @@ -12,7 +12,7 @@ else fi case $TEST_SUITE in - linters) + linters|all) bundle exec rubocop -Dc .rubocop.yml bundle exec haml-lint app/views ;;& From e8013d83451fa1b455aefd7ce620801ddaff8570 Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Fri, 5 Mar 2021 03:35:29 -0800 Subject: [PATCH 18/99] 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 19/99] 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 20/99] 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 21/99] 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 22/99] 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 1f9da86e39fd4f5b1b89dcba1d0e779dbf5d47be Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 4 Mar 2021 23:43:27 -0800 Subject: [PATCH 23/99] Fill submission text if the field is currently empty --- app/assets/javascripts/osem.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index 0839f13b..59174f01 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -147,6 +147,15 @@ function word_count(text, divId, maxcount) { }); }; +function fill_if_empty(text_area, filler) { + let area = $('#' + text_area); + + if (!area.val()) { + area.val(filler); + area.trigger('change'); + } +} + /* Wait for the DOM to be ready before attaching events to the elements */ $( document ).ready(function() { /* Set the minimum and maximum proposal abstract and submission text word length */ @@ -155,15 +164,15 @@ $( document ).ready(function() { var max = $selected.data("max-words"); var min = $selected.data("min-words"); + // Set the placeholder text for the abstract + fill_if_empty('event_submission_text', $selected.data("help")); + $("#abstract-maximum-word-count").text(max); $("#submission-maximum-word-count").text(max); $("#abstract-minimum-word-count").text(min); $("#submission-minimum-word-count").text(min); word_count($('#event_abstract').get(0), 'abstract-count', max); word_count($('#event_submission_text').get(0), 'submission-count', max); - - // Set the placeholder text for the abstract - $('#event_submission_text').attr("placeholder", $selected.data("help")); }) .trigger('change'); From 71ce82c968aebfc246d4cdfbc593a541e381ca28 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 5 Mar 2021 12:39:50 -0800 Subject: [PATCH 24/99] Create JS hook for template reset --- app/assets/javascripts/osem.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index 59174f01..9d5054f8 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -189,6 +189,18 @@ $( document ).ready(function() { var max = $selected.data("max-words"); word_count(this, 'submission-count', max); }); + + /* 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')); + if (affirm) { + let sub_text = $('#event_submission_text'); + sub_text.val($selected.data('help')); + sub_text.trigger('change'); + } + }); }); /* Commodity function for modal windows */ From 8f465136c3a7d6a0da7f1e2c9582078347539c05 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sat, 6 Mar 2021 22:56:01 -0800 Subject: [PATCH 25/99] Add buttons for submission text template reset --- app/views/proposals/_proposal_form.html.haml | 1 + app/views/proposals/new.html.haml | 1 + 2 files changed, 2 insertions(+) diff --git a/app/views/proposals/_proposal_form.html.haml b/app/views/proposals/_proposal_form.html.haml index 5b4e7079..010eea9e 100644 --- a/app/views/proposals/_proposal_form.html.haml +++ b/app/views/proposals/_proposal_form.html.haml @@ -50,6 +50,7 @@ = f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' }, placeholder: '' }, hint: markdown_hint('Only conference organizers will read this.') + %button.btn.btn-primary.primary-button{ type: 'button', id: 'sub_text_reset', data: { confirm: 'Do you really want to reset your submission text to the provided template?' } } Reset to Template %p You have used diff --git a/app/views/proposals/new.html.haml b/app/views/proposals/new.html.haml index bdd16e11..e6aaa355 100644 --- a/app/views/proposals/new.html.haml +++ b/app/views/proposals/new.html.haml @@ -63,6 +63,7 @@ = f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' } }, hint: markdown_hint + %button.btn.btn-primary.primary-button{ type: 'button', id: 'sub_text_reset', data: { confirm: 'Do you really want to reset your submission text to the provided template?' } } Reset to Template %p You have used From cdbeb6ec4cd2e0c2c4e9b8e337bf89a8b0f9002b Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sun, 7 Mar 2021 23:00:40 -0800 Subject: [PATCH 26/99] Add test for covering Rest to Template button --- spec/features/proposals_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 15c23fcb..d3946ec6 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -177,5 +177,24 @@ feature Event do @event.reload expect(@event.state).to eq('withdrawn') end + + scenario 'can reset to text template', feature: true, js: true do + event_type = conference.program.event_types[-1] + event_type.description = 'Example event description' + event_type.save! + + sign_in participant + visit new_conference_program_proposal_path(conference.short_title) + + fill_in 'event_title', with: 'Example Proposal' + select(event_type.title, from: 'event[event_type_id]') + fill_in 'event_submission_text', with: 'Lorem ipsum example submission text' + + accept_confirm do + click_button 'Reset to Template' + end + + expect(page.find('#event_submission_text').value).to eq(event_type.description) + end end end From 2e61bc2948667a536b2020d3b88a8a75056c6fcc Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sun, 7 Mar 2021 23:02:49 -0800 Subject: [PATCH 27/99] Include help data for event types in new proposal view (Why doesn't the new view use the proposal form partial?) --- app/views/proposals/new.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/proposals/new.html.haml b/app/views/proposals/new.html.haml index e6aaa355..e6307efa 100644 --- a/app/views/proposals/new.html.haml +++ b/app/views/proposals/new.html.haml @@ -33,7 +33,7 @@ = f.input :title, as: :string, required: true, input_html: { required: true } = f.input :event_type_id, as: :select, collection: @program.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, - data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length }]}, + data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length, help: type.description }]}, include_blank: false, label: 'Type', input_html: { class: 'select-help-toggle' } - @program.event_types.each do |event_type| From 98649a6780ff626f8d26fc00a5bb6493c066dd0b Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sun, 7 Mar 2021 23:08:29 -0800 Subject: [PATCH 28/99] Add small accpetable test coverage dip threshold --- .codecov.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index db247200..9c6a4c0d 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1 +1,6 @@ +coverage: + status: + project: + default: + threshold: 0.5% comment: off From 11a4d200f76066a4210313eb4014b71c5bd2582f Mon Sep 17 00:00:00 2001 From: Jimmy Date: Tue, 9 Mar 2021 18:25:15 -0800 Subject: [PATCH 29/99] [test] Fix style; add test for user#count_registration_tickets --- app/controllers/payments_controller.rb | 2 -- app/controllers/ticket_purchases_controller.rb | 4 ++-- spec/models/user_spec.rb | 11 +++++++++++ 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index d2317bbc..ab05aed3 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -34,8 +34,6 @@ class PaymentsController < ApplicationController redirect_to conference_physical_tickets_path, notice: 'Thanks! Your ticket is booked successfully.' end - - @has_registration_ticket = nil else @total_amount_to_pay = Ticket.total_price(@conference, current_user, paid: false) @unpaid_ticket_purchases = current_user.ticket_purchases.unpaid.by_conference(@conference) diff --git a/app/controllers/ticket_purchases_controller.rb b/app/controllers/ticket_purchases_controller.rb index 58e32feb..3034d742 100644 --- a/app/controllers/ticket_purchases_controller.rb +++ b/app/controllers/ticket_purchases_controller.rb @@ -31,14 +31,14 @@ class TicketPurchasesController < ApplicationController # User needs to pay for tickets if any of them is not free. if current_user.ticket_purchases.by_conference(@conference).unpaid.any? - has_registration_ticket = count_registration_tickets_before == 0 && count_registration_tickets_after == 1 + has_registration_ticket = count_registration_tickets_before.zero? && count_registration_tickets_after == 1 redirect_to new_conference_payment_path(has_registration_ticket: has_registration_ticket), notice: 'Please pay here to get tickets.' return end # Redirect to registration page for a user who didn't have a registration ticket and is purchasing one - if count_registration_tickets_before == 0 && count_registration_tickets_after == 1 + if count_registration_tickets_before.zero? && count_registration_tickets_after == 1 redirect_to new_conference_conference_registration_path(@conference.short_title), notice: 'Thanks! Your ticket is booked successfully. Please register for the conference.' else diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index b1a9de71..48eb7e8e 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -441,6 +441,17 @@ describe User do end end end + + describe '#count_registration_tickets' do + let(:registration_ticket) { create(:registration_ticket, price_cents: 0) } + let(:conference3) { create(:conference, short_title: 'oSC17', title: 'openSUSE Conference 2017', tickets: [registration_ticket]) } + let(:ticket_purchase) { create(user: user, conference: conference3, ticket: registration_ticket, quantity: 1) } + + it 'counts the number of registration tickets of a conference held by user' do + expect(user.count_registration_tickets(conference3).eq(1)) + expect(user.count_registration_tickets(conference2).eq(0)) + end + end end describe 'rolify' do From 59d19b3ae83b26a11e8859322173fd3045d3064b Mon Sep 17 00:00:00 2001 From: Jimmy Date: Tue, 9 Mar 2021 18:28:09 -0800 Subject: [PATCH 30/99] [style] fix style --- spec/models/user_spec.rb | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 48eb7e8e..7f1cd76f 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -446,10 +446,10 @@ describe User do let(:registration_ticket) { create(:registration_ticket, price_cents: 0) } let(:conference3) { create(:conference, short_title: 'oSC17', title: 'openSUSE Conference 2017', tickets: [registration_ticket]) } let(:ticket_purchase) { create(user: user, conference: conference3, ticket: registration_ticket, quantity: 1) } - + it 'counts the number of registration tickets of a conference held by user' do - expect(user.count_registration_tickets(conference3).eq(1)) - expect(user.count_registration_tickets(conference2).eq(0)) + expect(user.count_registration_tickets(conference3).to eq(1)) + expect(user.count_registration_tickets(conference2).to eq(0)) end end end From 9fd6659d9d0882ccfbe6e08091bae50c6b19fb33 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Tue, 9 Mar 2021 18:31:02 -0800 Subject: [PATCH 31/99] [style] fix style --- spec/models/user_spec.rb | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 7f1cd76f..7353ecf5 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -448,8 +448,8 @@ describe User do let(:ticket_purchase) { create(user: user, conference: conference3, ticket: registration_ticket, quantity: 1) } it 'counts the number of registration tickets of a conference held by user' do - expect(user.count_registration_tickets(conference3).to eq(1)) - expect(user.count_registration_tickets(conference2).to eq(0)) + expect(user.count_registration_tickets(conference3)).to eq(1) + expect(user.count_registration_tickets(conference2)).to eq(0) end end end From f6b026226aa798f0d2ff87c2cc41dc981e2a5f7d Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Tue, 9 Mar 2021 19:08:13 -0800 Subject: [PATCH 32/99] Update comment in osem.js to be accurate --- app/assets/javascripts/osem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index 9d5054f8..636ed959 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -164,7 +164,7 @@ $( document ).ready(function() { var max = $selected.data("max-words"); var min = $selected.data("min-words"); - // Set the placeholder text for the abstract + // Set the filler text for the submission text fill_if_empty('event_submission_text', $selected.data("help")); $("#abstract-maximum-word-count").text(max); From 0a20f80d6e3de9199ea3d662a8ed0061e7cd9e1a Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Wed, 10 Mar 2021 10:25:41 -0800 Subject: [PATCH 33/99] 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 aa1b281f9a5cd35624ede7030cade9f60409f81d Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 10 Mar 2021 11:00:14 -0800 Subject: [PATCH 34/99] [test] Fix test for user#count_registration_tickets --- spec/models/user_spec.rb | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/spec/models/user_spec.rb b/spec/models/user_spec.rb index 7353ecf5..98c791b6 100644 --- a/spec/models/user_spec.rb +++ b/spec/models/user_spec.rb @@ -445,9 +445,11 @@ describe User do describe '#count_registration_tickets' do let(:registration_ticket) { create(:registration_ticket, price_cents: 0) } let(:conference3) { create(:conference, short_title: 'oSC17', title: 'openSUSE Conference 2017', tickets: [registration_ticket]) } - let(:ticket_purchase) { create(user: user, conference: conference3, ticket: registration_ticket, quantity: 1) } + let(:ticket_purchase) { create(:ticket_purchase, user: user, conference: conference3, ticket: registration_ticket, quantity: 1) } it 'counts the number of registration tickets of a conference held by user' do + user.ticket_purchases << ticket_purchase + expect(user.count_registration_tickets(conference3)).to eq(1) expect(user.count_registration_tickets(conference2)).to eq(0) end From 1c28f3839e1d71ffcfe4f61971e32fe6adc8288d Mon Sep 17 00:00:00 2001 From: rajavi-mishra Date: Wed, 10 Mar 2021 11:18:39 -0800 Subject: [PATCH 35/99] 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 03b943b3f53a3c04a7175d594230aec87de20417 Mon Sep 17 00:00:00 2001 From: "depfu[bot]" <23717796+depfu[bot]@users.noreply.github.com> Date: Wed, 3 Mar 2021 06:04:48 +0000 Subject: [PATCH 36/99] Update cocoon to version 1.2.15 --- Gemfile.lock | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Gemfile.lock b/Gemfile.lock index 191d801b..273546b8 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -127,6 +127,8 @@ GEM aws_cf_signer rest-client cocoon (1.2.15) + codecov (0.5.0) + simplecov (>= 0.15, < 0.22) coderay (1.1.1) concurrent-ruby (1.1.8) countable-rails (0.0.1) From cb03e12455a61924442672430cda27b2125788f0 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Tue, 2 Mar 2021 15:09:34 -0800 Subject: [PATCH 37/99] Make 'all' option actually fire all rspec tests --- bin/travis_script.sh | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/bin/travis_script.sh b/bin/travis_script.sh index 3f4f52cf..57ca8aa5 100755 --- a/bin/travis_script.sh +++ b/bin/travis_script.sh @@ -15,20 +15,20 @@ case $TEST_SUITE in linters) bundle exec rubocop -Dc .rubocop.yml bundle exec haml-lint app/views - ;; - models) + ;;& + models|all) bundle exec rspec --format documentation spec/models - ;; - features) + ;;& + features|all) bundle exec rspec --format documentation spec/features - ;; - controllers) + ;;& + controllers|all) bundle exec rspec --format documentation spec/controllers - ;; - ability) + ;;& + ability|all) bundle exec rspec --format documentation spec/ability - ;; - rest) + ;;& + rest|all) bundle exec rspec --format documentation --exclude-pattern "spec/{models,features,controllers,ability}/**/*_spec.rb" ;; esac From 1c9ed8a5516ef2d0bced6a5921cd36775309d442 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 4 Mar 2021 22:16:16 -0800 Subject: [PATCH 38/99] Allow coverage to drop by a small threshold without failing CI --- .codecov.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index db247200..9c6a4c0d 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1 +1,6 @@ +coverage: + status: + project: + default: + threshold: 0.5% comment: off From 4409e7998ce4e62b86dc4ce93c05cf533f17aa1e Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 4 Mar 2021 22:28:29 -0800 Subject: [PATCH 39/99] Revert "Allow coverage to drop by a small threshold without failing CI" Small changes in coverage may be indicative of a larger issue with unintentional changes in behavior. Thus, reverting the threshold change. This reverts commit 247beb172b8aa0dbea3dd85a62ed9e25774f8875. --- .codecov.yml | 5 ----- 1 file changed, 5 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 9c6a4c0d..db247200 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,6 +1 @@ -coverage: - status: - project: - default: - threshold: 0.5% comment: off From 771adb89146069e69d181431a8620f8e02d8fa22 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 4 Mar 2021 22:50:37 -0800 Subject: [PATCH 40/99] Include linters in all suites --- bin/travis_script.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/bin/travis_script.sh b/bin/travis_script.sh index 57ca8aa5..dfcbfcac 100755 --- a/bin/travis_script.sh +++ b/bin/travis_script.sh @@ -12,7 +12,7 @@ else fi case $TEST_SUITE in - linters) + linters|all) bundle exec rubocop -Dc .rubocop.yml bundle exec haml-lint app/views ;;& From 257509db195ea36ded693c9e771bbd563715b21a Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sun, 7 Mar 2021 23:08:29 -0800 Subject: [PATCH 41/99] Add small accpetable test coverage dip threshold --- .codecov.yml | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/.codecov.yml b/.codecov.yml index db247200..9c6a4c0d 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1 +1,6 @@ +coverage: + status: + project: + default: + threshold: 0.5% comment: off From a48e78da22a5389f8ac8703c65c104d233195646 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 4 Mar 2021 23:43:27 -0800 Subject: [PATCH 42/99] Fill submission text if the field is currently empty --- app/assets/javascripts/osem.js | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index 0839f13b..59174f01 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -147,6 +147,15 @@ function word_count(text, divId, maxcount) { }); }; +function fill_if_empty(text_area, filler) { + let area = $('#' + text_area); + + if (!area.val()) { + area.val(filler); + area.trigger('change'); + } +} + /* Wait for the DOM to be ready before attaching events to the elements */ $( document ).ready(function() { /* Set the minimum and maximum proposal abstract and submission text word length */ @@ -155,15 +164,15 @@ $( document ).ready(function() { var max = $selected.data("max-words"); var min = $selected.data("min-words"); + // Set the placeholder text for the abstract + fill_if_empty('event_submission_text', $selected.data("help")); + $("#abstract-maximum-word-count").text(max); $("#submission-maximum-word-count").text(max); $("#abstract-minimum-word-count").text(min); $("#submission-minimum-word-count").text(min); word_count($('#event_abstract').get(0), 'abstract-count', max); word_count($('#event_submission_text').get(0), 'submission-count', max); - - // Set the placeholder text for the abstract - $('#event_submission_text').attr("placeholder", $selected.data("help")); }) .trigger('change'); From 07348cb08f9ba2828b0b357f79f0ffd6df4540a8 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 5 Mar 2021 12:39:50 -0800 Subject: [PATCH 43/99] Create JS hook for template reset --- app/assets/javascripts/osem.js | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index 59174f01..9d5054f8 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -189,6 +189,18 @@ $( document ).ready(function() { var max = $selected.data("max-words"); word_count(this, 'submission-count', max); }); + + /* 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')); + if (affirm) { + let sub_text = $('#event_submission_text'); + sub_text.val($selected.data('help')); + sub_text.trigger('change'); + } + }); }); /* Commodity function for modal windows */ From e00544e02425844606e34c7e02dafcdb1443f39e Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sat, 6 Mar 2021 22:56:01 -0800 Subject: [PATCH 44/99] Add buttons for submission text template reset --- app/views/proposals/_proposal_form.html.haml | 1 + 1 file changed, 1 insertion(+) diff --git a/app/views/proposals/_proposal_form.html.haml b/app/views/proposals/_proposal_form.html.haml index 423a7fba..5f907d6a 100644 --- a/app/views/proposals/_proposal_form.html.haml +++ b/app/views/proposals/_proposal_form.html.haml @@ -56,6 +56,7 @@ = f.input :submission_text, input_html: { rows: 5, data: { provide: 'markdown' }, placeholder: '' }, hint: markdown_hint('Only conference organizers will read this.') + %button.btn.btn-primary.primary-button{ type: 'button', id: 'sub_text_reset', data: { confirm: 'Do you really want to reset your submission text to the provided template?' } } Reset to Template %p You have used From 58ae746e78a5b45a11d8adc64b569e93bd0d14ff Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sun, 7 Mar 2021 23:00:40 -0800 Subject: [PATCH 45/99] Add test for covering Rest to Template button --- spec/features/proposals_spec.rb | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/spec/features/proposals_spec.rb b/spec/features/proposals_spec.rb index 482282a2..18297d2d 100644 --- a/spec/features/proposals_spec.rb +++ b/spec/features/proposals_spec.rb @@ -191,5 +191,24 @@ feature Event do @event.reload expect(@event.state).to eq('withdrawn') end + + scenario 'can reset to text template', feature: true, js: true do + event_type = conference.program.event_types[-1] + event_type.description = 'Example event description' + event_type.save! + + sign_in participant + visit new_conference_program_proposal_path(conference.short_title) + + fill_in 'event_title', with: 'Example Proposal' + select(event_type.title, from: 'event[event_type_id]') + fill_in 'event_submission_text', with: 'Lorem ipsum example submission text' + + accept_confirm do + click_button 'Reset to Template' + end + + expect(page.find('#event_submission_text').value).to eq(event_type.description) + end end end From 13b10cc9a3febfbbac3fe1faf2bc37d0ceea7ce2 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Sun, 7 Mar 2021 23:02:49 -0800 Subject: [PATCH 46/99] Include help data for event types in new proposal view (Why doesn't the new view use the proposal form partial?) --- app/views/proposals/new.html.haml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/views/proposals/new.html.haml b/app/views/proposals/new.html.haml index 5c581e5b..ac2d72ae 100644 --- a/app/views/proposals/new.html.haml +++ b/app/views/proposals/new.html.haml @@ -33,7 +33,7 @@ = f.input :title, as: :string, required: true, input_html: { required: true } = f.input :event_type_id, as: :select, collection: @program.event_types.map {|type| ["#{type.title} - #{show_time(type.length)}", type.id, - data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length }]}, + data: { min_words: type.minimum_abstract_length, max_words: type.maximum_abstract_length, help: type.description }]}, include_blank: false, label: 'Type', input_html: { class: 'select-help-toggle' } - if @program.languages.present? From c1fad244effef4f3e6c4b8bedad7a7d1fffbfe81 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Tue, 9 Mar 2021 19:08:13 -0800 Subject: [PATCH 47/99] Update comment in osem.js to be accurate --- app/assets/javascripts/osem.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/assets/javascripts/osem.js b/app/assets/javascripts/osem.js index 9d5054f8..636ed959 100644 --- a/app/assets/javascripts/osem.js +++ b/app/assets/javascripts/osem.js @@ -164,7 +164,7 @@ $( document ).ready(function() { var max = $selected.data("max-words"); var min = $selected.data("min-words"); - // Set the placeholder text for the abstract + // Set the filler text for the submission text fill_if_empty('event_submission_text', $selected.data("help")); $("#abstract-maximum-word-count").text(max); From 75baeb4f98ddf62040b00ca8eca650e46572503a Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 10 Mar 2021 16:17:34 -0800 Subject: [PATCH 48/99] [fix] Fix ticket purchases tests --- spec/features/ticket_purchases_spec.rb | 22 +++++----------------- 1 file changed, 5 insertions(+), 17 deletions(-) diff --git a/spec/features/ticket_purchases_spec.rb b/spec/features/ticket_purchases_spec.rb index 1b96a38d..52557998 100644 --- a/spec/features/ticket_purchases_spec.rb +++ b/spec/features/ticket_purchases_spec.rb @@ -7,7 +7,7 @@ feature Registration, feature: true, js: true do let!(:free_ticket) { create(:ticket, price_cents: 0) } let!(:first_registration_ticket) { create(:registration_ticket, price_cents: 0) } let!(:second_registration_ticket) { create(:registration_ticket, price_cents: 0) } - let!(:third_registration_ticket) { create(:registration_ticket, price_cents: 10) } + let!(:third_registration_ticket) { create(:registration_ticket, price_cents: 2000) } let!(:conference) { create(:conference, title: 'ExampleCon', tickets: [ticket, free_ticket, first_registration_ticket, second_registration_ticket, third_registration_ticket], registration_period: create(:registration_period, start_date: 3.days.ago)) } let!(:participant) { create(:user) } @@ -17,7 +17,7 @@ feature Registration, feature: true, js: true do stripe_iframe = all('iframe[name=stripe_checkout_app]').last sleep(5) Capybara.within_frame stripe_iframe do - expect(page).to have_content("#{ENV['OSEM_NAME']} tickets") + expect(page).to have_content(:all, "#{ENV['OSEM_NAME']} tickets") fill_in 'Card number', with: card_number fill_in 'Expiry', with: '08/22' fill_in 'CVC', with: '123' @@ -145,22 +145,10 @@ feature Registration, feature: true, js: true do purchase = TicketPurchase.where(user_id: participant.id, ticket_id: third_registration_ticket.id).first expect(purchase.quantity).to eq(1) - if Rails.application.secrets.stripe_publishable_key - find('.stripe-button-el').click - - stripe_iframe = all('iframe[name=stripe_checkout_app]').last - sleep(5) - Capybara.within_frame stripe_iframe do - expect(page).to have_content('book your tickets') - page.execute_script(%{ $('input#card_number').val('4242424242424242'); }) - page.execute_script(%{ $('input#cc-exp').val('08/22'); }) - page.execute_script(%{ $('input#cc-csc').val('123'); }) - page.execute_script(%{ $('#submitButton').click(); }) - sleep(20) - end - + if ENV['STRIPE_PUBLISHABLE_KEY'] || Rails.application.secrets.stripe_publishable_key + make_stripe_purchase expect(current_path).to eq(new_conference_conference_registration_path(conference.short_title)) - expect(flash).to eq('Thanks! Your ticket is booked successfully. Please register for the conference.') + expect(page).to have_content 'Your ticket is booked successfully.' end end From fb07a4356657239b56f3217ed059ab6d9fc354e6 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 10 Mar 2021 16:20:01 -0800 Subject: [PATCH 49/99] [style] fix style --- spec/features/ticket_purchases_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/ticket_purchases_spec.rb b/spec/features/ticket_purchases_spec.rb index 52557998..524facef 100644 --- a/spec/features/ticket_purchases_spec.rb +++ b/spec/features/ticket_purchases_spec.rb @@ -11,7 +11,7 @@ feature Registration, feature: true, js: true do let!(:conference) { create(:conference, title: 'ExampleCon', tickets: [ticket, free_ticket, first_registration_ticket, second_registration_ticket, third_registration_ticket], registration_period: create(:registration_period, start_date: 3.days.ago)) } let!(:participant) { create(:user) } - def make_stripe_purchase(card_number='4242424242424242') + def make_stripe_purchase(card_number = '4242424242424242') find('.stripe-button-el').click stripe_iframe = all('iframe[name=stripe_checkout_app]').last From 130bff950693c0925e43970cf76ccb27d1e2c845 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 10 Mar 2021 16:36:09 -0800 Subject: [PATCH 50/99] [fix] change pending to skip to satisfy CI --- spec/features/ticket_purchases_spec.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/spec/features/ticket_purchases_spec.rb b/spec/features/ticket_purchases_spec.rb index 524facef..cc6b66b5 100644 --- a/spec/features/ticket_purchases_spec.rb +++ b/spec/features/ticket_purchases_spec.rb @@ -188,7 +188,7 @@ feature Registration, feature: true, js: true do context 'who is registered' do scenario 'unregisters from conference, but ticket purchases dont delete' do - pending('SNAPCON: Investigate failure on the unregister button') + skip('SNAPCON: Investigate failure on the unregister button') visit root_path click_link 'Register' From ba4de34fa77abdfd34913362db471f6a3069c76e Mon Sep 17 00:00:00 2001 From: Jimmy Date: Wed, 10 Mar 2021 17:44:15 -0800 Subject: [PATCH 51/99] [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 52/99] [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 53/99] [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 54/99] [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 54cee7f103030f4650e5301882dd37cb50bc5932 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 11 Mar 2021 21:39:51 -0800 Subject: [PATCH 55/99] [style] Remove extraneous check --- app/controllers/payments_controller.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/controllers/payments_controller.rb b/app/controllers/payments_controller.rb index ab05aed3..ffbfec15 100644 --- a/app/controllers/payments_controller.rb +++ b/app/controllers/payments_controller.rb @@ -27,7 +27,7 @@ class PaymentsController < ApplicationController update_purchased_ticket_purchases has_registration_ticket = params[:has_registration_ticket] - if has_registration_ticket.present? && has_registration_ticket == 'true' + if has_registration_ticket == 'true' redirect_to new_conference_conference_registration_path(@conference.short_title), notice: 'Thanks! Your ticket is booked successfully. Please register for the conference.' else From 4856bc718dae8370453827046cd2aa925461fb96 Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 11 Mar 2021 22:00:15 -0800 Subject: [PATCH 56/99] [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 57/99] 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 536ec5b68ae3d8627cb97d35fa668e8d551c61b2 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 11 Mar 2021 23:21:08 -0800 Subject: [PATCH 58/99] Fix linters --- app/views/admin/conferences/show.html.haml | 30 +++++---- .../conference_registrations/_event.html.haml | 23 ++++--- .../_registration_info.html.haml | 2 +- app/views/conferences/_footer.haml | 27 ++++---- app/views/conferences/_header.haml | 13 ++-- app/views/conferences/_program.haml | 2 +- app/views/conferences/_sponsors.haml | 2 +- app/views/conferences/_tickets.haml | 2 +- app/views/conferences/show.html.haml | 41 +++--------- app/views/layouts/_navigation.html.haml | 67 ++++++++++--------- app/views/physical_tickets/index.html.haml | 2 +- .../proposals/_encouragement_text.html.haml | 2 +- app/views/proposals/_speaker_info.haml | 4 +- app/views/proposals/_volunteer_info.haml | 2 +- app/views/proposals/_volunteers_table.haml | 15 +++-- app/views/proposals/index.html.haml | 2 +- app/views/schedules/_event.html.haml | 16 ++--- app/views/schedules/happening_now.haml | 16 ++--- 18 files changed, 128 insertions(+), 140 deletions(-) diff --git a/app/views/admin/conferences/show.html.haml b/app/views/admin/conferences/show.html.haml index 76990b10..ce49c287 100644 --- a/app/views/admin/conferences/show.html.haml +++ b/app/views/admin/conferences/show.html.haml @@ -29,8 +29,9 @@ = render 'line_chart', title: 'Submissions per week', data: @submissions .col-md-4 - -# = render 'todo_list', - -# conference_progress: @conference_progress, conference: @conference + -# + = render 'todo_list', + conference_progress: @conference_progress, conference: @conference .row#tickets .col-md-8 = render 'line_chart', @@ -58,22 +59,27 @@ = render 'donut_chart', title: 'Event types', combined_data: @event_type_distribution .col-md-4 - -# = render 'donut_chart', title: 'Difficulty levels', - -# combined_data: @difficulty_levels_distribution + -# + = render 'donut_chart', title: 'Difficulty levels', + combined_data: @difficulty_levels_distribution .col-md-4 - -# = render 'donut_chart', title: 'Tracks', - -# combined_data: @tracks_distribution + -# + = render 'donut_chart', title: 'Tracks', + combined_data: @tracks_distribution .tab-pane#distribution_confirmed .row .col-md-4 - -# = render 'donut_chart', title: 'Event types', - -# combined_data: @event_type_distribution_confirmed + -# + = render 'donut_chart', title: 'Event types', + combined_data: @event_type_distribution_confirmed .col-md-4 - -# = render 'donut_chart', title: 'Difficulty levels', - -# combined_data: @difficulty_levels_distribution_confirmed + -# + = render 'donut_chart', title: 'Difficulty levels', + combined_data: @difficulty_levels_distribution_confirmed .col-md-4 - -# = render 'donut_chart', title: 'Tracks', - -# combined_data: @tracks_distribution_confirmed + -# + = render 'donut_chart', title: 'Tracks', + combined_data: @tracks_distribution_confirmed .tab-pane#distribution_withdrawn .row .col-md-4 diff --git a/app/views/conference_registrations/_event.html.haml b/app/views/conference_registrations/_event.html.haml index 2d0f6234..dd389f66 100644 --- a/app/views/conference_registrations/_event.html.haml +++ b/app/views/conference_registrations/_event.html.haml @@ -1,9 +1,9 @@ -.panel.panel-default{class: ("panel-success" if event.registrations.include?(@registration)) } +.panel.panel-default{ class: ('panel-success' if event.registrations.include?(registration)) } .panel-heading - %label{for: "registration_event_ids_#{event.id}"} - %h3{style: 'margin: 0 auto;'} - = hidden_field_tag "registration[event_ids][]", nil - = check_box_tag "registration[event_ids][]", event.id, event.registrations.include?(@registration), id: "registration_event_ids_#{event.id}" + %label{ for: "registration_event_ids_#{event.id}" } + %h3{ style: 'margin: 0 auto;' } + = hidden_field_tag 'registration[event_ids][]', nil + = check_box_tag 'registration[event_ids][]', event.id, event.registrations.include?(registration), id: "registration_event_ids_#{event.id}" = event.title %small = event.subtitle @@ -13,26 +13,27 @@ (Scheduled on: #{event.time.to_date}) .panel-body - -# %p - -# = canceled_replacement_event_label(event, event_schedule) - -# = replacement_event_notice(event_schedule) + -# + %p + = canceled_replacement_event_label(event, event_schedule) + = replacement_event_notice(event_schedule) %p - if event.speakers.any? presented by #{event.speaker_names} - if event_schedule.present? .h4.track %span.fa.fa-clock-o - %span.label{ style: "background-color: grey" } + %span.label{ style: 'background-color: grey' } = event_schedule.start_time.strftime('%A, %B %-d %H:%M') \- = event_schedule.end_time.strftime('%H:%M') %p = markdown(truncate(event.abstract, length: 250)) -# TODO: More informative text or aria-label. - = link_to 'more', conference_program_proposal_path(@conference.short_title, event.id), target: '_blank' + = link_to 'more', conference_program_proposal_path(conference.short_title, event.id), target: '_blank' - if event.track %span.track %span.fa.fa-road - %span.label{ style: "background-color: #{event.track.color}; color: #{ contrast_color(event.track.color) }" } + %span.label{ style: "background-color: #{event.track.color}; color: #{contrast_color(event.track.color)}" } = event.track.name diff --git a/app/views/conference_registrations/_registration_info.html.haml b/app/views/conference_registrations/_registration_info.html.haml index e8968298..45d6f9fe 100644 --- a/app/views/conference_registrations/_registration_info.html.haml +++ b/app/views/conference_registrations/_registration_info.html.haml @@ -18,6 +18,6 @@ You are registered for #{pluralize(@registration.events.count, 'event')}. They are at the end of this list. - @registration.events_ordered.each do |event| - = render 'conference_registrations/event', event: event, event_schedule: event.event_schedules.first + = render 'conference_registrations/event', event: event, event_schedule: event.event_schedules.first, conference: @conference, registration: @registration = render 'conferences/code_of_conduct', organization: @conference.organization diff --git a/app/views/conferences/_footer.haml b/app/views/conferences/_footer.haml index 6b66478a..0ef3fa56 100644 --- a/app/views/conferences/_footer.haml +++ b/app/views/conferences/_footer.haml @@ -1,14 +1,15 @@ --# .scroll-top-wrapper --# = link_to "#banner", class: "smoothscroll" do --# %i.fa.fa-2x.fa-arrow-circle-up +-# + scroll-top-wrapper + = link_to "#banner", class: "smoothscroll" do + %i.fa.fa-2x.fa-arrow-circle-up --# :javascript --# $(function(){ --# $(document).on( 'scroll', function(){ --# if ($(window).scrollTop() > 100) { --# $('.scroll-top-wrapper').addClass('show'); --# } else { --# $('.scroll-top-wrapper').removeClass('show'); --# } --# }); --# }); + :javascript + $(function(){ + $(document).on( 'scroll', function(){ + if ($(window).scrollTop() > 100) { + $('.scroll-top-wrapper').addClass('show'); + } else { + $('.scroll-top-wrapper').removeClass('show'); + } + }); + }); diff --git a/app/views/conferences/_header.haml b/app/views/conferences/_header.haml index fad8648c..f40fe600 100644 --- a/app/views/conferences/_header.haml +++ b/app/views/conferences/_header.haml @@ -2,13 +2,14 @@ #banner{ style: ("background-image: url(#{conference.picture_url})" if conference.picture_url) } .container .row - .col-md-6.col-md-offset-3{id: (conference.picture? ? "header-image" : "header-no-image")} + .col-md-6.col-md-offset-3{ id: (conference.picture? ? "header-image" : "header-no-image") } .row - -# - if conference.picture? - -# .col-md-4 - -# = image_tag(conference.picture_url, - -# class: 'img-responsive img-center', - -# id: 'splash-logo') + -# + - if conference.picture? + .col-md-4 + = image_tag(conference.picture_url, + class: 'img-responsive img-center', + id: 'splash-logo') .col-md-8 %h1 = conference.title.html_safe diff --git a/app/views/conferences/_program.haml b/app/views/conferences/_program.haml index 18d8a540..de07b475 100644 --- a/app/views/conferences/_program.haml +++ b/app/views/conferences/_program.haml @@ -2,7 +2,7 @@ %li %a.smoothscroll{ href: '#program' } Program %li - = link_to('Schedule', events_conference_schedule_path(@conference)) + = link_to('Schedule', events_conference_schedule_path(conference)) - cache [conference, highlights, tracks, booths, '#splash#program'] do %section#program diff --git a/app/views/conferences/_sponsors.haml b/app/views/conferences/_sponsors.haml index 0bd5edb0..ab9e3638 100644 --- a/app/views/conferences/_sponsors.haml +++ b/app/views/conferences/_sponsors.haml @@ -27,7 +27,7 @@ .row .col-md-12 %h3.text-center - = "Interested in sponsoring #{conference.title}?" + Interested in sponsoring #{conference.title}? = link_to(sponsorship_mailto(conference)) do Please, contact us! .trapezoid diff --git a/app/views/conferences/_tickets.haml b/app/views/conferences/_tickets.haml index b28f705e..940dc1ca 100644 --- a/app/views/conferences/_tickets.haml +++ b/app/views/conferences/_tickets.haml @@ -22,6 +22,6 @@ .word_break = short_ticket_description(ticket) %button.btn-block.btn.btn-lg.btn-success - %i.fa.fa-ticket.fa-fw{"aria-hidden": true} + %i.fa.fa-ticket.fa-fw{ "aria-hidden": true } = humanized_money_with_symbol(ticket.price) .trapezoid diff --git a/app/views/conferences/show.html.haml b/app/views/conferences/show.html.haml index f498bf97..c34aa3c1 100644 --- a/app/views/conferences/show.html.haml +++ b/app/views/conferences/show.html.haml @@ -20,24 +20,22 @@ - if @unpaid_tickets .row .col-md-12 - .alert.alert-dismissable.alert-info.text-center#unpaid-tickets{role: 'alert'} - %button.button.close{"data-dismiss" => "alert", "aria-label"=>"close"} + .alert.alert-dismissable.alert-info.text-center#unpaid-tickets{ role: 'alert' } + %button.button.close{ "data-dismiss" => "alert", "aria-label"=>"close" } × %p You have unpaid tickets. Please complete your purchase. = link_to('Purchase Tickets', new_conference_payment_path(@conference), class: 'btn btn-success btn-lg') - - if @user_needs_to_register .row - .col-md-12 - .alert.alert-dismissable.alert-warning.text-center#flash{role: 'alert'} - %button.button.close{"data-dismiss" => "alert", 'aria-label': 'close'} - × - %p - You still need to complete your registration for #{@conference.title}. - = link_to('Complete Registration', new_conference_conference_registration_path(@conference), class: 'btn btn-success btn-lg') - + .col-md-12 + .alert.alert-dismissable.alert-warning.text-center#flash{ role: 'alert' } + %button.button.close{ "data-dismiss" => "alert", 'aria-label': 'close' } + × + %p + You still need to complete your registration for #{@conference.title}. + = link_to('Complete Registration', new_conference_conference_registration_path(@conference), class: 'btn btn-success btn-lg') #splash - if @conference.code_of_conduct.present? @@ -79,29 +77,8 @@ sponsorship_levels: @sponsorship_levels, sponsors: @sponsors - -# footer - if @conference.splashpage.include_social_media - if @conference.contact.has_social_media? = render 'social_media', contact: @conference.contact = render 'footer' - - --# - content_for :script_head do --# :javascript --# var triangle_tcs = tinycolor("#{h(@conference.color)}").monochromatic(); --# var triangle_colors = triangle_tcs.map(function(t) { --# return t.toHexString(); --# }); --# $(function () { --# $(document).ready(function() { --# var triangle_width = document.body.clientWidth; --# var triangle_height = ($( "#banner" ).height() + 200 ); --# var pattern = Trianglify({ width: triangle_width, --# height: triangle_height, --# cell_size: 100, --# x_colors: triangle_colors --# }); --# $('#banner').css('background-image', 'url(' + 0 + ')'); --# }); --# }); diff --git a/app/views/layouts/_navigation.html.haml b/app/views/layouts/_navigation.html.haml index fb1ddeff..8215f5ce 100644 --- a/app/views/layouts/_navigation.html.haml +++ b/app/views/layouts/_navigation.html.haml @@ -51,37 +51,38 @@ = link_to(sign_in_path) do %span.fa.fa-user Sign In - -# %li.dropdown.visible-desktop - -# %a.dropdown-toggle{"data-toggle" => "dropdown", href: '#'} - -# %span.fa.fa-user - -# Sign In - -# %span.caret - -# .dropdown-menu - -# - if ENV['OSEM_ICHAIN_ENABLED'] == 'true' - -# = form_tag User.ichain_login_url do - -# = text_field_tag 'username', nil, id: 'user_ichain_email_dd', class: 'form-control', placeholder: 'Username' - -# = password_field_tag 'password', nil, id: 'user_ichain_password_dd', class: 'form-control', placeholder: 'Password' - -# %button.btn.btn-success.btn-block Sign in - -# - else - -# %div{style: "padding: 6px"} - -# = form_tag new_user_session_path, class: 'form-group' do - -# = text_field_tag 'user[login]', nil, id: 'user_login_dd', class: 'form-control', placeholder: 'Username / E-Mail' - -# = password_field_tag 'user[password]', nil, id: 'user_password_dd', class: 'form-control', placeholder: 'Password' - -# %p.text-right - -# %small - -# %label{for: 'user_remember_me'} Remember me - -# = check_box_tag 'user[remember_me]' - -# %br - -# %button.btn.btn-success.btn-block Sign in - -# - unless omniauth_configured.empty? - -# .divider - -# %h6.text-center - -# or - -# = render 'devise/shared/openid_links' - -# %p.text-right - -# %br - -# %a.small.btn.btn-xs.btn-default{"data-toggle" => "collapse", "data-target" => "#navbar-devise-help"} - -# Need Help? - -# #navbar-devise-help.collapse - -# = render 'devise/shared/links' + -# + %li.dropdown.visible-desktop + %a.dropdown-toggle{"data-toggle" => "dropdown", href: '#'} + %span.fa.fa-user + Sign In + %span.caret + .dropdown-menu + - if ENV['OSEM_ICHAIN_ENABLED'] == 'true' + = form_tag User.ichain_login_url do + = text_field_tag 'username', nil, id: 'user_ichain_email_dd', class: 'form-control', placeholder: 'Username' + = password_field_tag 'password', nil, id: 'user_ichain_password_dd', class: 'form-control', placeholder: 'Password' + %button.btn.btn-success.btn-block Sign in + - else + %div{style: "padding: 6px"} + = form_tag new_user_session_path, class: 'form-group' do + = text_field_tag 'user[login]', nil, id: 'user_login_dd', class: 'form-control', placeholder: 'Username / E-Mail' + = password_field_tag 'user[password]', nil, id: 'user_password_dd', class: 'form-control', placeholder: 'Password' + %p.text-right + %small + %label{for: 'user_remember_me'} Remember me + = check_box_tag 'user[remember_me]' + %br + %button.btn.btn-success.btn-block Sign in + - unless omniauth_configured.empty? + .divider + %h6.text-center + or + = render 'devise/shared/openid_links' + %p.text-right + %br + %a.small.btn.btn-xs.btn-default{"data-toggle" => "collapse", "data-target" => "#navbar-devise-help"} + Need Help? + #navbar-devise-help.collapse + = render 'devise/shared/links' .trapezoid diff --git a/app/views/physical_tickets/index.html.haml b/app/views/physical_tickets/index.html.haml index f05215d7..e89ceeab 100644 --- a/app/views/physical_tickets/index.html.haml +++ b/app/views/physical_tickets/index.html.haml @@ -12,7 +12,7 @@ -# TODO: And if they have a registration ticket? - if !@conference.user_registered?(@user) && @has_registration_ticket .col-md-12 - .alert.alert-success{role: 'alert'} + .alert.alert-success{ role: 'alert' } = link_to 'Complete Registration', new_conference_conference_registration_path(@conference), class: 'btn btn-info pull-right btn-lg' diff --git a/app/views/proposals/_encouragement_text.html.haml b/app/views/proposals/_encouragement_text.html.haml index 5c4ccb73..9b28088c 100644 --- a/app/views/proposals/_encouragement_text.html.haml +++ b/app/views/proposals/_encouragement_text.html.haml @@ -16,7 +16,7 @@ That means you have %b.notranslate= pluralize(@program.cfp.remaining_days, 'day') left! - %span.notranslate #{@conference.title} + %span.notranslate= @conference.title will only be as good as the content you present. Submit early, submit often! - else The submission period is closed now. diff --git a/app/views/proposals/_speaker_info.haml b/app/views/proposals/_speaker_info.haml index d757d9b4..552ff6ed 100644 --- a/app/views/proposals/_speaker_info.haml +++ b/app/views/proposals/_speaker_info.haml @@ -1,13 +1,13 @@ .speakerinfo .row .col-md-4 - = image_tag speaker.profile_picture(:size => 120), class: 'img-responsive img-rounded' + = image_tag speaker.profile_picture(size: 120), class: 'img-responsive img-rounded' .col-md-8 %h4 = link_to speaker.name, user_path(speaker.id) %br - if speaker.email_public? - = mail_to "#{ speaker.email }" do + = mail_to speaker.email.to_s do %i.fa.fa-envelope-o.fa-2x - if speaker.affiliation? .text-muted diff --git a/app/views/proposals/_volunteer_info.haml b/app/views/proposals/_volunteer_info.haml index f5e3e21b..ae63c327 100644 --- a/app/views/proposals/_volunteer_info.haml +++ b/app/views/proposals/_volunteer_info.haml @@ -1,7 +1,7 @@ .speakerinfo .row .col-md-4 - = image_tag speaker.profile_picture(:size => 120), class: 'img-responsive img-rounded' + = image_tag speaker.profile_picture(size: 120), class: 'img-responsive img-rounded' .col-md-8 %h4 = link_to speaker.name, user_path(speaker.id) diff --git a/app/views/proposals/_volunteers_table.haml b/app/views/proposals/_volunteers_table.haml index df99ce53..c842c1de 100644 --- a/app/views/proposals/_volunteers_table.haml +++ b/app/views/proposals/_volunteers_table.haml @@ -1,8 +1,8 @@ %table.table.table-striped#events - events.each do |event| %tr - %td.col-md-7{style: "padding:20px 8px 20px 8px;"} - = link_to event.title, conference_program_proposal_path(@conference.short_title, event.id) + %td.col-md-7{ style: 'padding:20px 8px 20px 8px;' } + = link_to event.title, conference_program_proposal_path(conference.short_title, event.id) %br %small.text-muted = event.event_type.title @@ -10,10 +10,11 @@ = "in #{event.track.name}" if event.track - if event.require_registration %br - = link_to registered_text(event), registrations_conference_program_proposal_path(@conference.short_title, event), class: 'btn btn-xs btn-danger' + = link_to registered_text(event), registrations_conference_program_proposal_path(conference.short_title, event), + class: 'btn btn-xs btn-danger' - %td.col-md-2{style: "padding:20px 8px 20px 8px;"} - - event_schedule = event.event_schedules.find_by(schedule_id: @program.selected_schedule_id) + %td.col-md-2{ style: 'padding:20px 8px 20px 8px;' } + - event_schedule = event.event_schedules.find_by(schedule_id: program.selected_schedule_id) - if event_schedule.present? - = inyourtz(event_schedule.start_time, @conference.timezone) do - = event_schedule.start_time.strftime("%Y %B %e - %H:%M") + = inyourtz(event_schedule.start_time, conference.timezone) do + = event_schedule.start_time.strftime('%Y %B %e - %H:%M') diff --git a/app/views/proposals/index.html.haml b/app/views/proposals/index.html.haml index 6785af29..2cc41860 100644 --- a/app/views/proposals/index.html.haml +++ b/app/views/proposals/index.html.haml @@ -121,7 +121,7 @@ Volunteer Duties %small Thanks for being a host at #{@conference.title} - = render 'volunteers_table', events: @volunteer_events + = render 'volunteers_table', events: @volunteer_events, conference: @conference, program: @program .row .col-md-12 diff --git a/app/views/schedules/_event.html.haml b/app/views/schedules/_event.html.haml index 25257c0d..dbd16b10 100644 --- a/app/views/schedules/_event.html.haml +++ b/app/views/schedules/_event.html.haml @@ -1,20 +1,20 @@ -.panel.panel-default.event-panel{ onClick: 'eventClicked(event, this);', "data-url" => "#{url_for(conference_program_proposal_path(@conference.short_title, event.id))}" } +.panel.panel-default.event-panel{ onClick: 'eventClicked(event, this);', 'data-url' => "#{url_for(conference_program_proposal_path(@conference.short_title, event.id))}" } - header_color = event.event_type&.color || '#f5f5f5' - .trapezoid{style: "color: white; top: 12px; z-index: 100;"} + .trapezoid{ style: 'color: white; top: 12px; z-index: 100;' } .panel-heading{ style: "background-color: #{header_color}; color: #{ contrast_color(header_color) }; border-radius: 4px" } - event.speakers_ordered.each do |speaker| - = image_tag speaker.profile_picture, class: "img-circle pull-right", alt: speaker.name, style: "padding: 2px;" + = image_tag speaker.profile_picture, class: 'img-circle pull-right', alt: speaker.name, style: 'padding: 2px;' %p = canceled_replacement_event_label(event, event_schedule) = replacement_event_notice(event_schedule) - %span.h3{style: "margin-bottom: 14px"} + %span.h3{ style: 'margin-bottom: 14px' } = event.title %br - %small{style: "color: #{contrast_color(header_color)}"} + %small{ style: "color: #{contrast_color(header_color)}" } = event.subtitle - .trapezoid{style: "color: #{header_color}; top: 12px;"} + .trapezoid{ style: "color: #{header_color}; top: 12px;" } .panel-body %h4 @@ -30,13 +30,13 @@ = inyourtz(event_schedule.start_time) do %span.track %span.fa.fa-clock-o - %span.label{ style: "background-color: grey" } + %span.label{ style: 'background-color: grey' } = event_schedule.start_time.strftime('%l:%M %P') \- = event_schedule.end_time.strftime('%l:%M %P') %span.track %span.fa.fa-map-marker - %span.label{ style: "background-color: grey" } + %span.label{ style: 'background-color: grey' } = event_schedule.room.name - if event.track %span.track diff --git a/app/views/schedules/happening_now.haml b/app/views/schedules/happening_now.haml index bfa2aced..0704b30e 100644 --- a/app/views/schedules/happening_now.haml +++ b/app/views/schedules/happening_now.haml @@ -12,7 +12,7 @@ %h3 This page was loaded at = inyourtz(Time.now) do - #{Time.now.strftime('%a %b %d at %I:%M %P (%z)')} + Time.now.strftime('%a %b %d at %I:%M %P (%z)').to_s .row / TODO: Clean this up, merge with all events page. @@ -23,12 +23,15 @@ - unless event_schedule.start_time.strftime('%Y-%m-%d').eql?(date) .col-xs-12.col-md-12 .date-content - %span{ class: 'date-title', id: "#{ event_schedule.start_time.strftime('%Y-%m-%d') }" } + %span.date-title{ id: event_schedule.start_time.strftime('%Y-%m-%d').to_s } = inyourtz(event_schedule.start_time, @conference.timezone) do = date = event_schedule.start_time.strftime('%Y-%m-%d') - %a{ title: "Go up", class: "pull-right", href: "#program" } - %i{ class: "fa fa-angle-double-up fa-lg", 'aria-hidden' => true } - - unless event_schedule.start_time.strftime('%H:%M').eql?(time) + %a.pull-right{ title: 'Go up', href: '#program' } + %i.fa.fa-angle-double-up.fa-lg{ 'aria-hidden' => true } + - if event_schedule.start_time.strftime('%H:%M').eql?(time) + .col-xs-12.col-md-11.col-md-offset-1 + = render 'event', event: event_schedule.event, event_schedule: event_schedule + - else .col-xs-12.col-md-1 .start-time = inyourtz(event_schedule.start_time, @conference.timezone) do @@ -36,9 +39,6 @@ .col-xs-12.col-md-11 .new-time-event = render 'event', event: event_schedule.event, event_schedule: event_schedule - - else - .col-xs-12.col-md-11.col-md-offset-1 - = render 'event', event: event_schedule.event, event_schedule: event_schedule :javascript // Refresh the page every 5 minutes. From 4ed0a02a886a9129098875c22cdae326c105cff1 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Thu, 11 Mar 2021 23:38:19 -0800 Subject: [PATCH 59/99] Revert "remove :linters group in gemfile" Bundler does not install the gems necessary to run linting without the linters group. This reverts commit a7cf2d480d0ad4404cfc4aaadc4c23bda3c11956. --- Gemfile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Gemfile b/Gemfile index 226932f5..97bf9ba6 100644 --- a/Gemfile +++ b/Gemfile @@ -266,7 +266,7 @@ group :test do gem 'pdf-inspector', require: "pdf/inspector" end -group :development, :test do +group :development, :test, :linters do # as debugger gem 'byebug' gem 'pry' From 33ce7a61c64bf758fb9fbc36c084334434109a7c Mon Sep 17 00:00:00 2001 From: Jimmy Date: Thu, 11 Mar 2021 23:39:06 -0800 Subject: [PATCH 60/99] [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 61/99] [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 62/99] [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 55c8801926d3c4a41638319dc2ad41b9470bf446 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 12 Mar 2021 00:25:20 -0800 Subject: [PATCH 63/99] Attempt upload of CodeCov to Code Climate --- .travis.yml | 14 ++++++-------- 1 file changed, 6 insertions(+), 8 deletions(-) diff --git a/.travis.yml b/.travis.yml index a94c68ef..6d1f206f 100644 --- a/.travis.yml +++ b/.travis.yml @@ -16,6 +16,8 @@ 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 @@ -26,20 +28,16 @@ notifications: on_success: change on_failure: change before_script: - # install CodeClimate test reporter and tell it we are starting a test run - # - curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > $CCTR - # - chmod +x $CCTR - # - $CCTR before-build - 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" # TODO Get this working. - # - $CCTR format-coverage -t simplecov --output coverage/codeclimate.$SUITE.json -# after_script: +after_script: # combine coverage from all suites, and upload3 to CodeClimate - # - $CCTR sum-coverage coverage/codeclimate.*.json | $CCTR upload-coverage - # - $CCTR after-build --exit-code $TRAVIS_TEST_RESULT + - $CCTR format-coverage -t simplecov --output coverage/codeclimate.$TEST_SUITE.json + - $CCTR sum-coverage coverage/codeclimate.*.json | $CCTR upload-coverage env: global: From fb5de3ec185e1af41bcbd33e2d17a299b778b2c9 Mon Sep 17 00:00:00 2001 From: CactusPuppy Date: Fri, 12 Mar 2021 00:40:19 -0800 Subject: [PATCH 64/99] Fix test coverage reporting hopefully --- .travis.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.travis.yml b/.travis.yml index 6d1f206f..4e6985a3 100644 --- a/.travis.yml +++ b/.travis.yml @@ -37,7 +37,8 @@ script: 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 | $CCTR upload-coverage + - $CCTR sum-coverage coverage/codeclimate.*.json + - if [[ "$TRAVIS_TEST_RESULT" == 0 ]]; then $CCTR upload-coverage; fi env: global: From 2bcd7d39b33f14e0aef7bc43ffe781ca91f2e61f Mon Sep 17 00:00:00 2001 From: Jimmy Date: Fri, 12 Mar 2021 07:49:55 -0800 Subject: [PATCH 65/99] [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 66/99] [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 67/99] 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 68/99] 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 69/99] 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 70/99] 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 71/99] 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 72/99] 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 73/99] 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 74/99] 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 75/99] 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 76/99] 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 77/99] 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 78/99] 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 79/99] 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 80/99] 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 81/99] 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 82/99] 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 83/99] 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 84/99] 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 85/99] 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 86/99] 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 87/99] 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 88/99] 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 89/99] 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 90/99] 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 91/99] 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 92/99] 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 93/99] 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 94/99] 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 95/99] 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 96/99] 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 97/99] 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 98/99] 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 99/99] 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