VRFS-1440 session and recording landing page comments should use timeago for timestamps

This commit is contained in:
Brian Smith 2014-04-06 16:43:32 -04:00
parent 887795bead
commit 6cda9023c7
5 changed files with 102 additions and 7 deletions

View File

@ -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('');

View File

@ -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);

View File

@ -7,7 +7,7 @@
<textarea id="<%= id %>" class="w100 p5 f15" rows="2" placeholder="Enter a comment..."></textarea>
</div>
<div class="right mr20">
<a href="#" id="btnPostComment" class="button-orange">POST</a>
<a id="btnPostComment" class="button-orange">POST</a>
</div>
<br clear="all" />
@ -24,7 +24,7 @@
<div class="w80 left p10 lightgrey mt10">
<a user-id="<%= c.user.id %>" hoveraction="<%= hoverAction %>" href="#"><%= c.user.name %></a>&nbsp;<%= c.comment %>
<br />
<div class="f12 grey mt5"><%= c.created_at.strftime("%b %e %Y, %l:%M %p") %></div>
<div class="f12 grey mt5"><%= timeago(c.created_at) %></div>
</div>
<br clear="all" />
<% end %>
@ -38,7 +38,7 @@
<div class="w80 left p10 lightgrey mt10">
<a href="#">{name}</a>&nbsp;{comment}
<br />
<div class="f12 grey mt5">Just now</div>
<div class="f12 grey mt5">{timeago}</div>
</div>
<br clear="all" />
</script>

View File

@ -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

View File

@ -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