From 28e752629a6be749972efc663e1bc0de216d7562 Mon Sep 17 00:00:00 2001 From: Seth Call Date: Wed, 29 Oct 2014 07:22:45 -0500 Subject: [PATCH] * show private recording on recording landing page to someone who was in the session --- ruby/lib/jam_ruby/lib/nav.rb | 4 ++ web/app/views/recordings/show.html.erb | 4 +- web/spec/features/recording_landing_spec.rb | 79 ++++++++++++++------- 3 files changed, 60 insertions(+), 27 deletions(-) diff --git a/ruby/lib/jam_ruby/lib/nav.rb b/ruby/lib/jam_ruby/lib/nav.rb index 7f58dad61..bfc788471 100644 --- a/ruby/lib/jam_ruby/lib/nav.rb +++ b/ruby/lib/jam_ruby/lib/nav.rb @@ -27,6 +27,10 @@ module JamRuby "#{base_url}/findSession" end + def self.session(session) + "#{base_url}/session/#{session.id}" + end + private def self.base_url diff --git a/web/app/views/recordings/show.html.erb b/web/app/views/recordings/show.html.erb index 747f6c383..b8e2bf74a 100644 --- a/web/app/views/recordings/show.html.erb +++ b/web/app/views/recordings/show.html.erb @@ -18,7 +18,7 @@ <% end %>
-<% if @claimed_recording.is_public %> +<% if @claimed_recording.is_public || @claimed_recording.recording.has_access?(current_user) %>
<% unless @claimed_recording.recording.band.blank? %>
@@ -97,7 +97,7 @@ <% end %>
-<% if @claimed_recording.is_public %> +<% if @claimed_recording.is_public || @claimed_recording.recording.has_access?(current_user) %> <% if signed_in? %> <% unless @claimed_recording.recording.band.nil? %> <%= render :partial => "shared/landing_sidebar", :locals => {:user => @claimed_recording.recording.band, :recent_history => @claimed_recording.recording.band.recent_history} %> diff --git a/web/spec/features/recording_landing_spec.rb b/web/spec/features/recording_landing_spec.rb index 45875b53b..6bf9f7beb 100644 --- a/web/spec/features/recording_landing_spec.rb +++ b/web/spec/features/recording_landing_spec.rb @@ -1,6 +1,6 @@ require 'spec_helper' -describe "Landing", :js => true, :type => :feature, :capybara_feature => true do +describe "Landing" do let (:user) { FactoryGirl.create(:user) } @@ -10,41 +10,70 @@ describe "Landing", :js => true, :type => :feature, :capybara_feature => true do Recording.delete_all end - before(:each) do - MusicSession.delete_all - sign_in_poltergeist(user) - end let (:claimed_recording) { FactoryGirl.create(:claimed_recording) } + let (:recording) { claimed_recording.recording } - it "should render comments" do + describe "no js required" do - recording = ClaimedRecording.first - comment = "test comment" - timestamp = "less than a minute ago" - url = "/recordings/#{claimed_recording.id}" - visit url + it "shows private recording to someone who was in the session" do + # make the session hidden + claimed_recording.is_public = false + claimed_recording.save! - fill_in "txtRecordingComment", with: comment - find('#btnPostComment').trigger(:click) + visit "/recordings/#{claimed_recording.id}" - # (1) Test a user creating a comment and ensure it displays. + # and verify that after we visit the page, we can see the name of it + find('strong', text: 'RECORDING NOT FOUND') - # comment body - find('div.comment-text', text: comment) + # log in the user who was a part of the session + sign_in(claimed_recording.user) - # timestamp - find('div.comment-timestamp', text: timestamp) + visit "/recordings/#{claimed_recording.id}" - # (2) Test a user visiting a landing page with an existing comment. + # and verify that after we visit the page, we can see the name of it + find('h2', text: claimed_recording.name) + end + end - # re-visit page to reload from database - visit url - # comment body - find('div.comment-text', text: comment) + describe "js required", :js => true, :type => :feature, :capybara_feature => true do - # timestamp - find('div.comment-timestamp', text: timestamp) + before(:each) do + MusicSession.delete_all + sign_in_poltergeist(user) + end + + + it "should render comments" do + + recording = ClaimedRecording.first + comment = "test comment" + timestamp = "less than a minute ago" + url = "/recordings/#{claimed_recording.id}" + 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.comment-text', text: comment) + + # timestamp + find('div.comment-timestamp', 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.comment-text', text: comment) + + # timestamp + find('div.comment-timestamp', text: timestamp) + end end end \ No newline at end of file