Merge branch 'master' into submission-reviewer-comments
* master: (246 commits) merge master Skip datatable spec because github actions is weird. Add devise view files for email messages Make the _mailbot_* files not depend on @conference Tweak devise text for confirm emails Run database migrations on release [fix]Add mailbot.css to assets.rb [fix]Fix empty string check [fix]Fix program#any_event_for_this_date? Add newline at end of show.js.erb file [feat]Display happening now only if program is also displayed [feat]Add brief version of event partial; fix style [feat]Description / happening now takes the entire row if the other is empty [feat]Use Ajax for paginating happening_now [style]Fix style [refactor]Delete unused javascript; Move about-and-happening-now to partial [feat]Add bootstrap style to pagination navbar [fix]Fix style; Re-enable checking happening now items per page pagination ...
This commit is contained in:
commit
6ce36c0fca
60 changed files with 878 additions and 152 deletions
6
.github/workflows/spec.yml
vendored
6
.github/workflows/spec.yml
vendored
|
|
@ -9,6 +9,7 @@ on:
|
|||
|
||||
jobs:
|
||||
linters:
|
||||
continue-on-error: true
|
||||
runs-on: ubuntu-latest
|
||||
env:
|
||||
OSEM_RUBY_VERSION: 2.6.6
|
||||
|
|
@ -16,11 +17,12 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
ruby-version: 2.6.6
|
||||
bundler-cache: true
|
||||
- run: bundle exec rubocop
|
||||
- run: bundle exec haml-lint app/views
|
||||
spec:
|
||||
continue-on-error: true
|
||||
runs-on: ubuntu-latest
|
||||
name: spec
|
||||
env:
|
||||
|
|
@ -34,7 +36,7 @@ jobs:
|
|||
- uses: actions/checkout@v2
|
||||
- uses: ruby/setup-ruby@v1
|
||||
with:
|
||||
ruby-version: 2.6
|
||||
ruby-version: 2.6.6
|
||||
bundler-cache: true
|
||||
- name: Prepare spec
|
||||
run: |
|
||||
|
|
|
|||
|
|
@ -248,6 +248,11 @@ linters:
|
|||
- "app/views/users/edit.html.haml"
|
||||
- "app/views/users/show.html.haml"
|
||||
|
||||
ConsecutiveComments:
|
||||
exclude:
|
||||
# This one seems like a bug in haml-lint.
|
||||
- "app/views/admin/conferences/show.html.haml"
|
||||
|
||||
# Offense count: 24
|
||||
ConsecutiveSilentScripts:
|
||||
exclude:
|
||||
|
|
@ -605,11 +610,6 @@ linters:
|
|||
- "app/views/admin/registrations/index.csv.haml"
|
||||
- "app/views/layouts/_admin.html.haml"
|
||||
|
||||
# Offense count: 1
|
||||
ImplicitDiv:
|
||||
exclude:
|
||||
- "app/views/admin/registrations/index.html.haml"
|
||||
|
||||
# Offense count: 9
|
||||
MultilinePipe:
|
||||
exclude:
|
||||
|
|
@ -637,7 +637,6 @@ linters:
|
|||
- "app/views/devise/passwords/new.html.haml"
|
||||
- "app/views/payments/new.html.haml"
|
||||
|
||||
|
||||
# Offense count: 13
|
||||
ViewLength:
|
||||
exclude:
|
||||
|
|
|
|||
13
Gemfile
13
Gemfile
|
|
@ -2,7 +2,7 @@
|
|||
|
||||
source 'https://rubygems.org'
|
||||
|
||||
ruby ENV['TRAVIS_RUBY_VERSION'] || '2.6.6'
|
||||
ruby ENV['TRAVIS_RUBY_VERSION'] || '~>2.6.6'
|
||||
|
||||
# rails-assets requires >= 1.8.4
|
||||
if Gem::Version.new(Bundler::VERSION) < Gem::Version.new('1.8.4')
|
||||
|
|
@ -27,6 +27,7 @@ gem 'paper_trail'
|
|||
# for upload management
|
||||
gem 'carrierwave'
|
||||
gem 'carrierwave-bombshelter'
|
||||
gem 'mimemagic', '~> 0.3.6'
|
||||
gem 'mini_magick'
|
||||
|
||||
# for internationalizing
|
||||
|
|
@ -138,8 +139,8 @@ gem 'prawn-rails'
|
|||
gem 'rqrcode'
|
||||
|
||||
# to render XLS spreadsheets
|
||||
gem 'axlsx', git: 'https://github.com/randym/axlsx.git'
|
||||
gem 'axlsx_rails'
|
||||
gem 'caxlsx'
|
||||
gem 'caxlsx_rails'
|
||||
|
||||
gem 'sentry-delayed_job'
|
||||
gem 'sentry-rails'
|
||||
|
|
@ -220,6 +221,12 @@ gem 'dalli'
|
|||
|
||||
gem 'icalendar'
|
||||
|
||||
# for making external requests easier
|
||||
gem 'httparty'
|
||||
|
||||
# pagination
|
||||
gem 'pagy', '<4.0'
|
||||
|
||||
# Use guard and spring for testing in development
|
||||
group :development do
|
||||
# to launch specs when files are modified
|
||||
|
|
|
|||
132
Gemfile.lock
132
Gemfile.lock
|
|
@ -1,37 +1,27 @@
|
|||
GIT
|
||||
remote: https://github.com/randym/axlsx.git
|
||||
revision: c593a08b2a929dac7aa8dc418b55e26b4c49dc34
|
||||
specs:
|
||||
axlsx (3.0.0.pre)
|
||||
htmlentities (~> 4.3, >= 4.3.4)
|
||||
mimemagic (~> 0.3)
|
||||
nokogiri (~> 1.8, >= 1.8.2)
|
||||
rubyzip (~> 1.2, >= 1.2.1)
|
||||
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
remote: https://rails-assets.org/
|
||||
specs:
|
||||
Ascii85 (1.0.3)
|
||||
actioncable (5.2.4.5)
|
||||
actionpack (= 5.2.4.5)
|
||||
actioncable (5.2.5)
|
||||
actionpack (= 5.2.5)
|
||||
nio4r (~> 2.0)
|
||||
websocket-driver (>= 0.6.1)
|
||||
actionmailer (5.2.4.5)
|
||||
actionpack (= 5.2.4.5)
|
||||
actionview (= 5.2.4.5)
|
||||
activejob (= 5.2.4.5)
|
||||
actionmailer (5.2.5)
|
||||
actionpack (= 5.2.5)
|
||||
actionview (= 5.2.5)
|
||||
activejob (= 5.2.5)
|
||||
mail (~> 2.5, >= 2.5.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
actionpack (5.2.4.5)
|
||||
actionview (= 5.2.4.5)
|
||||
activesupport (= 5.2.4.5)
|
||||
actionpack (5.2.5)
|
||||
actionview (= 5.2.5)
|
||||
activesupport (= 5.2.5)
|
||||
rack (~> 2.0, >= 2.0.8)
|
||||
rack-test (>= 0.6.3)
|
||||
rails-dom-testing (~> 2.0)
|
||||
rails-html-sanitizer (~> 1.0, >= 1.0.2)
|
||||
actionview (5.2.4.5)
|
||||
activesupport (= 5.2.4.5)
|
||||
actionview (5.2.5)
|
||||
activesupport (= 5.2.5)
|
||||
builder (~> 3.1)
|
||||
erubi (~> 1.4)
|
||||
rails-dom-testing (~> 2.0)
|
||||
|
|
@ -41,20 +31,20 @@ GEM
|
|||
activemodel (>= 4.1, < 6.2)
|
||||
case_transform (>= 0.2)
|
||||
jsonapi-renderer (>= 0.1.1.beta1, < 0.3)
|
||||
activejob (5.2.4.5)
|
||||
activesupport (= 5.2.4.5)
|
||||
activejob (5.2.5)
|
||||
activesupport (= 5.2.5)
|
||||
globalid (>= 0.3.6)
|
||||
activemodel (5.2.4.5)
|
||||
activesupport (= 5.2.4.5)
|
||||
activerecord (5.2.4.5)
|
||||
activemodel (= 5.2.4.5)
|
||||
activesupport (= 5.2.4.5)
|
||||
activemodel (5.2.5)
|
||||
activesupport (= 5.2.5)
|
||||
activerecord (5.2.5)
|
||||
activemodel (= 5.2.5)
|
||||
activesupport (= 5.2.5)
|
||||
arel (>= 9.0)
|
||||
activestorage (5.2.4.5)
|
||||
actionpack (= 5.2.4.5)
|
||||
activerecord (= 5.2.4.5)
|
||||
marcel (~> 0.3.1)
|
||||
activesupport (5.2.4.5)
|
||||
activestorage (5.2.5)
|
||||
actionpack (= 5.2.5)
|
||||
activerecord (= 5.2.5)
|
||||
marcel (~> 1.0.0)
|
||||
activesupport (5.2.5)
|
||||
concurrent-ruby (~> 1.0, >= 1.0.2)
|
||||
i18n (>= 0.7, < 2)
|
||||
minitest (~> 5.1)
|
||||
|
|
@ -65,8 +55,8 @@ GEM
|
|||
awesome_nested_set (>= 3.0)
|
||||
acts_as_list (0.9.19)
|
||||
activerecord (>= 3.0)
|
||||
addressable (2.6.0)
|
||||
public_suffix (>= 2.0.2, < 4.0)
|
||||
addressable (2.7.0)
|
||||
public_suffix (>= 2.0.2, < 5.0)
|
||||
afm (0.2.2)
|
||||
ajax-datatables-rails (0.4.3)
|
||||
railties (>= 4.0)
|
||||
|
|
@ -82,9 +72,6 @@ GEM
|
|||
awesome_nested_set (3.4.0)
|
||||
activerecord (>= 4.0.0, < 7.0)
|
||||
aws_cf_signer (0.1.3)
|
||||
axlsx_rails (0.5.2)
|
||||
actionpack (>= 3.1)
|
||||
axlsx (>= 2.0.1)
|
||||
bcrypt (3.1.16)
|
||||
bindex (0.6.0)
|
||||
bootstrap-sass (3.4.1)
|
||||
|
|
@ -94,15 +81,15 @@ GEM
|
|||
bootstrap3-datetimepicker-rails (4.17.47)
|
||||
momentjs-rails (>= 2.8.1)
|
||||
builder (3.2.4)
|
||||
byebug (11.0.1)
|
||||
byebug (11.1.3)
|
||||
cancancan (2.3.0)
|
||||
capybara (3.26.0)
|
||||
capybara (3.35.3)
|
||||
addressable
|
||||
mini_mime (>= 0.1.3)
|
||||
nokogiri (~> 1.8)
|
||||
rack (>= 1.6.0)
|
||||
rack-test (>= 0.6.3)
|
||||
regexp_parser (~> 1.5)
|
||||
regexp_parser (>= 1.5, < 3.0)
|
||||
xpath (~> 3.2)
|
||||
carrierwave (2.1.1)
|
||||
activemodel (>= 5.0.0)
|
||||
|
|
@ -118,6 +105,14 @@ GEM
|
|||
fastimage
|
||||
case_transform (0.2)
|
||||
activesupport
|
||||
caxlsx (3.1.0)
|
||||
htmlentities (~> 4.3, >= 4.3.4)
|
||||
marcel (~> 1.0)
|
||||
nokogiri (~> 1.10, >= 1.10.4)
|
||||
rubyzip (>= 1.3.0, < 3)
|
||||
caxlsx_rails (0.6.2)
|
||||
actionpack (>= 3.1)
|
||||
caxlsx (>= 3.0)
|
||||
chartkick (3.4.2)
|
||||
childprocess (3.0.0)
|
||||
chronic (0.10.2)
|
||||
|
|
@ -249,10 +244,10 @@ GEM
|
|||
httparty (0.18.1)
|
||||
mime-types (~> 3.0)
|
||||
multi_xml (>= 0.5.2)
|
||||
i18n (1.8.9)
|
||||
i18n (1.8.10)
|
||||
concurrent-ruby (~> 1.0)
|
||||
i18n_data (0.8.0)
|
||||
icalendar (2.7.0)
|
||||
icalendar (2.7.1)
|
||||
ice_cube (~> 0.16)
|
||||
ice_cube (0.16.3)
|
||||
image_processing (1.12.1)
|
||||
|
|
@ -293,18 +288,19 @@ GEM
|
|||
lumberjack (1.0.12)
|
||||
mail (2.7.1)
|
||||
mini_mime (>= 0.1.1)
|
||||
marcel (0.3.3)
|
||||
mimemagic (~> 0.3.2)
|
||||
marcel (1.0.0)
|
||||
method_source (0.8.2)
|
||||
mime-types (3.3.1)
|
||||
mime-types-data (~> 3.2015)
|
||||
mime-types-data (3.2021.0225)
|
||||
mimemagic (0.3.5)
|
||||
mimemagic (0.4.3)
|
||||
nokogiri (~> 1)
|
||||
rake
|
||||
mina (1.2.3)
|
||||
open4 (~> 1.3.4)
|
||||
rake
|
||||
mini_magick (4.9.5)
|
||||
mini_mime (1.0.2)
|
||||
mini_mime (1.0.3)
|
||||
mini_portile2 (2.5.0)
|
||||
minitest (5.14.4)
|
||||
momentjs-rails (2.20.1)
|
||||
|
|
@ -324,7 +320,7 @@ GEM
|
|||
nenv (0.3.0)
|
||||
netrc (0.11.0)
|
||||
nio4r (2.5.7)
|
||||
nokogiri (1.11.1)
|
||||
nokogiri (1.11.2)
|
||||
mini_portile2 (~> 2.5.0)
|
||||
racc (~> 1.4)
|
||||
notiffany (0.1.1)
|
||||
|
|
@ -362,6 +358,7 @@ GEM
|
|||
rack-openid (~> 1.3.1)
|
||||
open4 (1.3.4)
|
||||
orm_adapter (0.5.0)
|
||||
pagy (3.12.0)
|
||||
paper_trail (10.3.1)
|
||||
activerecord (>= 4.2)
|
||||
request_store (~> 1.1)
|
||||
|
|
@ -420,7 +417,7 @@ GEM
|
|||
pry-byebug (3.8.0)
|
||||
byebug (~> 11.0)
|
||||
pry (~> 0.10)
|
||||
public_suffix (3.1.1)
|
||||
public_suffix (4.0.6)
|
||||
puma (5.2.2)
|
||||
nio4r (~> 2.0)
|
||||
racc (1.5.2)
|
||||
|
|
@ -430,18 +427,18 @@ GEM
|
|||
ruby-openid (>= 2.1.8)
|
||||
rack-test (1.1.0)
|
||||
rack (>= 1.0, < 3)
|
||||
rails (5.2.4.5)
|
||||
actioncable (= 5.2.4.5)
|
||||
actionmailer (= 5.2.4.5)
|
||||
actionpack (= 5.2.4.5)
|
||||
actionview (= 5.2.4.5)
|
||||
activejob (= 5.2.4.5)
|
||||
activemodel (= 5.2.4.5)
|
||||
activerecord (= 5.2.4.5)
|
||||
activestorage (= 5.2.4.5)
|
||||
activesupport (= 5.2.4.5)
|
||||
rails (5.2.5)
|
||||
actioncable (= 5.2.5)
|
||||
actionmailer (= 5.2.5)
|
||||
actionpack (= 5.2.5)
|
||||
actionview (= 5.2.5)
|
||||
activejob (= 5.2.5)
|
||||
activemodel (= 5.2.5)
|
||||
activerecord (= 5.2.5)
|
||||
activestorage (= 5.2.5)
|
||||
activesupport (= 5.2.5)
|
||||
bundler (>= 1.3.0)
|
||||
railties (= 5.2.4.5)
|
||||
railties (= 5.2.5)
|
||||
sprockets-rails (>= 2.0.0)
|
||||
rails-assets-bootstrap (3.3.6)
|
||||
rails-assets-jquery (>= 1.9.1, < 3)
|
||||
|
|
@ -475,9 +472,9 @@ GEM
|
|||
rails-i18n (5.1.3)
|
||||
i18n (>= 0.7, < 2)
|
||||
railties (>= 5.0, < 6)
|
||||
railties (5.2.4.5)
|
||||
actionpack (= 5.2.4.5)
|
||||
activesupport (= 5.2.4.5)
|
||||
railties (5.2.5)
|
||||
actionpack (= 5.2.5)
|
||||
activesupport (= 5.2.5)
|
||||
method_source
|
||||
rake (>= 0.8.7)
|
||||
thor (>= 0.19.0, < 2.0)
|
||||
|
|
@ -489,7 +486,7 @@ GEM
|
|||
recaptcha (4.14.0)
|
||||
json
|
||||
redcarpet (3.5.1)
|
||||
regexp_parser (1.6.0)
|
||||
regexp_parser (2.1.1)
|
||||
request_store (1.4.1)
|
||||
rack (>= 1.4)
|
||||
responders (2.4.1)
|
||||
|
|
@ -678,8 +675,6 @@ DEPENDENCIES
|
|||
annotate
|
||||
autoprefixer-rails
|
||||
awesome_nested_set
|
||||
axlsx!
|
||||
axlsx_rails
|
||||
bootstrap-sass (~> 3.4.0)
|
||||
bootstrap-switch-rails (~> 3.0.0)
|
||||
bootstrap3-datetimepicker-rails (~> 4.17.47)
|
||||
|
|
@ -688,6 +683,8 @@ DEPENDENCIES
|
|||
capybara
|
||||
carrierwave
|
||||
carrierwave-bombshelter
|
||||
caxlsx
|
||||
caxlsx_rails
|
||||
chartkick
|
||||
climate_control
|
||||
cloudinary
|
||||
|
|
@ -712,6 +709,7 @@ DEPENDENCIES
|
|||
guard-rspec
|
||||
haml-lint
|
||||
haml-rails
|
||||
httparty
|
||||
icalendar
|
||||
iso-639
|
||||
jquery-datatables
|
||||
|
|
@ -721,6 +719,7 @@ DEPENDENCIES
|
|||
leaflet-rails
|
||||
letter_opener
|
||||
letter_opener_web (~> 1.0)
|
||||
mimemagic (~> 0.3.6)
|
||||
mina
|
||||
mini_magick
|
||||
money-rails
|
||||
|
|
@ -731,6 +730,7 @@ DEPENDENCIES
|
|||
omniauth-github
|
||||
omniauth-google-oauth2
|
||||
omniauth-openid
|
||||
pagy (< 4.0)
|
||||
paper_trail
|
||||
pdf-inspector
|
||||
pg
|
||||
|
|
|
|||
1
Procfile
1
Procfile
|
|
@ -1,2 +1,3 @@
|
|||
web: bundle exec rails server -b 0.0.0.0
|
||||
worker: bundle exec rails jobs:work
|
||||
release: rake db:migrate
|
||||
|
|
|
|||
|
|
@ -54,6 +54,7 @@
|
|||
//= require selectize
|
||||
//= require bootstrap-select
|
||||
//= require osem-survey
|
||||
//= require pagy
|
||||
|
||||
$(document).ready(function() {
|
||||
$('a[disabled=disabled]').click(function(event){
|
||||
|
|
@ -63,4 +64,6 @@ $(document).ready(function() {
|
|||
$('body').smoothScroll({
|
||||
delegateSelector: 'a.smoothscroll'
|
||||
});
|
||||
|
||||
window.addEventListener("load", Pagy.init);
|
||||
});
|
||||
|
|
|
|||
|
|
@ -149,13 +149,23 @@ function word_count(text, divId, maxcount) {
|
|||
});
|
||||
};
|
||||
|
||||
function fill_if_empty(text_area, filler) {
|
||||
let area = $('#' + text_area);
|
||||
function replace_defaut_submission_text(input_selector, new_text, valid_defaults) {
|
||||
let $area = $(input_selector);
|
||||
let current_text = $area.val();
|
||||
|
||||
if (!area.val()) {
|
||||
area.val(filler);
|
||||
area.trigger('change');
|
||||
if (!current_text) {
|
||||
$area.val(new_text);
|
||||
$area.trigger('change');
|
||||
return;
|
||||
}
|
||||
|
||||
valid_defaults.some(default_text => {
|
||||
if (current_text == default_text) {
|
||||
$area.val(new_text);
|
||||
$area.trigger('change');
|
||||
return true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/* Wait for the DOM to be ready before attaching events to the elements */
|
||||
|
|
@ -166,8 +176,13 @@ $( document ).ready(function() {
|
|||
var max = $selected.data("max-words");
|
||||
var min = $selected.data("min-words");
|
||||
|
||||
// Set the filler text for the submission text
|
||||
fill_if_empty('event_submission_text', $selected.data("instructions"));
|
||||
// We replace the default text only if the current field is empty,
|
||||
// or is set to the default text of another event type.
|
||||
replace_defaut_submission_text(
|
||||
'#event_submission_text',
|
||||
$selected.data("instructions"),
|
||||
$("#event_event_type_id option").toArray().map(e => $(e).data('instructions'))
|
||||
);
|
||||
|
||||
$("#abstract-maximum-word-count").text(max);
|
||||
$("#submission-maximum-word-count").text(max);
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ module Admin
|
|||
:include_venue, :include_registrations,
|
||||
:include_tickets, :include_lodgings,
|
||||
:include_sponsors, :include_social_media,
|
||||
:include_booths)
|
||||
:include_booths, :include_happening_now)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@
|
|||
class ApplicationController < ActionController::Base
|
||||
before_action :set_paper_trail_whodunnit
|
||||
include ApplicationHelper
|
||||
include Pagy::Backend
|
||||
add_flash_types :error
|
||||
protect_from_forgery with: :exception, prepend: true
|
||||
before_action :store_location
|
||||
|
|
|
|||
|
|
@ -57,6 +57,8 @@ class ConferenceRegistrationsController < ApplicationController
|
|||
sign_in(@registration.user)
|
||||
end
|
||||
|
||||
MailblusterEditLeadJob.perform_later(@user, add_tags: ["snapcon-#{@conference.short_title}"])
|
||||
|
||||
if @conference.tickets.visible.any? && !current_user.supports?(@conference)
|
||||
redirect_to conference_tickets_path(@conference.short_title),
|
||||
notice: 'You are now registered and will be receiving E-Mail notifications.'
|
||||
|
|
@ -87,6 +89,7 @@ class ConferenceRegistrationsController < ApplicationController
|
|||
|
||||
def destroy
|
||||
if @registration.destroy
|
||||
MailblusterEditLeadJob.perform_later(@user, remove_tags: ["snapcon-#{@conference.short_title}"])
|
||||
redirect_to root_path,
|
||||
notice: "You are not registered for #{@conference.title} anymore!"
|
||||
else
|
||||
|
|
|
|||
|
|
@ -1,6 +1,10 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
EVENTS_PER_PAGE = Rails.configuration.conference[:events_per_page]
|
||||
|
||||
class ConferencesController < ApplicationController
|
||||
include ConferenceHelper
|
||||
|
||||
protect_from_forgery with: :null_session
|
||||
before_action :respond_to_options
|
||||
load_and_authorize_resource find_by: :short_title, except: :show
|
||||
|
|
@ -56,6 +60,13 @@ class ConferencesController < ApplicationController
|
|||
if splashpage.include_booths
|
||||
@booths = @conference.confirmed_booths.order('title')
|
||||
end
|
||||
if splashpage.include_happening_now
|
||||
events_schedules_list = get_happening_now_events_schedules(@conference)
|
||||
@events_schedules_limit = EVENTS_PER_PAGE
|
||||
@events_schedules_length = events_schedules_list.length
|
||||
@pagy, @events_schedules = pagy_array(events_schedules_list, items: @events_schedules_limit, link_extra: 'data-remote="true"')
|
||||
@happening_now_url = happening_now_conference_schedule_path(conference_id: @conference.short_title, format: :json)
|
||||
end
|
||||
end
|
||||
if splashpage.include_registrations || splashpage.include_tickets
|
||||
@tickets = @conference.tickets.visible.order('price_cents')
|
||||
|
|
|
|||
|
|
@ -1,6 +1,8 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class SchedulesController < ApplicationController
|
||||
include ConferenceHelper
|
||||
|
||||
load_and_authorize_resource
|
||||
before_action :respond_to_options
|
||||
load_resource :conference, find_by: :short_title
|
||||
|
|
@ -67,11 +69,13 @@ class SchedulesController < ApplicationController
|
|||
end
|
||||
|
||||
def happening_now
|
||||
@events_schedules = @program.selected_event_schedules(
|
||||
includes: [:room, { event: %i[track event_type speakers submitter] }]
|
||||
).select(&:happening_now?)
|
||||
@events_schedules = [] unless @events_schedules
|
||||
@events_schedules = get_happening_now_events_schedules(@conference)
|
||||
@current_time = Time.now.in_time_zone(@conference.timezone)
|
||||
|
||||
respond_to do |format|
|
||||
format.html
|
||||
format.json { render json: @events_schedules.to_json(root: false, include: :event) }
|
||||
end
|
||||
end
|
||||
|
||||
def app
|
||||
|
|
|
|||
|
|
@ -1,6 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
module ApplicationHelper
|
||||
include Pagy::Frontend
|
||||
# Returns a string build from the start and end date of the given conference.
|
||||
#
|
||||
# If the conference is only one day long
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
DEFAULT_LOGO = 'snapcon_logo.png'
|
||||
DEFAULT_COLOR = '#0B3559'
|
||||
DEFAULT_LOGO = Rails.configuration.conference[:default_logo_filename]
|
||||
DEFAULT_COLOR = Rails.configuration.conference[:default_color]
|
||||
|
||||
module ConferenceHelper
|
||||
# Return true if only call_for_papers or call_for_tracks or call_for_booths is open
|
||||
|
|
@ -77,4 +77,12 @@ module ConferenceHelper
|
|||
end
|
||||
calendar
|
||||
end
|
||||
|
||||
def get_happening_now_events_schedules(conference)
|
||||
events_schedules = conference.program.selected_event_schedules(
|
||||
includes: [:room, { event: %i[track event_type speakers submitter] }]
|
||||
).select(&:happening_now?)
|
||||
events_schedules ||= []
|
||||
events_schedules
|
||||
end
|
||||
end
|
||||
|
|
|
|||
9
app/jobs/mailbluster_create_lead_job.rb
Normal file
9
app/jobs/mailbluster_create_lead_job.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MailblusterCreateLeadJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(user)
|
||||
MailblusterManager.create_lead(user)
|
||||
end
|
||||
end
|
||||
7
app/jobs/mailbluster_delete_lead_job.rb
Normal file
7
app/jobs/mailbluster_delete_lead_job.rb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
class MailblusterDeleteLeadJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(user)
|
||||
MailblusterManager.delete_lead(user)
|
||||
end
|
||||
end
|
||||
9
app/jobs/mailbluster_edit_lead_job.rb
Normal file
9
app/jobs/mailbluster_edit_lead_job.rb
Normal file
|
|
@ -0,0 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
class MailblusterEditLeadJob < ApplicationJob
|
||||
queue_as :default
|
||||
|
||||
def perform(user, add_tags: [], remove_tags: [], old_email: nil)
|
||||
MailblusterManager.edit_lead(user, add_tags: add_tags, remove_tags: remove_tags, old_email: old_email)
|
||||
end
|
||||
end
|
||||
|
|
@ -1,8 +1,9 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
SNAPCON_BCC_ADDRESS = 'messages@snap.berkeley.edu'
|
||||
EMAIL_TEMPLATE = 'email_template'
|
||||
YTLF_TICKET_ID = 50
|
||||
|
||||
SNAPCON_BCC_ADDRESS = Rails.configuration.mailbot[:bcc_address]
|
||||
YTLF_TICKET_ID = Rails.configuration.mailbot[:ytlf_ticket_id]
|
||||
|
||||
class Mailbot < ActionMailer::Base
|
||||
helper ConferenceHelper
|
||||
|
|
|
|||
48
app/models/concerns/track_saved_changes.rb
Normal file
48
app/models/concerns/track_saved_changes.rb
Normal file
|
|
@ -0,0 +1,48 @@
|
|||
# https://github.com/ccmcbeck/after-commit
|
||||
module TrackSavedChanges
|
||||
extend ActiveSupport::Concern
|
||||
|
||||
included do
|
||||
# expose the details if consumer wants to do more
|
||||
# attr_reader :ts_saved_changes_history, :ts_saved_changes_unfiltered
|
||||
after_initialize :ts_reset_saved_changes
|
||||
after_save :ts_track_saved_changes
|
||||
end
|
||||
|
||||
# on initalize, but useful for fine grain control
|
||||
def ts_reset_saved_changes
|
||||
@ts_saved_changes_unfiltered = {}
|
||||
@ts_saved_changes_history = []
|
||||
end
|
||||
|
||||
# filter out any changes that result in the original value
|
||||
def ts_saved_changes
|
||||
@ts_saved_changes_unfiltered.reject { |_k, v| v[0] == v[1] }
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
# on save
|
||||
def ts_track_saved_changes
|
||||
# maintain an array of ActiveModel::Dirty.changes
|
||||
@ts_saved_changes_history << previous_changes.dup
|
||||
# accumulate the most recent changes
|
||||
@ts_saved_changes_history.last.each_pair { |k, v| ts_track_saved_change k, v }
|
||||
end
|
||||
|
||||
# v is an an array of [prev, current]
|
||||
def ts_track_saved_change(key, value)
|
||||
if @ts_saved_changes_unfiltered.key? key
|
||||
@ts_saved_changes_unfiltered[key][1] = ts_track_saved_value value[1]
|
||||
else
|
||||
@ts_saved_changes_unfiltered[key] = value.dup
|
||||
end
|
||||
end
|
||||
|
||||
# type safe dup inspred by http://stackoverflow.com/a/20955038
|
||||
def ts_track_saved_value(value)
|
||||
value.dup
|
||||
rescue TypeError
|
||||
value
|
||||
end
|
||||
end
|
||||
|
|
@ -34,6 +34,8 @@
|
|||
class Event < ApplicationRecord
|
||||
include ActiveRecord::Transitions
|
||||
include RevisionCount
|
||||
include FormatHelper
|
||||
|
||||
has_paper_trail on: [:create, :update], ignore: [:updated_at, :guid, :week], meta: { conference_id: :conference_id }
|
||||
|
||||
acts_as_commentable
|
||||
|
|
@ -338,6 +340,10 @@ class Event < ApplicationRecord
|
|||
time <=> other.time
|
||||
end
|
||||
|
||||
def serializable_hash(options = {})
|
||||
super(options).merge('rendered_abstract' => markdown(abstract))
|
||||
end
|
||||
|
||||
private
|
||||
|
||||
##
|
||||
|
|
|
|||
|
|
@ -55,16 +55,19 @@ class EventSchedule < ApplicationRecord
|
|||
# True within `threshold` before and after the event.
|
||||
#
|
||||
def happening_now?(threshold = 30.minutes)
|
||||
# TODO: Save start_time with local timezone info when making an event schedule
|
||||
in_tz_start = start_time.in_time_zone(timezone)
|
||||
in_tz_end = end_time.in_time_zone(timezone)
|
||||
in_tz_start -= in_tz_start.utc_offset
|
||||
in_tz_end -= in_tz_end.utc_offset
|
||||
|
||||
return false if in_tz_end < Time.now
|
||||
|
||||
begin_range = Time.now - threshold
|
||||
end_range = Time.now + threshold
|
||||
event_time_range = in_tz_start..in_tz_end
|
||||
now_range = begin_range..end_range
|
||||
# TODO: There's probably better logic.
|
||||
event_time_range.overlaps?(now_range) && (in_tz_end > Time.now)
|
||||
event_time_range.overlaps?(now_range)
|
||||
end
|
||||
|
||||
def self.withdrawn_or_canceled_event_schedules(schedule_ids)
|
||||
|
|
|
|||
|
|
@ -195,6 +195,7 @@ class Program < ApplicationRecord
|
|||
# * +True+ -> If there is any event for the given date
|
||||
# * +False+ -> If there is not any event for the given date
|
||||
def any_event_for_this_date?(date)
|
||||
return false if date.nil? || date == ''
|
||||
return false unless selected_schedule.present?
|
||||
|
||||
parsed_date = DateTime.parse("#{date} 00:00").utc
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
# banner_photo_updated_at :datetime
|
||||
# include_booths :boolean
|
||||
# include_cfp :boolean default(FALSE)
|
||||
# include_happening_now :boolean
|
||||
# include_lodgings :boolean
|
||||
# include_program :boolean
|
||||
# include_registrations :boolean
|
||||
|
|
|
|||
|
|
@ -53,6 +53,7 @@ class UserDisabled < StandardError
|
|||
end
|
||||
|
||||
class User < ApplicationRecord
|
||||
include TrackSavedChanges
|
||||
rolify
|
||||
# prevent N+1 queries with has_cached_role? by preloading roles *always*
|
||||
default_scope { preload(:roles) }
|
||||
|
|
@ -80,6 +81,12 @@ class User < ApplicationRecord
|
|||
|
||||
after_save :touch_events
|
||||
|
||||
# Note that using after_create_commit and after_update_commit does not work.
|
||||
# See https://github.com/CactusPuppy/snapcon/pull/43#discussion_r609458034
|
||||
after_commit :mailbluster_create_lead, on: :create
|
||||
after_commit :mailbluster_delete_lead, on: :destroy
|
||||
after_commit :mailbluster_update_lead, on: :update, if: ->(user){ ['name', 'email'].any? { |key| user.ts_saved_changes.key? key } }
|
||||
|
||||
# add scope
|
||||
scope :comment_notifiable, ->(conference) {joins(:roles).where('roles.name IN (?)', [:organizer, :cfp]).where('roles.resource_type = ? AND roles.resource_id = ?', 'Conference', conference.id)}
|
||||
|
||||
|
|
@ -361,12 +368,32 @@ class User < ApplicationRecord
|
|||
User.count == 1 && User.first.email == 'deleted@localhost.osem'
|
||||
end
|
||||
|
||||
# TODO: email_hash function for mailbluster
|
||||
# def email_hash
|
||||
# Digest::MD5.hexdigest user.email
|
||||
# end
|
||||
|
||||
private
|
||||
|
||||
def setup_role
|
||||
self.is_admin = true if User.empty?
|
||||
end
|
||||
|
||||
def mailbluster_create_lead
|
||||
MailblusterCreateLeadJob.perform_later self
|
||||
ts_reset_saved_changes
|
||||
end
|
||||
|
||||
def mailbluster_delete_lead
|
||||
MailblusterDeleteLeadJob.perform_later email
|
||||
ts_reset_saved_changes
|
||||
end
|
||||
|
||||
def mailbluster_update_lead
|
||||
MailblusterEditLeadJob.perform_later(self, old_email: ts_saved_changes.fetch('email', [nil])[0])
|
||||
ts_reset_saved_changes
|
||||
end
|
||||
|
||||
def touch_events
|
||||
event_users.each(&:touch)
|
||||
end
|
||||
|
|
|
|||
40
app/services/mailbluster_manager.rb
Normal file
40
app/services/mailbluster_manager.rb
Normal file
|
|
@ -0,0 +1,40 @@
|
|||
class MailblusterManager
|
||||
include HTTParty
|
||||
base_uri 'https://api.mailbluster.com/api/leads/'
|
||||
@auth_headers = {
|
||||
headers: {
|
||||
'Content-Type' => 'application/json',
|
||||
'Authorization' => ENV['MAILBLUSTER_API_KEY']
|
||||
}
|
||||
}
|
||||
|
||||
def self.query_api(method, path, body: {})
|
||||
options = @auth_headers.merge(body: body.to_json)
|
||||
send(method, path, options).parsed_response
|
||||
end
|
||||
|
||||
def self.create_lead(user)
|
||||
query_api(:post, '/', body: {
|
||||
'email' => user.email,
|
||||
'firstName' => user.name,
|
||||
'overrideExisting' => true,
|
||||
'subscribed' => true,
|
||||
'tags' => [ENV['OSEM_NAME'] || 'snapcon']
|
||||
})
|
||||
end
|
||||
|
||||
def self.edit_lead(user, add_tags: [], remove_tags: [], old_email: nil)
|
||||
email_hash = Digest::MD5.hexdigest(old_email.presence || user.email)
|
||||
query_api(:put, "/#{email_hash}", body: {
|
||||
'email' => user.email,
|
||||
'firstName' => user.name,
|
||||
'addTags' => add_tags,
|
||||
'removeTags' => remove_tags
|
||||
})
|
||||
end
|
||||
|
||||
def self.delete_lead(email)
|
||||
email_hash = Digest::MD5.hexdigest email
|
||||
query_api(:delete, "/#{email_hash}")
|
||||
end
|
||||
end
|
||||
|
|
@ -20,7 +20,7 @@
|
|||
combined_data: @registration_distribution
|
||||
.row
|
||||
.col-md-12
|
||||
%div.margin-event-table
|
||||
.margin-event-table
|
||||
%table.datatable#registrations{ data: { source: admin_conference_registrations_path(conference_id: @conference, format: :json) } }
|
||||
%thead
|
||||
%tr
|
||||
|
|
|
|||
|
|
@ -25,6 +25,8 @@
|
|||
= f.input :include_tracks, label: 'Include confirmed tracks', input_html: { checked: params[:action] == 'new' || @splashpage.try(:include_tracks) }
|
||||
%li
|
||||
= f.input :include_booths, label: "Include confirmed #{(t'booth').pluralize}", input_html: { checked: params[:action] == 'new' || @splashpage.try(:include_booths) }
|
||||
%li
|
||||
= f.input :include_happening_now, label: 'Include events happening now', input_html: { checked: params[:action] == 'new' || @splashpage.try(:include_happening_now) }
|
||||
|
||||
%li
|
||||
= f.input :include_registrations, label: 'Display the registration period', input_html: { checked: params[:action] == 'new' || @splashpage.try(:include_registrations) }
|
||||
|
|
|
|||
|
|
@ -27,6 +27,9 @@
|
|||
%li
|
||||
%i{ class: "fa-li #{icon_for_todo @splashpage.include_booths?}" }
|
||||
Include confirmed #{(t'booth').pluralize}
|
||||
%li
|
||||
%i{ class: "fa-li #{icon_for_todo @splashpage.include_happening_now?}" }
|
||||
Include events happening now
|
||||
%li
|
||||
%i{ class: "fa-li #{icon_for_todo @splashpage.include_registrations?}" }
|
||||
Display the registration period
|
||||
|
|
|
|||
32
app/views/conferences/_about_and_happening_now.haml
Normal file
32
app/views/conferences/_about_and_happening_now.haml
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
= content_for :happening_now do
|
||||
#happening-now
|
||||
= render 'happening_now', conference: conference,
|
||||
events_schedules: events_schedules, pagy: pagy,
|
||||
events_schedules_length: events_schedules_length,
|
||||
events_schedules_limit: events_schedules_limit
|
||||
|
||||
= content_for :about do
|
||||
#about
|
||||
.row
|
||||
%h2.text-left{ style: 'margin-bottom:30px' } About the Conference
|
||||
= markdown(conference.description, false)
|
||||
|
||||
%section#about-and-happening-now
|
||||
.container
|
||||
.row
|
||||
-# happening now events are displayed second in md or lg view
|
||||
- if conference.splashpage.include_happening_now && conference.splashpage.include_program
|
||||
- if conference.description.present?
|
||||
.col-md-6.col-md-push-6.col-lg-4.col-lg-push-8
|
||||
= yield :happening_now
|
||||
- else
|
||||
.col-md-12
|
||||
= yield :happening_now
|
||||
- if conference.description.present?
|
||||
- if conference.splashpage.include_happening_now && conference.splashpage.include_program
|
||||
.col-md-6.col-md-pull-6.col-lg-8.col-lg-pull-4
|
||||
= yield :about
|
||||
- else
|
||||
.col-md-12
|
||||
= yield :about
|
||||
.trapezoid
|
||||
12
app/views/conferences/_happening_now.haml
Normal file
12
app/views/conferences/_happening_now.haml
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
- if conference.splashpage.include_program && conference.splashpage.include_happening_now
|
||||
- if events_schedules.any?
|
||||
.row
|
||||
%h2.text-center{ style: 'margin-bottom:30px' } Happening Now
|
||||
- events_schedules.each do |event_schedule|
|
||||
= render 'schedules/event', conference: conference, event_schedule: event_schedule, event: event_schedule.event, is_brief: true
|
||||
- if events_schedules_length > events_schedules_limit
|
||||
.container{ style: 'width:100%; text-align:center' }
|
||||
!= pagy_bootstrap_nav_js(pagy)
|
||||
- else
|
||||
.row
|
||||
%h3.text-center There are no events happening now.
|
||||
|
|
@ -26,11 +26,3 @@
|
|||
- if venue.country != 'US'
|
||||
•
|
||||
= venue.country_name
|
||||
|
||||
- unless conference.description.blank?
|
||||
%section#about
|
||||
.container
|
||||
.row
|
||||
.col-md-8.col-md-offset-2
|
||||
= markdown(conference.description, escape_html=false)
|
||||
.trapezoid
|
||||
|
|
|
|||
|
|
@ -41,9 +41,16 @@
|
|||
- if @conference.code_of_conduct.present?
|
||||
= render 'code_of_conduct', organization: @conference.organization
|
||||
|
||||
-# header/description
|
||||
-# header
|
||||
= render 'header', conference: @conference, venue: @conference.venue
|
||||
|
||||
-# description / happening now
|
||||
- if @conference.splashpage.include_happening_now? || @conference.description.present?
|
||||
= render 'about_and_happening_now', conference: @conference,
|
||||
events_schedules: @events_schedules, pagy: @pagy,
|
||||
events_schedules_length: @events_schedules_length,
|
||||
events_schedules_limit: @events_schedules_limit
|
||||
|
||||
-# calls for content, or program
|
||||
- if @conference.splashpage.include_cfp
|
||||
= render 'call_for_content', conference: @conference,
|
||||
|
|
|
|||
5
app/views/conferences/show.js.erb
Normal file
5
app/views/conferences/show.js.erb
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
$('#happening-now').html("<%= j(render 'happening_now', conference: @conference,
|
||||
events_schedules: @events_schedules, pagy: @pagy,
|
||||
events_schedules_length: @events_schedules_length,
|
||||
events_schedules_limit: @events_schedules_limit)%>");
|
||||
Pagy.init(document.getElementById('happening-now'));
|
||||
|
|
@ -4,7 +4,7 @@
|
|||
.panel.panel-default
|
||||
.panel-heading
|
||||
%h3.panel-title
|
||||
Resend confirmation instructions
|
||||
Resend account confirmation instructions
|
||||
.panel-body
|
||||
= semantic_form_for(resource, as: resource_name, url: confirmation_path(resource_name), method: :post) do |f|
|
||||
= f.input :email, input_html: { autofocus: true, required: true }
|
||||
|
|
|
|||
|
|
@ -0,0 +1,9 @@
|
|||
<%= render partial: "layouts/mailbot_header" %>
|
||||
<div id="content">
|
||||
<p>Welcome to Snap!Con <%= @email %>!</p>
|
||||
|
||||
<p>You can confirm your account email through the link below:</p>
|
||||
|
||||
<p><%= link_to 'Confirm my account', confirmation_url(@resource, confirmation_token: @token) %></p>
|
||||
</div>
|
||||
<%= render partial: "layouts/mailbot_footer" %>
|
||||
7
app/views/devise/mailer/email_changed.html.erb
Normal file
7
app/views/devise/mailer/email_changed.html.erb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<p>Hello <%= @email %>!</p>
|
||||
|
||||
<% if @resource.try(:unconfirmed_email?) %>
|
||||
<p>We're contacting you to notify you that your email is being changed to <%= @resource.unconfirmed_email %>.</p>
|
||||
<% else %>
|
||||
<p>We're contacting you to notify you that your email has been changed to <%= @resource.email %>.</p>
|
||||
<% end %>
|
||||
3
app/views/devise/mailer/password_change.html.erb
Normal file
3
app/views/devise/mailer/password_change.html.erb
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>We're contacting you to notify you that your password has been changed.</p>
|
||||
|
|
@ -0,0 +1,8 @@
|
|||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Someone has requested a link to change your password. You can do this through the link below.</p>
|
||||
|
||||
<p><%= link_to 'Change my password', edit_password_url(@resource, reset_password_token: @token) %></p>
|
||||
|
||||
<p>If you didn't request this, please ignore this email.</p>
|
||||
<p>Your password won't change until you access the link above and create a new one.</p>
|
||||
7
app/views/devise/mailer/unlock_instructions.html.erb
Normal file
7
app/views/devise/mailer/unlock_instructions.html.erb
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
<p>Hello <%= @resource.email %>!</p>
|
||||
|
||||
<p>Your account has been locked due to an excessive number of unsuccessful sign in attempts.</p>
|
||||
|
||||
<p>Click the link below to unlock your account:</p>
|
||||
|
||||
<p><%= link_to 'Unlock my account', unlock_url(@resource, unlock_token: @token) %></p>
|
||||
|
|
@ -1,12 +1,7 @@
|
|||
<html lang="en">
|
||||
<head>
|
||||
<meta charset="utf-8"/>
|
||||
<meta content="width=device-width, initial-scale=1" name="viewport"/>
|
||||
<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" %>
|
||||
</head>
|
||||
<body>
|
||||
<div id="border" style="background-color: <%= conference_color(@conference) %>"></div>
|
||||
<% if @conference.present? %>
|
||||
<div id="border" style="background-color: <%= conference_color(@conference) %>">
|
||||
<% else %>
|
||||
<div id="border" style="background-color: #003262">
|
||||
<% end %>
|
||||
</body>
|
||||
</html>
|
||||
|
|
@ -9,17 +9,21 @@
|
|||
<meta content="Michael Ball, Brian Harvey, Jens Moenig, Bernat Romagosa, Dan Garcia, Lauren Mock" name="author"/>
|
||||
<%= stylesheet_link_tag "mailbot" %>
|
||||
</head>
|
||||
|
||||
<body>
|
||||
|
||||
<% if @conference.present? %>
|
||||
<div id="border" style="background-color: <%= conference_color(@conference) %>">
|
||||
<% else %>
|
||||
<div id="border" style="background-color: #003262">
|
||||
<% end %>
|
||||
<div class="row">
|
||||
<div class="col-md-2">
|
||||
<% if @conference.present? %>
|
||||
<%= image_tag(conference_logo_url(@conference), style: "display:block;height:70px;width:auto;", alt: @conference.title + ' logo') %>
|
||||
<% else %>
|
||||
<%= image_tag(Organization.first.picture_url, style: "display:block;height:70px;width:auto;", alt: ENV['OSEM_NAME'] + ' logo') %>
|
||||
<% end %>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
|
|
@ -8,6 +8,12 @@
|
|||
= render partial: 'payment'
|
||||
.row
|
||||
.col-md-13
|
||||
%p.text-center
|
||||
%strong
|
||||
If you do not have a credit card, please reach out to use at
|
||||
= mail_to(@conference.contact.email)
|
||||
%hr
|
||||
|
||||
%p.text-muted.text-center
|
||||
%small
|
||||
All payments are handled securely by our payment processor,
|
||||
|
|
|
|||
|
|
@ -2,6 +2,7 @@
|
|||
- header_color = event.event_type&.color || '#f5f5f5'
|
||||
.trapezoid{ style: 'color: white; top: 12px; z-index: 100;' }
|
||||
.panel-heading{ style: "background-color: #{header_color}; color: #{ contrast_color(header_color) }; border-radius: 4px" }
|
||||
- if !defined?(is_brief) || is_brief == false
|
||||
- event.speakers_ordered.each do |speaker|
|
||||
= image_tag speaker.profile_picture, class: 'img-circle pull-right', alt: speaker.name, style: 'padding: 2px;'
|
||||
|
||||
|
|
@ -14,7 +15,8 @@
|
|||
%br
|
||||
%small{ style: "color: #{contrast_color(header_color)}" }
|
||||
= event.subtitle
|
||||
.trapezoid{ style: "color: #{header_color}; top: 12px;" }
|
||||
|
||||
.trapezoid{ style: "color: #{header_color}; border-top-color: #{header_color}; top: 12px;" }
|
||||
|
||||
.panel-body
|
||||
%h4
|
||||
|
|
@ -26,6 +28,7 @@
|
|||
= markdown(truncate(event.abstract, length: 400))
|
||||
-# TODO: More informative text or aria-label.
|
||||
= link_to 'more', conference_program_proposal_path(@conference.short_title, event.id) if event.abstract.length > 400
|
||||
- if !defined?(is_brief) || is_brief == false
|
||||
- if event_schedule.present?
|
||||
= inyourtz(event_schedule.start_time) do
|
||||
%span.track
|
||||
|
|
|
|||
|
|
@ -66,6 +66,12 @@ module Osem
|
|||
|
||||
config.active_job.queue_adapter = :delayed_job
|
||||
|
||||
config.conference = {
|
||||
events_per_page: (ENV['EVENTS_PER_PAGE'] || 3),
|
||||
default_logo_filename: (ENV['DEFAULT_LOGO_FILENAME'] || 'snapcon_logo.png'),
|
||||
default_color: (ENV['DEFAULT_COLOR'] || '#0B3559')
|
||||
}
|
||||
|
||||
config.before_configuration do
|
||||
env_file = File.join(Rails.root, 'config', 'local_env.yml')
|
||||
if File.exist?(env_file)
|
||||
|
|
|
|||
|
|
@ -44,6 +44,12 @@ Osem::Application.configure do
|
|||
# Set the secret key base if it's not set via other means
|
||||
config.secret_key_base ||= 'f4be765bc98e516de82ac01daa8f8aa11c5ca13cb6c911887851ac89457b6c0b056b2361a21b5c08926c9386e0f91eef84fc0b103d522bf00bc0c78ea8ce7c58'
|
||||
|
||||
# Test mailbot settings
|
||||
config.mailbot = {
|
||||
ytlf_ticket_id: 50,
|
||||
bcc_address: 'test@test.com'
|
||||
}
|
||||
|
||||
# Use omniauth mock credentials
|
||||
OmniAuth.config.test_mode = true
|
||||
|
||||
|
|
@ -114,6 +120,5 @@ Osem::Application.configure do
|
|||
end
|
||||
end
|
||||
|
||||
config.assets.precompile += ['mailbot.css']
|
||||
config.active_record.verbose_query_logs = true
|
||||
end
|
||||
|
|
|
|||
|
|
@ -101,4 +101,10 @@ Osem::Application.configure do
|
|||
|
||||
# Set the secret_key_base from the env, if not set by any other means
|
||||
config.secret_key_base ||= ENV["SECRET_KEY_BASE"]
|
||||
|
||||
# Mailbot settings
|
||||
config.mailbot = {
|
||||
ytlf_ticket_id: (ENV['YTLF_TICKET_ID'] || 50),
|
||||
bcc_address: ENV['OSEM_MESSAGE_BCC_ADDRESS']
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -52,5 +52,9 @@ Osem::Application.configure do
|
|||
ActiveSupport::Deprecation.silenced = true
|
||||
end
|
||||
|
||||
config.assets.precompile += ['mailbot.css']
|
||||
# Test mailbot settings
|
||||
config.mailbot = {
|
||||
ytlf_ticket_id: 50,
|
||||
bcc_address: 'test@test.com'
|
||||
}
|
||||
end
|
||||
|
|
|
|||
|
|
@ -9,3 +9,4 @@ Rails.application.config.assets.version = '1.0'
|
|||
# Precompile additional assets.
|
||||
# application.js, application.css, and all non-JS/CSS in app/assets folder are already added.
|
||||
# Rails.application.config.assets.precompile += %w( search.js )
|
||||
Rails.application.config.assets.precompile += ['mailbot.css']
|
||||
|
|
|
|||
164
config/initializers/pagy.rb
Normal file
164
config/initializers/pagy.rb
Normal file
|
|
@ -0,0 +1,164 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
# Pagy initializer file (4.1.0)
|
||||
# Customize only what you really need and notice that Pagy works also without any of the following lines.
|
||||
# Should you just cherry pick part of this file, please maintain the require-order of the extras
|
||||
|
||||
# Extras
|
||||
# See https://ddnexus.github.io/pagy/extras
|
||||
|
||||
# Backend Extras
|
||||
|
||||
# Array extra: Paginate arrays efficiently, avoiding expensive array-wrapping and without overriding
|
||||
# See https://ddnexus.github.io/pagy/extras/array
|
||||
require 'pagy/extras/array'
|
||||
|
||||
# Countless extra: Paginate without any count, saving one query per rendering
|
||||
# See https://ddnexus.github.io/pagy/extras/countless
|
||||
# require 'pagy/extras/countless'
|
||||
# Pagy::VARS[:cycle] = false # default
|
||||
|
||||
# Elasticsearch Rails extra: Paginate `ElasticsearchRails::Results` objects
|
||||
# See https://ddnexus.github.io/pagy/extras/elasticsearch_rails
|
||||
# default :pagy_search method: change only if you use
|
||||
# also the searchkick extra that defines the same
|
||||
# VARS[:elasticsearch_rails_search_method] = :pagy_search
|
||||
# require 'pagy/extras/elasticsearch_rails'
|
||||
|
||||
# Searchkick extra: Paginate `Searchkick::Results` objects
|
||||
# See https://ddnexus.github.io/pagy/extras/searchkick
|
||||
# default :pagy_search method: change only if you use
|
||||
# also the elasticsearch_rails extra that defines the same
|
||||
# VARS[:searchkick_search_method] = :pagy_search
|
||||
# require 'pagy/extras/searchkick'
|
||||
|
||||
# Frontend Extras
|
||||
|
||||
# Bootstrap extra: Add nav, nav_js and combo_nav_js helpers and templates for Bootstrap pagination
|
||||
# See https://ddnexus.github.io/pagy/extras/bootstrap
|
||||
require 'pagy/extras/bootstrap'
|
||||
|
||||
# Bulma extra: Add nav, nav_js and combo_nav_js helpers and templates for Bulma pagination
|
||||
# See https://ddnexus.github.io/pagy/extras/bulma
|
||||
# require 'pagy/extras/bulma'
|
||||
|
||||
# Foundation extra: Add nav, nav_js and combo_nav_js helpers and templates for Foundation pagination
|
||||
# See https://ddnexus.github.io/pagy/extras/foundation
|
||||
# require 'pagy/extras/foundation'
|
||||
|
||||
# Materialize extra: Add nav, nav_js and combo_nav_js helpers for Materialize pagination
|
||||
# See https://ddnexus.github.io/pagy/extras/materialize
|
||||
# require 'pagy/extras/materialize'
|
||||
|
||||
# Navs extra: Add nav_js and combo_nav_js javascript helpers
|
||||
# Notice: the other frontend extras add their own framework-styled versions,
|
||||
# so require this extra only if you need the unstyled version
|
||||
# See https://ddnexus.github.io/pagy/extras/navs
|
||||
# require 'pagy/extras/navs'
|
||||
|
||||
# Semantic extra: Add nav, nav_js and combo_nav_js helpers for Semantic UI pagination
|
||||
# See https://ddnexus.github.io/pagy/extras/semantic
|
||||
# require 'pagy/extras/semantic'
|
||||
|
||||
# UIkit extra: Add nav helper and templates for UIkit pagination
|
||||
# See https://ddnexus.github.io/pagy/extras/uikit
|
||||
# require 'pagy/extras/uikit'
|
||||
|
||||
# Multi size var used by the *_nav_js helpers
|
||||
# See https://ddnexus.github.io/pagy/extras/navs#steps
|
||||
# Pagy::VARS[:steps] = { 0 => [2,3,3,2], 540 => [3,5,5,3], 720 => [5,7,7,5] } # example
|
||||
|
||||
# Feature Extras
|
||||
|
||||
# Headers extra: http response headers (and other helpers) useful for API pagination
|
||||
# See http://ddnexus.github.io/pagy/extras/headers
|
||||
# require 'pagy/extras/headers'
|
||||
# Pagy::VARS[:headers] = { page: 'Current-Page', items: 'Page-Items', count: 'Total-Count', pages: 'Total-Pages' } # default
|
||||
|
||||
# Support extra: Extra support for features like: incremental, infinite, auto-scroll pagination
|
||||
# See https://ddnexus.github.io/pagy/extras/support
|
||||
# require 'pagy/extras/support'
|
||||
|
||||
# Items extra: Allow the client to request a custom number of items per page with an optional selector UI
|
||||
# See https://ddnexus.github.io/pagy/extras/items
|
||||
# require 'pagy/extras/items'
|
||||
# Pagy::VARS[:items_param] = :items # default
|
||||
# Pagy::VARS[:max_items] = 100 # default
|
||||
|
||||
# Overflow extra: Allow for easy handling of overflowing pages
|
||||
# See https://ddnexus.github.io/pagy/extras/overflow
|
||||
# require 'pagy/extras/overflow'
|
||||
# Pagy::VARS[:overflow] = :empty_page # default (other options: :last_page and :exception)
|
||||
|
||||
# Metadata extra: Provides the pagination metadata to Javascript frameworks like Vue.js, react.js, etc.
|
||||
# See https://ddnexus.github.io/pagy/extras/metadata
|
||||
# you must require the shared internal extra (BEFORE the metadata extra) ONLY if you need also the :sequels
|
||||
# require 'pagy/extras/shared'
|
||||
# require 'pagy/extras/metadata'
|
||||
# For performance reason, you should explicitly set ONLY the metadata you use in the frontend
|
||||
# Pagy::VARS[:metadata] = [:scaffold_url, :count, :page, :prev, :next, :last] # example
|
||||
|
||||
# Trim extra: Remove the page=1 param from links
|
||||
# See https://ddnexus.github.io/pagy/extras/trim
|
||||
# require 'pagy/extras/trim'
|
||||
|
||||
# Pagy Variables
|
||||
# See https://ddnexus.github.io/pagy/api/pagy#variables
|
||||
# All the Pagy::VARS are set for all the Pagy instances but can be overridden
|
||||
# per instance by just passing them to Pagy.new or the #pagy controller method
|
||||
|
||||
# Instance variables
|
||||
# See https://ddnexus.github.io/pagy/api/pagy#instance-variables
|
||||
# Pagy::VARS[:items] = 20 # default
|
||||
|
||||
# Other Variables
|
||||
# See https://ddnexus.github.io/pagy/api/pagy#other-variables
|
||||
# Pagy::VARS[:size] = [1,4,4,1] # default
|
||||
# Pagy::VARS[:page_param] = :page # default
|
||||
# Pagy::VARS[:params] = {} # default
|
||||
# Pagy::VARS[:anchor] = '#anchor' # example
|
||||
# Pagy::VARS[:link_extra] = 'data-remote="true"' # example
|
||||
|
||||
# Rails
|
||||
|
||||
# Rails: extras assets path required by the helpers that use javascript
|
||||
# (pagy*_nav_js, pagy*_combo_nav_js, and pagy_items_selector_js)
|
||||
# See https://ddnexus.github.io/pagy/extras#javascript
|
||||
Rails.application.config.assets.paths << Pagy.root.join('javascripts')
|
||||
|
||||
# I18n
|
||||
|
||||
# Pagy internal I18n: ~18x faster using ~10x less memory than the i18n gem
|
||||
# See https://ddnexus.github.io/pagy/api/frontend#i18n
|
||||
# Notice: No need to configure anything in this section if your app uses only "en"
|
||||
# or if you use the i18n extra below
|
||||
#
|
||||
# Examples:
|
||||
# load the "de" built-in locale:
|
||||
# Pagy::I18n.load(locale: 'de')
|
||||
#
|
||||
# load the "de" locale defined in the custom file at :filepath:
|
||||
# Pagy::I18n.load(locale: 'de', filepath: 'path/to/pagy-de.yml')
|
||||
#
|
||||
# load the "de", "en" and "es" built-in locales:
|
||||
# (the first passed :locale will be used also as the default_locale)
|
||||
# Pagy::I18n.load({locale: 'de'},
|
||||
# {locale: 'en'},
|
||||
# {locale: 'es'})
|
||||
#
|
||||
# load the "en" built-in locale, a custom "es" locale,
|
||||
# and a totally custom locale complete with a custom :pluralize proc:
|
||||
# (the first passed :locale will be used also as the default_locale)
|
||||
# Pagy::I18n.load({locale: 'en'},
|
||||
# {locale: 'es', filepath: 'path/to/pagy-es.yml'},
|
||||
# {locale: 'xyz', # not built-in
|
||||
# filepath: 'path/to/pagy-xyz.yml',
|
||||
# pluralize: lambda{|count| ... } )
|
||||
|
||||
# I18n extra: uses the standard i18n gem which is ~18x slower using ~10x more memory
|
||||
# than the default pagy internal i18n (see above)
|
||||
# See https://ddnexus.github.io/pagy/extras/i18n
|
||||
# require 'pagy/extras/i18n'
|
||||
|
||||
# Default i18n key
|
||||
# Pagy::VARS[:i18n_key] = 'pagy.item_name' # default
|
||||
|
|
@ -51,8 +51,8 @@ en:
|
|||
failure: 'Could not authenticate you from %{kind} because "%{reason}".'
|
||||
mailer:
|
||||
confirmation_instructions:
|
||||
subject: 'Confirmation instructions'
|
||||
subject: 'Snap!Con: New Account Confirmation'
|
||||
reset_password_instructions:
|
||||
subject: 'Reset password instructions'
|
||||
subject: 'Snap!Con: Reset Your Password'
|
||||
unlock_instructions:
|
||||
subject: 'Unlock Instructions'
|
||||
subject: 'Snap!Con: Unlock Your Account'
|
||||
|
|
|
|||
|
|
@ -0,0 +1,5 @@
|
|||
class AddIncludeHappeningNowToSplashpages < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :splashpages, :include_happening_now, :boolean
|
||||
end
|
||||
end
|
||||
10
db/schema.rb
10
db/schema.rb
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2021_03_06_185903) do
|
||||
ActiveRecord::Schema.define(version: 2021_04_01_050437) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
|
|
@ -269,6 +269,13 @@ ActiveRecord::Schema.define(version: 2021_03_06_185903) do
|
|||
t.datetime "created_at"
|
||||
end
|
||||
|
||||
create_table "events_users", id: false, force: :cascade do |t|
|
||||
t.bigint "event_id"
|
||||
t.bigint "user_id"
|
||||
t.index ["event_id"], name: "index_events_users_on_event_id"
|
||||
t.index ["user_id"], name: "index_events_users_on_user_id"
|
||||
end
|
||||
|
||||
create_table "lodgings", force: :cascade do |t|
|
||||
t.string "name"
|
||||
t.text "description"
|
||||
|
|
@ -443,6 +450,7 @@ ActiveRecord::Schema.define(version: 2021_03_06_185903) do
|
|||
t.boolean "include_cfp", default: false
|
||||
t.boolean "include_booths"
|
||||
t.boolean "shuffle_highlights", default: false, null: false
|
||||
t.boolean "include_happening_now"
|
||||
end
|
||||
|
||||
create_table "sponsors", force: :cascade do |t|
|
||||
|
|
|
|||
|
|
@ -48,5 +48,4 @@ describe ConferencesController do
|
|||
expect(response.response_code).to eq(200)
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
|
|||
|
|
@ -27,4 +27,49 @@ describe SchedulesController do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe 'GET #happening_now' do
|
||||
let!(:conference2) { create(:full_conference, start_date: 1.day.ago, end_date: 7.days.from_now, start_hour: 0, end_hour: 24) }
|
||||
let!(:program) { conference2.program }
|
||||
let!(:selected_schedule) { create(:schedule, program: program) }
|
||||
let!(:scheduled_event1) do
|
||||
program.update_attributes!(selected_schedule: selected_schedule)
|
||||
create(:event, program: program, state: 'confirmed', abstract: '`markdown`')
|
||||
end
|
||||
let!(:event_schedule1) { create(:event_schedule, event: scheduled_event1, schedule: selected_schedule, start_time: Time.now.in_time_zone(conference2.timezone).strftime('%a, %d %b %Y %H:%M:%S')) }
|
||||
let!(:scheduled_event2) do
|
||||
program.update_attributes!(selected_schedule: selected_schedule)
|
||||
create(:event, program: program, state: 'confirmed')
|
||||
end
|
||||
let!(:event_schedule2) { create(:event_schedule, event: scheduled_event2, schedule: selected_schedule, start_time: (Time.now.in_time_zone(conference2.timezone) + 1.hour).strftime('%a, %d %b %Y %H:%M:%S')) }
|
||||
|
||||
context 'html' do
|
||||
before :each do
|
||||
get :happening_now, params: { conference_id: conference2.short_title }
|
||||
end
|
||||
|
||||
it 'has 200 status code' do
|
||||
expect(response).to be_success
|
||||
end
|
||||
end
|
||||
|
||||
context 'json' do
|
||||
before :each do
|
||||
get :happening_now, format: :json, params: { conference_id: conference2.short_title }
|
||||
end
|
||||
|
||||
it 'has 200 status code' do
|
||||
expect(response).to be_success
|
||||
end
|
||||
|
||||
it 'returns the events that are happening now' do
|
||||
expect(response.body).to include(event_schedule1.to_json(include: :event))
|
||||
expect(response.body).not_to include(event_schedule2.to_json(include: :event))
|
||||
end
|
||||
|
||||
it 'contains the rendered markdown in HTML of events that are happening now' do
|
||||
expect(response.body).to include('code')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -3,7 +3,7 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe UserDatatable do
|
||||
subject! do
|
||||
subject!(:user_datatable) do
|
||||
described_class.new(view)
|
||||
end
|
||||
|
||||
|
|
@ -90,9 +90,11 @@ describe UserDatatable do
|
|||
it { is_expected.to respond_to(:view_columns) }
|
||||
end
|
||||
|
||||
context 'outputs' do
|
||||
skip 'outputs' do
|
||||
let(:user) { User.first }
|
||||
let(:output) { subject.as_json }
|
||||
let(:output) { user_datatable.as_json }
|
||||
|
||||
before { skip('Investigate CI failures') }
|
||||
|
||||
it 'recordsTotal' do
|
||||
expect(output[:recordsTotal]).to eq(1)
|
||||
|
|
|
|||
|
|
@ -11,6 +11,7 @@
|
|||
# banner_photo_updated_at :datetime
|
||||
# include_booths :boolean
|
||||
# include_cfp :boolean default(FALSE)
|
||||
# include_happening_now :boolean
|
||||
# include_lodgings :boolean
|
||||
# include_program :boolean
|
||||
# include_registrations :boolean
|
||||
|
|
@ -44,6 +45,7 @@ FactoryBot.define do
|
|||
include_sponsors { true }
|
||||
include_lodgings { true }
|
||||
include_cfp { true }
|
||||
include_happening_now { true }
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -80,8 +80,30 @@ FactoryBot.define do
|
|||
last_sign_in_at { Date.today }
|
||||
is_disabled { false }
|
||||
|
||||
after(:build) do |user|
|
||||
url_mailbluster = 'https://api.mailbluster.com/api/leads/'
|
||||
response_body = "{
|
||||
\"message\": \"Lead created\",
|
||||
\"lead\": {
|
||||
\"id\": 329395,
|
||||
\"firstName\": \"#{user.name}\",
|
||||
\"lastName\": \"\",
|
||||
\"fullName\": \"#{user.name}\",
|
||||
\"email\": \"#{user.email}\",
|
||||
\"subscribed\": true,
|
||||
\"tags\": [
|
||||
#{ENV['OSEM_NAME'] || 'snapcon'}
|
||||
],
|
||||
}
|
||||
}"
|
||||
WebMock.stub_request(:post, url_mailbluster)
|
||||
.to_return(body: response_body, status: 200)
|
||||
end
|
||||
# Called by every user creation
|
||||
|
||||
after(:create) do |user|
|
||||
user.is_admin = false
|
||||
|
||||
# save with bang cause we want change in DB and not just in object instance
|
||||
user.save!
|
||||
end
|
||||
|
|
|
|||
|
|
@ -449,4 +449,14 @@ describe Event do
|
|||
end
|
||||
end
|
||||
end
|
||||
|
||||
describe '#serializable_hash' do
|
||||
let(:event2) { create(:event, program: conference.program, abstract: '`markdown`') }
|
||||
|
||||
context 'serializes event correctly' do
|
||||
it 'contains rendered markdown in HTML' do
|
||||
expect(event2.serializable_hash['rendered_abstract']).to include('<code>markdown</code>')
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
|||
140
spec/services/mailbluster_manager_spec.rb
Normal file
140
spec/services/mailbluster_manager_spec.rb
Normal file
|
|
@ -0,0 +1,140 @@
|
|||
# frozen_string_literal: true
|
||||
|
||||
require 'spec_helper'
|
||||
require 'webmock/rspec'
|
||||
|
||||
describe MailblusterManager, type: :model do
|
||||
let!(:user) { create(:user) }
|
||||
|
||||
before(:each) do
|
||||
WebMock.reset_executed_requests!
|
||||
end
|
||||
|
||||
url = 'https://api.mailbluster.com/api/leads/'
|
||||
|
||||
describe 'query_api' do
|
||||
it 'translates :get to a get request' do
|
||||
stub_request(:get, url)
|
||||
described_class.query_api(:get, '/')
|
||||
|
||||
expect(WebMock).to have_requested(:get, url)
|
||||
end
|
||||
|
||||
it 'translates :post to a post request' do
|
||||
stub_request(:post, url + 'path')
|
||||
described_class.query_api(:post, '/path', body: { key: 'value' })
|
||||
|
||||
expect(WebMock).to have_requested(:post, url + 'path').with(body: { key: 'value' })
|
||||
end
|
||||
end
|
||||
|
||||
describe 'create_lead' do
|
||||
it 'makes a post request to Mailbluster\'s API and gets the correct response' do
|
||||
response_body = "{
|
||||
\"message\": \"Lead created\",
|
||||
\"lead\": {
|
||||
\"id\": 329395,
|
||||
\"firstName\": \"#{user.name}\",
|
||||
\"lastName\": \"\",
|
||||
\"fullName\": \"#{user.name}\",
|
||||
\"email\": \"#{user.email}\",
|
||||
\"subscribed\": true,
|
||||
\"tags\": [
|
||||
#{ENV['OSEM_NAME'] || 'snapcon'}
|
||||
],
|
||||
}
|
||||
}"
|
||||
stub_request(:post, url)
|
||||
.to_return(body: response_body, status: 200)
|
||||
response = described_class.create_lead(user)
|
||||
|
||||
expect(WebMock).to have_requested(:post, url).with(body: {
|
||||
'email': user.email,
|
||||
'firstName': user.name,
|
||||
'overrideExisting': true,
|
||||
'subscribed': true,
|
||||
'tags': [ENV['OSEM_NAME'] || 'snapcon']
|
||||
}.to_json)
|
||||
expect(response).to eq(response_body)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'edit_lead' do
|
||||
it 'makes a put request to Mailbluster\'s API to change the email and gets the correct response' do
|
||||
response_body = "{
|
||||
\"message\": \"Lead updated\",
|
||||
\"lead\": {
|
||||
\"id\": 329395,
|
||||
\"firstName\": \"#{user.name}\",
|
||||
\"lastName\": \"\",
|
||||
\"fullName\": \"#{user.name}\",
|
||||
\"email\": \"#{user.email}\",
|
||||
\"subscribed\": true,
|
||||
\"tags\": [
|
||||
#{ENV['OSEM_NAME'] || 'snapcon'}
|
||||
],
|
||||
}
|
||||
}"
|
||||
old_email = user.email
|
||||
user.email = 'new@new.org'
|
||||
user.save
|
||||
stub_request(:put, url + Digest::MD5.hexdigest(old_email))
|
||||
.to_return(body: response_body, status: 200)
|
||||
response = described_class.edit_lead(user, old_email: old_email)
|
||||
|
||||
expect(WebMock).to have_requested(:put, url + Digest::MD5.hexdigest(old_email)).with(body: {
|
||||
'email': user.email,
|
||||
'firstName': user.name,
|
||||
'addTags': [],
|
||||
'removeTags': []
|
||||
}.to_json)
|
||||
expect(response).to eq(response_body)
|
||||
end
|
||||
|
||||
it 'makes a put request to Mailbluster\'s API to add a tag and gets the correct response' do
|
||||
response_body = "{
|
||||
\"message\": \"Lead updated\",
|
||||
\"lead\": {
|
||||
\"id\": 329395,
|
||||
\"firstName\": \"#{user.name}\",
|
||||
\"lastName\": \"\",
|
||||
\"fullName\": \"#{user.name}\",
|
||||
\"email\": \"#{user.email}\",
|
||||
\"subscribed\": true,
|
||||
\"tags\": [
|
||||
#{ENV['OSEM_NAME'] || 'snapcon'}, '2021'
|
||||
],
|
||||
}
|
||||
}"
|
||||
stub_request(:put, url + Digest::MD5.hexdigest(user.email))
|
||||
.to_return(body: response_body, status: 200)
|
||||
add_tags = ['2021']
|
||||
response = described_class.edit_lead(user, add_tags: add_tags)
|
||||
|
||||
expect(WebMock).to have_requested(:put, url + Digest::MD5.hexdigest(user.email)).with(body: {
|
||||
'email': user.email,
|
||||
'firstName': user.name,
|
||||
'addTags': add_tags,
|
||||
'removeTags': []
|
||||
}.to_json)
|
||||
expect(response).to eq(response_body)
|
||||
end
|
||||
end
|
||||
|
||||
describe 'delete_lead' do
|
||||
it 'correctly requests the right URL and gets a valid response' do
|
||||
email_hash = Digest::MD5.hexdigest user.email
|
||||
response_body = "{
|
||||
\"message\":\"Lead deleted\",
|
||||
\"leadHash\":\"#{email_hash}\"
|
||||
}"
|
||||
lead_url = url + email_hash.to_s
|
||||
stub_request(:delete, lead_url)
|
||||
.to_return(body: response_body)
|
||||
response = described_class.delete_lead(user.email)
|
||||
|
||||
expect(WebMock).to have_requested(:delete, lead_url)
|
||||
expect(response).to eq(response_body)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -11,6 +11,7 @@ RSpec.configure do |config|
|
|||
config.before(:each) do
|
||||
mock_commercial_request
|
||||
mock_image_request
|
||||
mock_default_mailbluster
|
||||
end
|
||||
end
|
||||
|
||||
|
|
@ -39,3 +40,7 @@ def mock_image_request
|
|||
WebMock.stub_request(:post, 'https://api.cloudinary.com/v1_1/snapcon/image/destroy')
|
||||
.to_return(status: 200, body: {}.to_json, headers: {})
|
||||
end
|
||||
|
||||
def mock_default_mailbluster
|
||||
WebMock.stub_request(:any, /api.mailbluster.com/)
|
||||
end
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue