* VRFS-1135 a few more tests in controller for user and band targetting

This commit is contained in:
Seth Call 2014-02-20 08:01:18 +00:00
parent df14676495
commit 1940e6d8ff
2 changed files with 44 additions and 6 deletions

View File

@ -7,7 +7,7 @@ glue :music_session_history do
'music_session_history'
end
attributes :id, :description, :genres, :created_at, :session_removed_at, :comment_count, :like_count, :play_count
attributes :id, :description, :genres, :created_at, :session_removed_at, :comment_count, :like_count, :play_count, :fan_access
child(:user => :creator) {
@ -67,7 +67,7 @@ glue :recording do
child(:claimed_recordings => :claimed_recordings) {
attributes :id, :name, :description, :is_public, :is_downloadable, :genre_id
attributes :id, :name, :description, :is_public, :genre_id
child(:user => :creator) {
attributes :id, :first_name, :last_name, :photo_url

View File

@ -4,6 +4,8 @@ describe ApiFeedsController do
render_views
let(:user) { FactoryGirl.create(:user) }
let(:user2) { FactoryGirl.create(:user) }
let(:band) { FactoryGirl.create(:band) }
let(:music_session) {FactoryGirl.create(:music_session, creator: user) }
let(:claimed_recording) {FactoryGirl.create(:claimed_recording) }
@ -115,23 +117,59 @@ describe ApiFeedsController do
describe "user targetting" do
it "user viewing own profile" do
pending 'not tested'
music_session.fan_access = false
music_session.save!
controller.current_user = music_session.creator
get :index
get :index, { user: music_session.creator.id }
json = JSON.parse(response.body, :symbolize_names => true)
json[:entries].length.should == 1
end
it "user viewing someone else's profile" do
pending 'not tested'
music_session.fan_access = false
music_session.save!
controller.current_user = user2
music_session.music_session_history.reload
music_session.music_session_history.fan_access.should be_false
get :index, { user: music_session.creator.id }
json = JSON.parse(response.body, :symbolize_names => true)
json[:entries].length.should == 0
end
end
describe "band targetting" do
it "user viewing own band" do
user.bands << band
user.save!
claimed_recording1 = FactoryGirl.create(:claimed_recording, user: user)
claimed_recording1.is_public = false
claimed_recording1.recording.band = band
claimed_recording1.recording.save!
claimed_recording1.save!
controller.current_user = user
get :index
get :index, { band: band.id }
json = JSON.parse(response.body, :symbolize_names => true)
json[:entries].length.should == 1
end
it "user viewing someone else's band" do
user.bands << band
user.save!
claimed_recording1 = FactoryGirl.create(:claimed_recording, user: user)
claimed_recording1.is_public = false
claimed_recording1.recording.band = band
claimed_recording1.recording.save!
claimed_recording1.save!
controller.current_user = user2
get :index, { band: band.id }
json = JSON.parse(response.body, :symbolize_names => true)
json[:entries].length.should == 0
end