Merge branch 'develop' of bitbucket.org:jamkazam/jam-cloud into develop

This commit is contained in:
Seth Call 2014-01-05 03:47:35 +00:00
commit 17486c6ed2
18 changed files with 311 additions and 262 deletions

1
runweb
View File

@ -1,5 +1,6 @@
#!/bin/bash
pushd web
# run jam-web rails server
bundle exec rails s
popd

View File

@ -36,6 +36,7 @@
city: userDetail.city,
first_name: userDetail.first_name,
last_name: userDetail.last_name,
photoUrl: context.JK.resolveAvatarUrl(userDetail.photo_url),
user_instruments: userDetail.instruments,
birth_date : userDetail.birth_date,
gender: userDetail.gender,

View File

@ -59,7 +59,15 @@
}
.account-profile {
padding-top:25px;
padding-top:20px;
.avatar_large {
position:absolute;
float:none;
top: -36px;
right:0;
margin-right:20%;
}
h2 {
margin-bottom:15px;
@ -67,17 +75,16 @@
.location {
position:relative;
padding-top:25px;
}
#account-change-avatar {
position:absolute;
top:-27px;
right:72px;
height:13px;
float:right;
margin-right:17%;
}
.birth_date {
margin-left:40px;
}
}

View File

@ -273,9 +273,6 @@
#band-filter-results {
margin: 0 10px 5px 10px;
overflow: auto;
height: 100%;
width: 100%;
}
.band-list-result {

View File

@ -88,6 +88,17 @@
}
}
}
.filter-head {
position: absolute;
padding:11px 0;
}
.filter-body {
height:100%;
width:100%;
box-sizing: border-box;
padding-top: 49px;
}
}
.result-list-button-wrapper {
@ -248,7 +259,7 @@ a.arrow-down {
#session-controls {
width:100%;
padding:11px 0px 11px 0px;
padding:6px 0px 11px 0px;
background-color:#4c4c4c;
min-height:20px;
overflow-x:scroll;

View File

@ -22,14 +22,11 @@
#musician-filter-results {
margin: 0 10px 0px 10px;
overflow: auto;
height: 100%;
// width: 100%;
}
.musician-wrapper {
// overflow: auto;
// height: 480px;
overflow: initial;
height: initial;
width: 100%;
}
@ -37,12 +34,8 @@
padding-top: 5px;
padding-right: 5px;
padding-left: 5px;
box-sizing:border-box;
}
#session-controls.musician-filter {
padding-top: 6px;
}
.musician-following {
overflow: auto;
}

View File

@ -196,6 +196,7 @@
position:relative;
margin:10px 0px 10px 0px;
padding-bottom:5px;
box-sizing:border-box;
}
.profile-social-left {

View File

@ -42,7 +42,8 @@
}
}
.content {
.content,
.inner-content {
clear: both;
float: left;
height: 100%;

View File

@ -30,7 +30,9 @@
<h2>profile:</h2>
<div class="location w30 left">
<a href="#" class="avatar_large"><img src="{photoUrl}" id="profile-avatar" /></a>
<a href="#" class="small" id="account-change-avatar">Change Avatar</a>
<div class="clearall"></div>
<div class="field">
<label>Country:</label>
@ -54,19 +56,19 @@
</div>
</div>
<div class="right-side right w70">
<div class="right-side right w70" style="margin-top:-36px;">
<div class="field left w45">
<label>First Name:</label>
<input type="text" name="first_name" value="{first_name}" class="w80"><br/>
<input type="text" name="first_name" value="{first_name}" class="w80" style="margin-bottom:12px;">
</div>
<div class="field right w45">
<label>Last Name:</label>
<input type="text" name="last_name" value="{last_name}" class="w80">
<input type="text" name="last_name" value="{last_name}" class="w80" style="margin-bottom:12px;">
</div>
<br class="clearall"/>
<div class="field left">
<div class="field left w45">
<label>Gender:</label>
<select name="gender" data-value="{gender}" class="w80">
<option value='M'>Male</option>
@ -75,7 +77,7 @@
</select>
</div>
<div class="field left birth_date">
<div class="field right w45 birth_date">
<label>Birth Date:</label>
<%= date_select("user", "birth_date", :use_short_month => true, :start_year => 1900, :end_year => Time.now.year - 18, :order => [:month, :day, :year], :default => -25.years.from_now) %>
</div>
@ -100,9 +102,9 @@
<a id="account-edit-profile-cancel" href="#" class="button-grey">CANCEL</a>&nbsp;&nbsp;<a id="account-edit-profile-submit" href="#" class="button-orange">UPDATE PROFILE</a>
</div>
</div>
</form>
<br clear="all"/>
<div class="clearall"/>
</form>
</div>
<!-- end content wrapper -->

View File

@ -7,11 +7,11 @@
<%= render "screen_navigation" %>
<% end -%>
<%= content_tag(:div, :class => 'content-body') do -%>
<%= content_tag(:div, :class => 'content-body-scroller') do -%>
<%= form_tag('', :id => 'find-band-form') do -%>
<%= content_tag(:div, render(:partial => "web_filter", :locals => {:search_type => Search::PARAM_BAND}), :class => 'band-filter', :id => 'session-controls') %>
<%= content_tag(:div, :class => 'content-scroller') do -%>
<%= content_tag(:div, content_tag(:div, '', :id => 'band-filter-results', :class => 'filter-results'), :class => 'content-wrapper band-wrapper') %>
<%= form_tag('', {:id => 'find-band-form', :class => 'inner-content'}) do -%>
<%= render(:partial => "web_filter", :locals => {:search_type => Search::PARAM_BAND}) %>
<%= content_tag(:div, :class => 'filter-body') do %>
<%= content_tag(:div, :class => 'content-body-scroller') do -%>
<%= content_tag(:div, content_tag(:div, '', :id => 'band-filter-results', :class => 'filter-results'), :class => 'content-wrapper') %>
<% end -%>
<% end -%>
<% end -%>

View File

@ -7,11 +7,11 @@
<%= render "screen_navigation" %>
<% end -%>
<%= content_tag(:div, :class => 'content-body') do -%>
<%= content_tag(:div, :class => 'content-body-scroller') do -%>
<%= form_tag('', :id => 'find-musician-form') do -%>
<%= content_tag(:div, render(:partial => "web_filter", :locals => {:search_type => Search::PARAM_MUSICIAN}), :class => 'musician-filter', :id => 'session-controls') %>
<%= content_tag(:div, :class => 'content-scroller') do -%>
<%= content_tag(:div, content_tag(:div, '', :id => 'musician-filter-results'), :class => 'content-wrapper musician-wrapper') %>
<%= form_tag('', {:id => 'find-musician-form', :class => 'inner-content'}) do -%>
<%= render(:partial => "web_filter", :locals => {:search_type => Search::PARAM_MUSICIAN}) %>
<%= content_tag(:div, :class => 'filter-body') do %>
<%= content_tag(:div, :class => 'content-body-scroller') do -%>
<%= content_tag(:div, content_tag(:div, '', :id => 'musician-filter-results', :class => 'filter-results'), :class => 'content-wrapper musician-wrapper') %>
<% end -%>
<% end -%>
<% end -%>
@ -22,7 +22,7 @@
<!-- Session Row Template -->
<script type="text/template" id="template-find-musician-row">
<div class="profile-band-list-result musician-list-result">
<div style="float:left">
<div class="left">
<!-- avatar -->
<div class="avatar-small"><img src="{avatar_url}" /></div>

View File

@ -1,30 +1,39 @@
<% filter_label = defined?(search_type) && search_type == Search::PARAM_BAND ? :band : :musician %>
<%= content_tag(:div, :class => "filter-element wrapper") do -%>
<%= content_tag(:div, 'Filter By:', :class => 'filter-element desc') %>
<!-- order by filter -->
<%= select_tag("#{filter_label}_order_by", options_for_select(Search::ORDERINGS), {:class => "#{filter_label}-order-by"} ) %>
<% end -%>
<%= content_tag(:div, :class => 'filter-element wrapper') do -%>
<% if :musician == filter_label %>
<!-- instrument filter -->
<%= content_tag(:div, 'Instrument:', :class => 'filter-element desc') %>
<%= select_tag("#{filter_label}_instrument",
options_for_select([['Any', '']].concat(JamRuby::Instrument.all.collect { |ii| [ii.description, ii.id] }))) %>
<% elsif :band == filter_label %>
<!-- genre filter -->
<%= content_tag(:div, 'Genre:', :class => 'filter-element desc') %>
<%= select_tag("#{filter_label}_genre",
options_for_select([['Any', '']].concat(JamRuby::Genre.all.collect { |ii| [ii.description, ii.id] }))) %>
<% end %>
<% end -%>
<!-- distance filter -->
<%= content_tag(:div, :class => 'filter-element wrapper') do -%>
<%= content_tag(:div, 'Within', :class => 'filter-element desc') %>
<%= content_tag(:div, :class => 'query-distance-params') do -%>
<% default_distance = :musician == filter_label ? Search::M_MILES_DEFAULT : Search::B_MILES_DEFAULT %>
<%= select_tag("#{filter_label}_query_distance", options_for_select(Search::DISTANCE_OPTS, default_distance)) %>
<!-- @begin web_filter -->
<% case search_type
when Search::PARAM_BAND
filter_label = :band
when Search::PARAM_MUSICIAN
filter_label = :musician
end %>
<%= content_tag(:div, :id => defined?(id) ? id : 'session-controls', :class => "#{filter_label}-filter filter-head") do %>
<%= content_tag(:div, :class => "filter-element wrapper") do -%>
<%= content_tag(:div, 'Filter By:', :class => 'filter-element desc') %>
<!-- order by filter -->
<%= select_tag("#{filter_label}_order_by", options_for_select(Search::ORDERINGS), {:class => "#{filter_label}-order-by"} ) %>
<% end -%>
<%= content_tag(:div, :class => 'filter-element desc') do -%>
miles of <%= content_tag(:span, current_user.current_city(request.remote_ip), :id => "#{filter_label}-filter-city") %>
<%= content_tag(:div, :class => 'filter-element wrapper') do -%>
<% if :musician == filter_label %>
<!-- instrument filter -->
<%= content_tag(:div, 'Instrument:', :class => 'filter-element desc') %>
<%= select_tag("#{filter_label}_instrument",
options_for_select([['Any', '']].concat(JamRuby::Instrument.all.collect { |ii| [ii.description, ii.id] }))) %>
<% elsif :band == filter_label %>
<!-- genre filter -->
<%= content_tag(:div, 'Genre:', :class => 'filter-element desc') %>
<%= select_tag("#{filter_label}_genre",
options_for_select([['Any', '']].concat(JamRuby::Genre.all.collect { |ii| [ii.description, ii.id] }))) %>
<% end %>
<% end -%>
<!-- distance filter -->
<%= content_tag(:div, :class => 'filter-element wrapper') do -%>
<%= content_tag(:div, 'Within', :class => 'filter-element desc') %>
<%= content_tag(:div, :class => 'query-distance-params') do -%>
<% default_distance = :musician == filter_label ? Search::M_MILES_DEFAULT : Search::B_MILES_DEFAULT %>
<%= select_tag("#{filter_label}_query_distance", options_for_select(Search::DISTANCE_OPTS, default_distance)) %>
<% end -%>
<%= content_tag(:div, :class => 'filter-element desc') do -%>
miles of <%= content_tag(:span, current_user.current_city(request.remote_ip), :id => "#{filter_label}-filter-city") %>
<% end -%>
<% end -%>
<% end -%>
<!-- @end web_filter -->

26
web/public/503.html Normal file
View File

@ -0,0 +1,26 @@
<!DOCTYPE html>
<html>
<head>
<title>We're sorry, but something is being worked on. (503)</title>
<style type="text/css">
body { background-color: #fff; color: #666; text-align: center; font-family: arial, sans-serif; }
div.dialog {
width: 25em;
padding: 0 4em;
margin: 4em auto 0 auto;
border: 1px solid #ccc;
border-right-color: #999;
border-bottom-color: #999;
}
h1 { font-size: 100%; color: #f00; line-height: 1.5em; }
</style>
</head>
<body>
<!-- This file lives in public/503.html -->
<div class="dialog">
<h1>We're sorry, but we're currently upgrading the poo flinging sloths.</h1>
<h2>Please be patient while we make things even more awesome!</h2>
</div>
</body>
</html>

View File

@ -71,17 +71,6 @@ describe "In a Session", :js => true, :type => :feature, :capybara_feature => tr
#in_client(others[0]) {page.save_screenshot('tmp/partys_all_here_now.png')}
end
it "a user can change the genre and the change will be seen by another participant" do
pending "...it doesn't work this way, but i will reuse this pattern"
create_join_session(user, [finder])
in_client(user) do
@new_genre = change_session_genre
end
in_client(finder) do
expect(get_session_genre).to include(@new_genre)
end
end
it "a user can change the genre and the Find Session screen will be updated" do
create_session(user)
in_client(finder) { sign_in_poltergeist finder }
@ -94,5 +83,4 @@ describe "In a Session", :js => true, :type => :feature, :capybara_feature => tr
end
end
end
end

View File

@ -12,6 +12,7 @@ describe "Session Recordings", :js => true, :type => :feature, :capybara_feature
let(:creator) { FactoryGirl.create(:user) }
let(:joiner1) { FactoryGirl.create(:user) }
let(:some_genre) { random_genre }
before(:each) do
MusicSession.delete_all
@ -19,96 +20,37 @@ describe "Session Recordings", :js => true, :type => :feature, :capybara_feature
# creates a recording, and stops it, and confirms the 'Finished Recording' dialog shows for both
it "creator start/stop" do
create_join_session(creator, [joiner1])
start_recording_with(creator, [joiner1])
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Stop Recording'
end
in_client(creator) { stop_recording }
in_client(joiner1) do
find('#notification').should have_content 'started a recording'
find('#recording-status').should have_content 'Stop Recording'
end
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
in_client(joiner1) do
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
check_recording_finished_for([creator, joiner1])
end
# confirms that anyone can start/stop a recording
it "creator starts and other stops" do
create_join_session(creator, [joiner1])
start_recording_with(creator, [joiner1])
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Stop Recording'
end
in_client(joiner1) { stop_recording }
in_client(joiner1) do
find('#notification').should have_content 'started a recording'
find('#recording-status').should have_content 'Stop Recording'
end
in_client(joiner1) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
in_client(creator) do
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
check_recording_finished_for([creator, joiner1])
end
# confirms that a formal leave (by hitting the 'Leave' button) will result in a good recording
it "creator starts and then leaves" do
create_join_session(creator, [joiner1])
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Stop Recording'
end
in_client(joiner1) do
find('#notification').should have_content 'started a recording'
find('#recording-status').should have_content 'Stop Recording'
end
start_recording_with(creator, [joiner1])
in_client(creator) do
find('#session-leave').trigger(:click)
expect(page).to have_selector('h2', text: 'feed')
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
in_client(joiner1) do
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
check_recording_finished_for [creator, joiner1]
end
# confirms that if someone leaves 'ugly' (without calling 'Leave' REST API), that the recording is junked
it "creator starts and then abruptly leave" do
create_join_session(creator, [joiner1])
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Stop Recording'
end
in_client(joiner1) do
find('#notification').should have_content 'started a recording'
find('#recording-status').should have_content 'Stop Recording'
end
start_recording_with(creator, [joiner1])
in_client(creator) do
visit "/downloads" # kills websocket, looking like an abrupt leave
@ -124,91 +66,32 @@ describe "Session Recordings", :js => true, :type => :feature, :capybara_feature
it "creator starts/stops, with 3 total participants" do
joiner2 = FactoryGirl.create(:user)
create_join_session(creator, [joiner1, joiner2])
start_recording_with(creator, [joiner1, joiner2])
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Stop Recording'
stop_recording
end
in_client(joiner1) do
find('#recording-status').should have_content 'Stop Recording'
end
in_client(joiner2) do
find('#recording-status').should have_content 'Stop Recording'
end
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
in_client(joiner1) do
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
in_client(joiner2) do
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
check_recording_finished_for [creator, joiner1, joiner2]
end
it "creator starts with session leave to stop, with 3 total participants" do
joiner2 = FactoryGirl.create(:user)
create_join_session(creator, [joiner1, joiner2])
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Stop Recording'
end
in_client(joiner1) do
find('#recording-status').should have_content 'Stop Recording'
end
in_client(joiner2) do
find('#recording-status').should have_content 'Stop Recording'
end
start_recording_with(creator, [joiner1, joiner2])
in_client(creator) do
find('#session-leave').trigger(:click)
expect(page).to have_selector('h2', text: 'feed')
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
in_client(joiner1) do
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
in_client(joiner2) do
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
check_recording_finished_for [creator, joiner1, joiner2]
end
# confirms that if someone leaves 'ugly' (without calling 'Leave' REST API), that the recording is junked with 3 participants
it "creator starts and then abruptly leave with 3 participants" do
joiner2 = FactoryGirl.create(:user)
create_join_session(creator, [joiner1, joiner2])
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Stop Recording'
end
in_client(joiner1) do
find('#recording-status').should have_content 'Stop Recording'
end
in_client(joiner2) do
find('#recording-status').should have_content 'Stop Recording'
end
start_recording_with(creator, [joiner1, joiner2])
in_client(creator) do
visit "/downloads" # kills websocket, looking like an abrupt leave
@ -234,23 +117,14 @@ describe "Session Recordings", :js => true, :type => :feature, :capybara_feature
RecordedTrack.delete_all
ClaimedRecording.delete_all
create_join_session(creator, [joiner1])
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Stop Recording'
end
start_recording_with(creator, [joiner1], some_genre)
in_client(joiner1) do
find('#notification').should have_content 'started a recording'
find('#recording-status').should have_content 'Stop Recording'
stop_recording
end
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
@users = [creator, joiner1]
check_recording_finished_for @users
end
it "discard the recording" do
@ -277,43 +151,64 @@ describe "Session Recordings", :js => true, :type => :feature, :capybara_feature
end
end
it "claim recording" do
in_client(creator) do
find('#recording-finished-dialog h1')
fill_in "claim-recording-name", with: "my recording"
fill_in "claim-recording-description", with: "my description"
find('#keep-session-recording').trigger(:click)
should have_no_selector('h1', text: 'recording finished')
it "claim recording with unique names/descriptions" do
@users.each do |user|
name = "#{user.name}'s recording"
desc = "#{user.name}'s description"
music_session = MusicSession.first()
recording = music_session.recordings.first()
claimed_recording = ClaimedRecording.find_by_user_id(creator.id)
claimed_recording.name.should == "my recording"
claimed_recording.description.should == "my description"
claimed_recording.is_public.should be_true
claimed_recording.is_downloadable.should be_true
claimed_recording.genre = music_session.genres[0]
end
in_client(joiner1) do
find('#recording-finished-dialog h1')
fill_in "claim-recording-name", with: "my recording"
fill_in "claim-recording-description", with: "my description"
find('#keep-session-recording').trigger(:click)
should have_no_selector('h1', text: 'recording finished')
music_session = MusicSession.first()
recording = music_session.recordings.first()
claimed_recording = ClaimedRecording.find_by_user_id(joiner1.id)
claimed_recording.name.should == "my recording"
claimed_recording.description.should == "my description"
claimed_recording.is_public.should be_true
claimed_recording.is_downloadable.should be_true
claimed_recording.genre = music_session.genres[0]
in_client(user) do
claim_recording(name, desc)
music_session = MusicSession.first()
recording = music_session.recordings.first()
claimed_recording = ClaimedRecording.find_by_user_id(user.id)
claimed_recording.name.should == name
claimed_recording.description.should == desc
claimed_recording.is_public.should be_true
claimed_recording.is_downloadable.should be_true
claimed_recording.genre = music_session.genres[0]
end
end
end
it "a 'Recording Name' is required" do
@users.each do |user|
in_client(user) do
find('#recording-finished-dialog h1')
fill_in "claim-recording-name", with: ''
fill_in "claim-recording-description", with: "my description"
find('#keep-session-recording').trigger(:click)
should have_content("can't be blank")
save_screenshot("tmp/name#{user.name}.png")
end
end
end
it "a 'Description' is optional" do
@users.each do |user|
in_client(user) do
claim_recording("my recording", '')
music_session = MusicSession.first()
recording = music_session.recordings.first()
claimed_recording = ClaimedRecording.find_by_user_id(user.id)
claimed_recording.name.should == "my recording"
claimed_recording.description.should == ''
claimed_recording.is_public.should be_true
claimed_recording.is_downloadable.should be_true
claimed_recording.genre = music_session.genres[0]
end
end
end
it "genre is pre-set with the genre selected for the session" do
@users.each do |user|
in_client(user) do
find('#recording-finished-dialog h1')
g = selected_genres('#recording-finished-dialog div.genre-selector')
expect(some_genre).to match(%r{#{g}}i)
end
end
end
end
end

View File

@ -96,16 +96,25 @@ Spork.prefork do
config.include Requests::JsonHelpers, type: :request
config.include Requests::FeatureHelpers, type: :feature
config.include Snapshot
config.before(:suite) do
end
config.before(:all) do
set_up_snapshot
end
config.before(:each) do
if example.metadata[:js]
page.driver.resize(1920, 1080)
page.driver.headers = { 'User-Agent' => 'Mozilla/5.0 (Windows NT 6.1; Win64; x64; rv:25.0) Gecko/20100101 Firefox/25.0' }
end
if example.metadata[:snap]
snapshot_example
end
end
config.before(:each, :js => true) do
@ -133,6 +142,10 @@ Spork.prefork do
puts "response.status = #{response.status}, response.body = " + response.body
end
end
config.after(:all) do
tear_down_snapshot
end
end
end

View File

@ -0,0 +1,28 @@
module Snapshot
def set_up_snapshot(filepath = 'tmp/snapshots.html')
@size = [1280, 720] #arbitrary
@file = File.new(filepath, "w+")
@file.puts "<HTML><BODY BGCOLOR=grey>"
@file.puts "<H1>Snapshot #{ENV["BUILD_NUMBER"]} - #{@size[0]}x#{@size[1]}</H1>"
end
def snapshot_example
page.driver.resize(@size[0], @size[1])
@file.puts "<H3>Example name: #{get_description}</H3><BR><BR>"
end
def snap!(title = get_description)
base64 = page.driver.render_base64(:png)
@file.puts '<H3>' + title + '</H3>'
@file.puts '<img alt="' + title +'" src="data:image/png;base64,' + base64 + '" />'
@file.puts '<BR><BR><BR>'
end
def tear_down_snapshot
@file.puts "</BODY></HTML>"
@file.close()
end
end

View File

@ -115,9 +115,20 @@ def determine_test_name(metadata, test_name_buffer = '')
end
end
def get_description
description = example.metadata[:description_args]
if description.kind_of?(Array)
description = description[0]
end
return description
end
# takes, or creates, a unique session description which is returned for subsequent calls to join_session to use
# in finding this session)
def create_session(creator = FactoryGirl.create(:user), unique_session_desc = "create_join_session #{SecureRandom.urlsafe_base64}")
def create_session(creator = FactoryGirl.create(:user), unique_session_desc = nil, genre = nil)
unique_session_desc ||= "create_join_session #{SecureRandom.urlsafe_base64}"
genre ||= 'Rock'
# create session in one client
in_client(creator) do
@ -129,7 +140,7 @@ def create_session(creator = FactoryGirl.create(:user), unique_session_desc = "c
within('#create-session-form') do
fill_in('description', :with => unique_session_desc)
select('Rock', :from => 'genres')
select(genre, :from => 'genres')
find('div.intellectual-property ins').trigger(:click)
find('#btn-create-session').trigger(:click) # fails if page width is low
end
@ -138,7 +149,7 @@ def create_session(creator = FactoryGirl.create(:user), unique_session_desc = "c
expect(page).to have_selector('h2', text: 'my tracks')
end
return creator, unique_session_desc
return creator, unique_session_desc, genre
end
@ -161,8 +172,8 @@ def join_session(joiner, unique_session_desc)
end
def create_join_session(creator, joiners=[])
creator, unique_session_desc = create_session(creator)
def create_join_session(creator, joiners=[], genre=nil)
creator, unique_session_desc = create_session(creator, nil, genre)
# find session in second client
joiners.each do |joiner|
@ -170,6 +181,44 @@ def create_join_session(creator, joiners=[])
end
end
def start_recording_with(creator, joiners=[], genre=nil)
create_join_session(creator, joiners, genre)
in_client(creator) do
find('#recording-start-stop').trigger(:click)
find('#recording-status').should have_content 'Stop Recording'
end
joiners.each do |joiner|
in_client(joiner) do
find('#notification').should have_content 'started a recording'
find('#recording-status').should have_content 'Stop Recording'
end
end
end
def stop_recording
find('#recording-start-stop').trigger(:click)
end
def assert_recording_finished
find('#recording-status').should have_content 'Make a Recording'
should have_selector('h1', text: 'recording finished')
end
def check_recording_finished_for(users=[])
users.each do |user|
in_client(user) do
assert_recording_finished
end
end
end
def claim_recording(name, description)
find('#recording-finished-dialog h1')
fill_in "claim-recording-name", with: name
fill_in "claim-recording-description", with: description
find('#keep-session-recording').trigger(:click)
should have_no_selector('h1', text: 'recording finished')
end
def set_session_as_private()
find('#session-settings-button').trigger(:click)
@ -191,8 +240,30 @@ def get_options(selector)
return find(selector).all('option').collect(&:text).uniq
end
def selected_genres
return page.evaluate_script("JK.GenreSelectorHelper.getSelectedGenres('#session-settings-genre')")
def selected_genres(selector='#session-settings-genre')
return page.evaluate_script("JK.GenreSelectorHelper.getSelectedGenres('#{selector}')")
end
def random_genre
['African',
'Ambient',
'Asian',
'Blues',
'Classical',
'Country',
'Electronic',
'Folk',
'Hip Hop',
'Jazz',
'Latin',
'Metal',
'Pop',
'R&B',
'Reggae',
'Religious',
'Rock',
'Ska',
'Other'].sample
end
def change_session_genre #randomly just change it
@ -235,4 +306,9 @@ def assert_all_tracks_seen(users=[])
end
end
end
end
def show_user_menu
page.execute_script("$('ul.shortcuts').show()")
#page.execute_script("JK.UserDropdown.menuHoverIn()")
end