* VRFS-1377 done, tested. going to manually test soon on production
This commit is contained in:
parent
7df02c0778
commit
c9625a4529
|
|
@ -1,7 +1,6 @@
|
|||
CREATE TABLE events (
|
||||
id VARCHAR(64) PRIMARY KEY DEFAULT uuid_generate_v4(),
|
||||
slug VARCHAR(512) NOT NULL UNIQUE,
|
||||
event_day date,
|
||||
title TEXT,
|
||||
description TEXT,
|
||||
show_sponser BOOLEAN NOT NULL DEFAULT false,
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
class JamRuby::Event < ActiveRecord::Base
|
||||
|
||||
attr_accessible :slug, :event_day, :title, :description, :show_sponser, as: :admin
|
||||
attr_accessible :slug, :title, :description, :show_sponser, as: :admin
|
||||
|
||||
validates :slug, uniqueness: true, presence: true
|
||||
validates :show_sponser, :inclusion => {:in => [true, false]}
|
||||
|
|
|
|||
|
|
@ -14,7 +14,6 @@ class JamRuby::EventSession < ActiveRecord::Base
|
|||
before_validation :sanitize_active_admin
|
||||
|
||||
def sanitize_active_admin
|
||||
puts self.inspect
|
||||
self.img_url = nil if self.img_url == ''
|
||||
self.user_id = nil if self.user_id == ''
|
||||
self.band_id = nil if self.band_id == ''
|
||||
|
|
|
|||
|
|
@ -9,4 +9,16 @@
|
|||
.bio {
|
||||
line-height:16px;
|
||||
}
|
||||
|
||||
.session-button {
|
||||
img.listen-now-play {
|
||||
vertical-align: top;
|
||||
padding-right:7px;
|
||||
}
|
||||
}
|
||||
}
|
||||
.landing-sidebar {
|
||||
.sponsor {
|
||||
margin-bottom:50px;
|
||||
}
|
||||
}
|
||||
|
|
@ -13,6 +13,7 @@ module EventSessionHelper
|
|||
url = image_path(event_session.img_url)
|
||||
else
|
||||
url = resolve_avatarables(event_session.band, event_session.user, allow_none: true)
|
||||
url = image_path(url) if url
|
||||
end
|
||||
|
||||
if url
|
||||
|
|
@ -38,25 +39,34 @@ module EventSessionHelper
|
|||
timezone.at(event_session.starts_at.to_i).strftime('%l:%M %P')
|
||||
end
|
||||
|
||||
def fetch_last_session(event_session)
|
||||
# if no pinned state, then we try to find if there is a session currently on going during the specified time range
|
||||
# if so, then we are playing.
|
||||
# if there has been none, we say it's still coming,
|
||||
# if there has been at least one, and it's over, we say session over
|
||||
query = MusicSessionHistory.where(fan_access: true).where(created_at: event_session.starts_at..event_session.ends_at)
|
||||
if event_session.user_id
|
||||
query = query.where(user_id: event_session.user_id)
|
||||
elsif event_session.band_id
|
||||
query = query.where(band_id: event_session.band_id)
|
||||
else
|
||||
raise 'invalid state in event_session_button'
|
||||
end
|
||||
|
||||
query.order('created_at DESC').first
|
||||
end
|
||||
|
||||
def event_session_button(event_session)
|
||||
|
||||
state = nil # can be :not_started, :over, :playing
|
||||
state = event_session.pinned_state if event_session.pinned_state
|
||||
if !state && (event_session.starts_at && event_session.ends_at && (event_session.user_id || event_session.band_id))
|
||||
# if no pinned state, then we try to find if there is a session currently on going during the specified time range
|
||||
# if so, then we are playing.
|
||||
# if there has been none, we say it's still coming,
|
||||
# if there has been at least one, and it's over, we say session over
|
||||
query = MusicSessionHistory.where(created_at: event_session.starts_at..event_session.ends_at)
|
||||
if event_session.user_id
|
||||
query = query.where(user_id: event_session.user_id)
|
||||
elsif event_session.band_id
|
||||
query = query.where(band_id: event_session.band_id)
|
||||
else
|
||||
raise 'invalid state in event_session_button'
|
||||
end
|
||||
if state
|
||||
|
||||
music_session_history = query.order('created_at DESC').first
|
||||
music_session_history = fetch_last_session(event_session)
|
||||
|
||||
elsif !state && (event_session.starts_at && event_session.ends_at && (event_session.user_id || event_session.band_id))
|
||||
|
||||
music_session_history = fetch_last_session(event_session)
|
||||
|
||||
if music_session_history
|
||||
if music_session_history.session_removed_at
|
||||
|
|
@ -73,8 +83,7 @@ module EventSessionHelper
|
|||
content_tag(:a, 'SESSION ENDED', href: music_session_history.nil? ? '#' : music_session_detail_path(music_session_history.id), class: 'button-grey')
|
||||
elsif state == 'playing'
|
||||
content_tag(:a, '', href: music_session_detail_path(music_session_history.id), class: 'button-orange') do
|
||||
image_tag 'content/icon_playbutton.png', :width => 20, height: 20, align: 'absmiddle'
|
||||
content_tag(:span, 'LISTEN NOW')
|
||||
content_tag(:span, image_tag('content/icon_playbutton.png', :width => 20, height: 20, align: 'absmiddle', class:'listen-now-play') + 'LISTEN NOW')
|
||||
end
|
||||
elsif state == 'not_started'
|
||||
nil
|
||||
|
|
|
|||
|
|
@ -3,13 +3,13 @@
|
|||
= event_session_img(event_session)
|
||||
%br
|
||||
%br
|
||||
%span= event_session_title(event_session)
|
||||
%span.event-title= event_session_title(event_session)
|
||||
|
||||
.landing-details.event
|
||||
.left.f20.teal.time
|
||||
%strong
|
||||
= event_session_start_hour(event_session)
|
||||
.right
|
||||
.right.session-button
|
||||
= event_session_button(event_session)
|
||||
%br{ clear:'all' }
|
||||
|
||||
|
|
|
|||
|
|
@ -17,12 +17,9 @@
|
|||
%br
|
||||
%div{align:'center'}
|
||||
- if @event.show_sponser?
|
||||
%span SPONSORED BY:
|
||||
= image_tag 'content/logo_centurylink.png', width:320, height:80, class:'play-icon', alt:'CenturyLink logo'
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
%br
|
||||
.sponsor
|
||||
%span SPONSORED BY:
|
||||
= image_tag 'content/logo_centurylink.png', width:320, height:80, alt:'CenturyLink logo'
|
||||
%div{align: 'center'} LEARN ABOUT JAMKAZAM</div>
|
||||
%br
|
||||
= image_tag 'web/carousel_musicians.jpg', width:350, alt:'JamKazam Overview', class: 'video-slide',
|
||||
|
|
|
|||
|
|
@ -17,7 +17,7 @@
|
|||
<% end %>
|
||||
|
||||
<div class="sessions-page">
|
||||
<div class="landing-band">
|
||||
<div class="landing-band">
|
||||
<% unless @music_session.band.nil? %>
|
||||
<div class="landing-avatar">
|
||||
<% unless @music_session.band.photo_url.blank? %>
|
||||
|
|
|
|||
|
|
@ -390,4 +390,14 @@ FactoryGirl.define do
|
|||
mix.recording.claimed_recordings << FactoryGirl.create(:claimed_recording, user: user, recording: mix.recording)
|
||||
}
|
||||
end
|
||||
|
||||
|
||||
factory :event, :class => JamRuby::Event do
|
||||
sequence(:slug) { |n| "slug-#{n}" }
|
||||
title 'event title'
|
||||
description 'event description'
|
||||
end
|
||||
|
||||
factory :event_session, :class => JamRuby::EventSession do
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -0,0 +1,114 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe "Events", :js => true, :type => :feature, :capybara_feature => true, :slow => true do
|
||||
|
||||
subject { page }
|
||||
|
||||
before(:all) do
|
||||
Capybara.javascript_driver = :poltergeist
|
||||
Capybara.current_driver = Capybara.javascript_driver
|
||||
Capybara.default_wait_time = 30 # these tests are SLOOOOOW
|
||||
end
|
||||
|
||||
before(:each) do
|
||||
UserMailer.deliveries.clear
|
||||
MusicSession.delete_all
|
||||
@event = FactoryGirl.create(:event, :slug => 'so_latency', show_sponser:true)
|
||||
visit "/events/so_latency"
|
||||
end
|
||||
|
||||
it "should not break as page gets more and more well-defined" do
|
||||
find('h1', text: @event.title)
|
||||
find('h2', text: 'ARTIST LINEUP')
|
||||
find('p', text: @event.description)
|
||||
find('.landing-sidebar')
|
||||
find('.sponsor span', 'SPONSORED BY:')
|
||||
|
||||
# add an event session to the event, with nothing defined
|
||||
@event_session = FactoryGirl.create(:event_session, event: @event)
|
||||
visit "/events/so_latency"
|
||||
find('.landing-band.event img')['src'].should == '/assets/web/logo-256.png'
|
||||
find('.event-title', text: 'TBD')
|
||||
find('.time strong', text: 'TBD')
|
||||
|
||||
# define the event better by associating with a band
|
||||
band = FactoryGirl.create(:band)
|
||||
@event_session.band = band
|
||||
@event_session.save!
|
||||
visit "/events/so_latency"
|
||||
find('.landing-details.event .bio', text: band.biography)
|
||||
find('.landing-band.event img')['src'].should == '/assets/shared/avatar_generic_band.png'
|
||||
|
||||
# update starts at
|
||||
starts_at = 1.hours.ago
|
||||
@event_session.starts_at = starts_at
|
||||
@event_session.save!
|
||||
visit "/events/so_latency"
|
||||
timezone = ActiveSupport::TimeZone.new('Central Time (US & Canada)')
|
||||
find('.time strong', text: timezone.at(@event_session.starts_at.to_i).strftime('%l:%M %P').strip)
|
||||
|
||||
# update ends at
|
||||
ends_at = 1.hours.from_now
|
||||
@event_session.ends_at = ends_at
|
||||
@event_session.save!
|
||||
visit "/events/so_latency"
|
||||
# UI shouldn't change; as long as it doesn't crash we are OK
|
||||
|
||||
# now start a session, and don't sent session_removed_at
|
||||
music_session = FactoryGirl.create(:music_session, band: band)
|
||||
music_session_history = music_session.music_session_history
|
||||
music_session_history.session_removed_at.should be_nil
|
||||
visit "/events/so_latency"
|
||||
find('.landing-details .session-button span', text:'LISTEN NOW')
|
||||
find('.landing-details .session-button a').trigger(:click)
|
||||
find('.sessions-page .landing-band', text: band.name) # indication of session landing page
|
||||
find(".recording-controls[data-music-session=\"#{music_session_history.id}\"]")
|
||||
|
||||
# force the pinned_state to say 'not_started'
|
||||
@event_session.pinned_state = 'not_started'
|
||||
@event_session.save!
|
||||
visit "/events/so_latency"
|
||||
expect(page).not_to have_css('.landing-details .session-button a') # no button at all
|
||||
|
||||
# force the pinned_state to say 'not_started'
|
||||
@event_session.pinned_state = 'over'
|
||||
@event_session.save!
|
||||
visit "/events/so_latency"
|
||||
find('.landing-details .session-button a', text:'SESSION ENDED').trigger(:click)
|
||||
find('.sessions-page .landing-band', text: band.name) # indication of session landing page
|
||||
find(".recording-controls[data-music-session=\"#{music_session_history.id}\"]")
|
||||
|
||||
# unpin
|
||||
@event_session.pinned_state = nil
|
||||
@event_session.save!
|
||||
|
||||
|
||||
# turn fan_access = false... this will hide the button
|
||||
music_session_history.fan_access = false
|
||||
music_session_history.save!
|
||||
visit "/events/so_latency"
|
||||
expect(page).not_to have_css('.landing-details .session-button a') # no button at all
|
||||
|
||||
|
||||
# now start a second session, and don't sent session_removed_at
|
||||
music_session = FactoryGirl.create(:music_session, band: band)
|
||||
music_session_history = music_session.music_session_history
|
||||
music_session_history.session_removed_at.should be_nil
|
||||
visit "/events/so_latency"
|
||||
find('.landing-details .session-button span', text:'LISTEN NOW')
|
||||
find('.landing-details .session-button a').trigger(:click)
|
||||
find('.sessions-page .landing-band', text: band.name) # indication of session landing page
|
||||
find(".recording-controls[data-music-session=\"#{music_session_history.id}\"]")
|
||||
visit "/events/so_latency"
|
||||
|
||||
# then end it, and see session_ended
|
||||
music_session_history = music_session.music_session_history
|
||||
music_session_history.session_removed_at = Time.now
|
||||
music_session_history.save!
|
||||
visit "/events/so_latency"
|
||||
find('.landing-details .session-button a', text:'SESSION ENDED').trigger(:click)
|
||||
find('.sessions-page .landing-band', text: band.name) # indication of session landing page
|
||||
find(".recording-controls[data-music-session=\"#{music_session_history.id}\"]")
|
||||
|
||||
end
|
||||
end
|
||||
Loading…
Reference in New Issue