diff --git a/web/app/assets/javascripts/commentDialog.js b/web/app/assets/javascripts/commentDialog.js
index 702f52c80..f734c98fd 100644
--- a/web/app/assets/javascripts/commentDialog.js
+++ b/web/app/assets/javascripts/commentDialog.js
@@ -108,8 +108,19 @@
function events() {
var $btnSelector = $('#btn-add-comment', $screen);
- $btnSelector.unbind('click');
- $btnSelector.click(addComment);
+ var $txtComment = $('#txtComment', $screen);
+
+ if (!context.JK.currentUserId) {
+ console.log('here1');
+ $txtComment.attr('placeholder', 'You must be logged in to add a comment.');
+ $btnSelector.removeClass('button-orange');
+ $btnSelector.addClass('button-grey');
+ }
+ else {
+ console.log('here2');
+ $btnSelector.unbind('click');
+ $btnSelector.click(addComment);
+ }
}
function showDialog() {
diff --git a/web/app/assets/javascripts/feed.js b/web/app/assets/javascripts/feed.js
index 368bc81fb..c32871db9 100644
--- a/web/app/assets/javascripts/feed.js
+++ b/web/app/assets/javascripts/feed.js
@@ -283,24 +283,6 @@
return false;
}
- function toggleUserProfile() {
- var userId = $(this).attr('user-id');
- window.location = '/client#/profile/' + userId;
- return false;
- }
-
- function toggleBandProfile() {
- var bandId = $(this).attr('band-id');
- if (bandId == null) {
- var userId = $(this).attr('user-id');
- window.location = '/client#/profile/' + userId;
- }
- else {
- window.location = '/client#/bandProfile/' + bandId;
- }
- return false;
- }
-
function renderFeeds(feeds) {
$.each(feeds.entries, function(i, feed) {
@@ -320,9 +302,6 @@
$('.details', $feedItem).click(toggleSessionDetails);
$('.details-arrow', $feedItem).click(toggleSessionDetails);
$('.play-button', $feedItem).click(toggleSessionPlay);
- $('.avatar-tiny', $feedItem).click(toggleUserProfile);
- $('.musician-name', $feedItem).click(toggleUserProfile);
- $('.artist', $feedItem).click(toggleBandProfile);
if (!feed.session_removed_at)
{
@@ -407,7 +386,9 @@
else {
logger.warn("skipping feed type: " + feed.type);
}
- })
+
+ context.JK.bindProfileClickEvents();
+ });
}
function renderFeed(feed) {
diff --git a/web/app/assets/javascripts/utils.js b/web/app/assets/javascripts/utils.js
index f7957024f..0140c1b9f 100644
--- a/web/app/assets/javascripts/utils.js
+++ b/web/app/assets/javascripts/utils.js
@@ -170,14 +170,14 @@
$("[profileaction='band']", $parent).click(function(evt) {
closeDialogs();
console.log("navigating to band profile %o", $(this).attr('band-id'));
- context.location = "/client#/bandProfile/" + $(this).attr('band-id');
+ window.location = "/client#/bandProfile/" + $(this).attr('band-id');
});
$("[profileaction='musician']", $parent).unbind('click');
$("[profileaction='musician']", $parent).click(function(evt) {
closeDialogs();
console.log("navigating to musician profile %o", $(this).attr('user-id'));
- context.location = "/client#/profile/" + $(this).attr('user-id');
+ window.location = "/client#/profile/" + $(this).attr('user-id');
});
}
diff --git a/web/app/assets/javascripts/web/web.js b/web/app/assets/javascripts/web/web.js
index 78df2ad4c..ffcbebaa6 100644
--- a/web/app/assets/javascripts/web/web.js
+++ b/web/app/assets/javascripts/web/web.js
@@ -35,6 +35,7 @@
//= require hoverSession
//= require hoverRecording
//= require shareDialog
+//= require commentDialog
//= require layout
//= require user_dropdown
//= require jamkazam
diff --git a/web/app/views/clients/_recordingFinishedDialog.html.erb b/web/app/views/clients/_recordingFinishedDialog.html.erb
index 8714ae77f..13fd40181 100644
--- a/web/app/views/clients/_recordingFinishedDialog.html.erb
+++ b/web/app/views/clients/_recordingFinishedDialog.html.erb
@@ -16,7 +16,7 @@
diff --git a/web/app/views/layouts/web.html.erb b/web/app/views/layouts/web.html.erb
index 6615d4fc5..2515ae9da 100644
--- a/web/app/views/layouts/web.html.erb
+++ b/web/app/views/layouts/web.html.erb
@@ -80,7 +80,6 @@
<%= render "clients/hoverBand" %>
<%= render "clients/hoverSession" %>
<%= render "clients/hoverRecording" %>
- <%= render "clients/commentDialog" %>
<%= yield(:extra_dialogs) %>
diff --git a/web/app/views/users/_feed_music_session.html.haml b/web/app/views/users/_feed_music_session.html.haml
index d903ec43f..c1ea1ee33 100644
--- a/web/app/views/users/_feed_music_session.html.haml
+++ b/web/app/views/users/_feed_music_session.html.haml
@@ -4,7 +4,7 @@
= session_avatar(feed_item)
/ type and artist
.left.ml20.w15
- .title{:'session-id' => feed_item.id }
+ .title{hoveraction: 'session', :'session-id' => feed_item.id }
%a{:href => "/sessions/#{feed_item.id}", :target => "_blank"} SESSION
.artist
= session_artist_name(feed_item)
diff --git a/web/app/views/users/_feed_music_session_ajax.html.haml b/web/app/views/users/_feed_music_session_ajax.html.haml
index bc2b8ef04..15f5cc6c5 100644
--- a/web/app/views/users/_feed_music_session_ajax.html.haml
+++ b/web/app/views/users/_feed_music_session_ajax.html.haml
@@ -6,7 +6,7 @@
%img{ src: '{{data.feed_item.helpers.avatar}}' }
/ type and artist
.left.ml20.w15
- .title{:'session-id' => '{{data.feed_item.id}}' }
+ .title{hoveraction: 'session', :'session-id' => '{{data.feed_item.id}}' }
%a{:href => "/sessions/{{data.feed_item.id}}", :rel => "external"} SESSION
.artist
%a.artist{:hoveraction => '{{data.feed_item.helpers.artist_hoveraction}}', :profileaction => "{{data.feed_item.helpers.artist_hoveraction}}", :'{{data.feed_item.helpers.artist_datakey}}' => '{{data.feed_item.helpers.artist_id}}'}
@@ -63,10 +63,10 @@
= '{% _.each(data.feed_item.participants, function(user) { %}'
%tr
%td{:width => "24"}
- %a.avatar-tiny{:href => "#", :hoveraction => "musician", :'user-id' => '{{user.id}}'}
+ %a.avatar-tiny{:hoveraction => "musician", :profileaction => "musician", :'user-id' => '{{user.id}}'}
%img{src: '{{user.helpers.avatar}}'}
%td
- %a.musician-name{:href => "#", :hoveraction => "musician", :'user-id' => '{{user.id}}'}
+ %a.musician-name{:hoveraction => "musician", :profileaction => "musician", :'user-id' => '{{user.id}}'}
= '{{user.first_name}} {{user.last_name}}'
%td
.nowrap
diff --git a/web/app/views/users/_feed_recording.html.haml b/web/app/views/users/_feed_recording.html.haml
index 82b45d7c1..d487821c2 100644
--- a/web/app/views/users/_feed_recording.html.haml
+++ b/web/app/views/users/_feed_recording.html.haml
@@ -7,7 +7,7 @@
= recording_avatar(feed_item)
/ type and artist
.left.ml20.w15.feed-type-title
- .title{:'recording-id' => feed_item.candidate_claimed_recording.id }
+ .title{hoveraction: 'recording', :'recording-id' => feed_item.candidate_claimed_recording.id }
%a{:href => "/recordings/#{feed_item.candidate_claimed_recording.id}", :target => "_blank"} RECORDING
.artist
= recording_artist_name(feed_item)
diff --git a/web/app/views/users/_feed_recording_ajax.html.haml b/web/app/views/users/_feed_recording_ajax.html.haml
index b72758500..25198edeb 100644
--- a/web/app/views/users/_feed_recording_ajax.html.haml
+++ b/web/app/views/users/_feed_recording_ajax.html.haml
@@ -6,7 +6,7 @@
%img{ src: '{{data.feed_item.helpers.avatar}}' }
/ type and artist
.left.ml20.w15
- .title{:'recording-id' => '{{data.candidate_claimed_recording.id}}' }
+ .title{hoveraction: 'recording', :'recording-id' => '{{data.candidate_claimed_recording.id}}' }
%a{:href => "/recordings/{{data.candidate_claimed_recording.id}}", :rel => "external"} RECORDING
.artist
%a.artist{:hoveraction => '{{data.feed_item.helpers.artist_hoveraction}}', :profileaction => "{{data.feed_item.helpers.artist_hoveraction}}", :'{{data.feed_item.helpers.artist_datakey}}' => '{{data.feed_item.helpers.artist_id}}'}
@@ -83,10 +83,10 @@
= '{% _.each(data.feed_item.grouped_tracks, function(track) { %}'
%tr
%td{:width => "24"}
- %a.avatar-tiny{:href => "#", :hoveraction => "musician", :"user-id" => '{{track.musician.id}}'}
+ %a.avatar-tiny{:hoveraction => "musician", :profileaction => "musician", :"user-id" => '{{track.musician.id}}'}
%img{src: '{{track.musician.helpers.avatar}}'}
%td
- %a.musician-name{:href => "#", :hoveraction => "musician", :"user-id" => '{{track.musician.id}}'}
+ %a.musician-name{:hoveraction => "musician", :profileaction => "musician", :"user-id" => '{{track.musician.id}}'}
= '{{track.musician.first_name}} {{track.musician.last_name}}'
%td
.nowrap
diff --git a/web/spec/features/feed_spec.rb b/web/spec/features/feed_spec.rb
index d0005db7a..85620ae4f 100644
--- a/web/spec/features/feed_spec.rb
+++ b/web/spec/features/feed_spec.rb
@@ -13,19 +13,58 @@ describe "Feed", :js => true, :type => :feature, :capybara_feature => true do
describe "sessions" do
before(:each) do
+ MusicSessionHistory.delete_all
create_session(creator: user)
formal_leave_by(user)
end
# it "should render avatar" do
+ # it " and link to profile" do
+ # end
+
+ # it " and render artist hover bubble" do
+ # end
# end
# it "should render description" do
+ # it " and link to session landing" do
+ # end
+
+ # it " and render session hover bubble" do
+ # end
# end
- # it "should render stats" do
+ # it "should render artist name" do
+ # it " and link to profile" do
+ # end
+
+ # it " and render artist hover bubble"
# end
+ it "should render stats" do
+ visit "/client#/feed"
+
+ # initial stats
+ find('span.plays').should have_content('0')
+ find('span.comments').should have_content('0')
+ find('span.likes').should have_content('0')
+
+ # Comments
+ find('a.btn-comment').trigger(:click)
+ comment = 'this sounds great'
+ fill_in "txtComment", with: comment
+ find('#btn-add-comment').trigger(:click)
+ find('div.comment-text', text: comment)
+ find('#dialog-close-button', '[layout-id="comment-dialog"]').trigger(:click)
+
+ find('#btn-refresh-feed').trigger(:click)
+ find('span.comments').should have_content('1')
+
+ # Likes
+ find('a.btn-like').trigger(:click)
+ find('span.likes').should have_content('1')
+ end
+
it "should render details" do
visit "/client#/feed"
find('.feed-details a.details').trigger(:click)
@@ -56,26 +95,78 @@ describe "Feed", :js => true, :type => :feature, :capybara_feature => true do
before(:each) do
MusicSessionHistory.delete_all
+ Recording.delete_all
start_recording_with(user)
stop_recording
formal_leave_by(user)
end
# it "should render avatar" do
+ # it " and link to profile" do
+ # end
+
+ # it " and render artist hover bubble" do
+ # end
# end
# it "should render description" do
+ # it " and link to recording landing" do
+ # end
+
+ # it " and render recording hover bubble" do
+ # end
# end
- # it "should render stats" do
+ # it "should render artist name" do
+ # it " and link to profile" do
+ # end
+
+ # it " and render artist hover bubble"
# end
+ it "should render stats" do
+ visit "/client#/feed"
+
+ # close recording finished dialog
+ claim_recording("my recording", "my recording description")
+
+ MusicSessionHistory.delete_all
+
+ find('#btn-refresh-feed').trigger(:click)
+
+ # initial stats
+ find('span.plays').should have_content('0')
+ find('span.comments').should have_content('0')
+ find('span.likes').should have_content('0')
+
+ # ensure Share icon exists
+ find('a.btn-share')
+
+ # Comments
+ find('a.btn-comment').trigger(:click)
+ comment = 'this sounds great'
+ fill_in "txtComment", with: comment
+ find('#btn-add-comment').trigger(:click)
+ find('div.comment-text', text: comment)
+ find('#dialog-close-button', '[layout-id="comment-dialog"]').trigger(:click)
+
+ find('#btn-refresh-feed').trigger(:click)
+ find('span.comments').should have_content('1')
+
+ # Likes
+ find('a.btn-like').trigger(:click)
+ find('span.likes').should have_content('1')
+ end
+
it "should render details" do
visit "/client#/feed"
# close recording finished dialog
- find('#recording-finished-dialog h1')
- find('#discard-session-recording').trigger(:click)
+ claim_recording("my recording", "my recording description")
+
+ MusicSessionHistory.delete_all
+
+ find('#btn-refresh-feed').trigger(:click)
find('.feed-details a.details').trigger(:click)
@@ -94,7 +185,7 @@ describe "Feed", :js => true, :type => :feature, :capybara_feature => true do
# confirm navigate to user profile page
find(".avatar-tiny[user-id=\"#{user.id}\"][hoveraction=\"musician\"]").trigger(:click)
- find("#user-profile h2[id=profile-username]", text: user.name)
+ find("#user-profile h2[id=profile-username]", text: user.name)
end
# it "should render play widget" do
diff --git a/web/spec/features/home_spec.rb b/web/spec/features/home_spec.rb
index 31abb2387..42cb8604c 100644
--- a/web/spec/features/home_spec.rb
+++ b/web/spec/features/home_spec.rb
@@ -14,7 +14,7 @@ describe "Home Screen", :js => true, :type => :feature, :capybara_feature => tru
let(:user) { FactoryGirl.create(:user) }
- share_examples_for :has_footer do
+ shared_examples_for :has_footer do
it "should have footer elements" do
should have_selector('#footer-links')
find('#footer-links').should have_content('about')
diff --git a/web/spec/support/utilities.rb b/web/spec/support/utilities.rb
index 3040a535f..bfd7e150d 100644
--- a/web/spec/support/utilities.rb
+++ b/web/spec/support/utilities.rb
@@ -322,7 +322,7 @@ def claim_recording(name, description)
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')
+ page.should have_no_selector('h1', text: 'recording finished')
end
def set_session_as_private()