79 lines
1.9 KiB
Ruby
79 lines
1.9 KiB
Ruby
require 'spec_helper'
|
|
|
|
describe "Landing" do
|
|
|
|
let (:user) { FactoryGirl.create(:user) }
|
|
|
|
before(:all) do
|
|
MusicSession.delete_all
|
|
ClaimedRecording.delete_all
|
|
Recording.delete_all
|
|
end
|
|
|
|
|
|
let (:claimed_recording) { FactoryGirl.create(:claimed_recording) }
|
|
let (:recording) { claimed_recording.recording }
|
|
|
|
describe "no js required" do
|
|
|
|
it "shows private recording to someone who was in the session" do
|
|
# make the session hidden
|
|
claimed_recording.is_public = false
|
|
claimed_recording.save!
|
|
|
|
visit "/recordings/#{claimed_recording.id}"
|
|
|
|
# and verify that after we visit the page, we can see the name of it
|
|
find('strong', text: 'RECORDING NOT FOUND')
|
|
|
|
# log in the user who was a part of the session
|
|
sign_in(claimed_recording.user)
|
|
|
|
visit "/recordings/#{claimed_recording.id}"
|
|
|
|
# and verify that after we visit the page, we can see the name of it
|
|
find('h2', text: claimed_recording.name)
|
|
end
|
|
end
|
|
|
|
|
|
describe "js required", :js => true, :type => :feature, :capybara_feature => true do
|
|
|
|
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 |