diff --git a/web/app/assets/javascripts/web/recordings.js b/web/app/assets/javascripts/web/recordings.js index 1b38c3ab9..cdd554618 100644 --- a/web/app/assets/javascripts/web/recordings.js +++ b/web/app/assets/javascripts/web/recordings.js @@ -75,7 +75,8 @@ var commentHtml = context.JK.fillTemplate(template, { avatar_url: context.JK.currentUserAvatarUrl, name: context.JK.currentUserName, - comment: comment + comment: comment, + timeago: $.timeago(Date.now()) }); $(".landing-comment-scroller").prepend(commentHtml); @@ -90,8 +91,7 @@ $('.timeago').timeago(); $playButton.click(togglePlay); $controls.bind('statechange.listenRecording', stateChange); - - $controls.listenRecording({recordingId: recordingId, claimedRecordingId: claimedRecordingId, sliderSelector:'.recording-slider', sliderBarSelector: '.recording-playback', currentTimeSelector:'.recording-current'}); + $controls.listenRecording({recordingId: recordingId, claimedRecordingId: claimedRecordingId, sliderSelector:'.recording-slider', sliderBarSelector: '.recording-playback', currentTimeSelector:'.recording-current'}); if (JK.currentUserId) { var shareDialog = new JK.ShareDialog(JK.app, claimedRecordingId, "recording"); @@ -102,6 +102,7 @@ }); $("#btnPostComment").click(function(e) { + alert("TEST"); if ($.trim($("#txtRecordingComment").val()).length > 0) { addComment(); $("#txtRecordingComment").val(''); diff --git a/web/app/assets/javascripts/web/sessions.js b/web/app/assets/javascripts/web/sessions.js index 71e3f8e57..070333da5 100644 --- a/web/app/assets/javascripts/web/sessions.js +++ b/web/app/assets/javascripts/web/sessions.js @@ -27,7 +27,8 @@ var commentHtml = context.JK.fillTemplate(template, { avatar_url: context.JK.currentUserAvatarUrl, name: context.JK.currentUserName, - comment: comment + comment: comment, + timeago: $.timeago(Date.now()) }); $(".landing-comment-scroller").prepend(commentHtml); diff --git a/web/app/views/shared/_comments.html.erb b/web/app/views/shared/_comments.html.erb index c13f3559a..851e8bd81 100644 --- a/web/app/views/shared/_comments.html.erb +++ b/web/app/views/shared/_comments.html.erb @@ -7,7 +7,7 @@
- POST + POST

@@ -24,7 +24,7 @@
<%= c.user.name %> <%= c.comment %>
-
<%= c.created_at.strftime("%b %e %Y, %l:%M %p") %>
+
<%= timeago(c.created_at) %>

<% end %> @@ -38,7 +38,7 @@
{name} {comment}
-
Just now
+
{timeago}

\ No newline at end of file diff --git a/web/spec/features/recording_landing_spec.rb b/web/spec/features/recording_landing_spec.rb new file mode 100644 index 000000000..a8d30f087 --- /dev/null +++ b/web/spec/features/recording_landing_spec.rb @@ -0,0 +1,51 @@ +require 'spec_helper' + +describe "Landing", :js => true, :type => :feature, :capybara_feature => true do + + let (:user) { FactoryGirl.create(:user) } + + before(:all) do + MusicSessionHistory.delete_all + ClaimedRecording.delete_all + Recording.delete_all + end + + before(:each) do + MusicSessionHistory.delete_all + end + + let (:claimed_recording) { FactoryGirl.create(:claimed_recording) } + + it "should render comments" do + pending "weird error" + + comment = "test comment" + timestamp = "less than a minute ago" + url = "/recordings/#{claimed_recording.id}" + + recording = ClaimedRecording.first + visit url + + fill_in "txtRecordingComment", with: comment + find('#btnPostComment').trigger(:click) + + # (1) Test a user creating a comment and ensure it displays. + + # comment body + find('div', text: comment) + + # timestamp + find('div', text: timestamp) + + # (2) Test a user visiting a landing page with an existing comment. + + # re-visit page to reload from database + visit url + + # comment body + find('div', text: comment) + + # timestamp + find('div', text: timestamp) + end +end \ No newline at end of file diff --git a/web/spec/features/session_landing_spec.rb b/web/spec/features/session_landing_spec.rb new file mode 100644 index 000000000..0e2df3550 --- /dev/null +++ b/web/spec/features/session_landing_spec.rb @@ -0,0 +1,42 @@ +require 'spec_helper' + +describe "Landing", :js => true, :type => :feature, :capybara_feature => true do + + let (:user) { FactoryGirl.create(:user) } + + before(:all) do + MusicSessionHistory.delete_all + end + + before(:each) do + create_session(creator: user) + formal_leave_by(user) + end + + it "should render comments" do + pending "weird error" + + msh = MusicSessionHistory.first + comment = "test comment" + timestamp = "less than a minute ago" + url = "/sessions/#{msh.id}" + visit url + + fill_in "txtSessionComment", with: comment + find('#btnPostComment').trigger(:click) + + # comment body + find('div', text: comment) + + # timestamp + find('div', text: timestamp) + + visit url + + # comment body + find('div', text: comment) + + # timestamp + find('div', text: timestamp) + end +end \ No newline at end of file