diff --git a/db/up/music_session_constraints.sql b/db/up/music_session_constraints.sql
index c3cc58a19..f070bc571 100644
--- a/db/up/music_session_constraints.sql
+++ b/db/up/music_session_constraints.sql
@@ -1,6 +1,6 @@
alter table music_sessions_comments drop constraint music_sessions_comments_music_session_id_fkey;
alter table music_sessions_comments add constraint ms_comments_ms_history_fkey foreign key (music_session_id)
-references music_sessions_history(id) match simple
+references music_sessions_history(music_session_id) match simple
ON UPDATE NO ACTION ON DELETE CASCADE;
alter table music_sessions_likers drop constraint music_sessions_likers_music_session_id_fkey;
diff --git a/ruby/lib/jam_ruby/models/user.rb b/ruby/lib/jam_ruby/models/user.rb
index 24d273571..b5dac67a6 100644
--- a/ruby/lib/jam_ruby/models/user.rb
+++ b/ruby/lib/jam_ruby/models/user.rb
@@ -228,6 +228,10 @@ module JamRuby
return !administratively_created
end
+ def pending_friend_request?(user)
+ FriendRequest.where("((user_id='#{self.id}' AND friend_id='#{user.id}') OR (user_id='#{user.id}' AND friend_id='#{self.id}')) AND status is null").size > 0
+ end
+
def friends?(user)
self.friends.exists?(user)
end
diff --git a/ruby/spec/jam_ruby/models/band_filter_search_spec.rb b/ruby/spec/jam_ruby/models/band_filter_search_spec.rb
index d1fca2b11..7912304a8 100644
--- a/ruby/spec/jam_ruby/models/band_filter_search_spec.rb
+++ b/ruby/spec/jam_ruby/models/band_filter_search_spec.rb
@@ -76,10 +76,12 @@ describe 'Band search' do
# refresh the order to ensure it works right
users.each_with_index do |u, index|
- f1 = Follow.new
- f1.user = u
- f1.followable = @band2
- f1.save
+ if index != 0
+ f1 = Follow.new
+ f1.user = u
+ f1.followable = @band2
+ f1.save
+ end
end
# @band2.followers.concat(users[1..-1])
diff --git a/ruby/spec/jam_ruby/models/musician_search_spec.rb b/ruby/spec/jam_ruby/models/musician_search_spec.rb
index 5f0b0dc62..a5caab73e 100644
--- a/ruby/spec/jam_ruby/models/musician_search_spec.rb
+++ b/ruby/spec/jam_ruby/models/musician_search_spec.rb
@@ -61,7 +61,7 @@ describe 'Musician search' do
f5.followable = @user3
f5.save
- # @user2
+ # @user2
f6 = Follow.new
f6.user = @user1
f6.followable = @user2
diff --git a/web/app/views/api_bands/liker_index.rabl b/web/app/views/api_bands/liker_index.rabl
index 9750b6e33..950d9d18c 100644
--- a/web/app/views/api_bands/liker_index.rabl
+++ b/web/app/views/api_bands/liker_index.rabl
@@ -10,6 +10,10 @@ node :last_name do |liker|
liker.user.last_name
end
+node :name do |liker|
+ liker.user.name
+end
+
node :city do |liker|
liker.user.city
end
@@ -22,6 +26,10 @@ node :country do |liker|
liker.user.country
end
+node :location do |liker|
+ liker.user.location
+end
+
node :musician do |liker|
liker.user.musician
end
diff --git a/web/app/views/api_users/band_like_index.rabl b/web/app/views/api_users/band_like_index.rabl
deleted file mode 100644
index 7283388cd..000000000
--- a/web/app/views/api_users/band_like_index.rabl
+++ /dev/null
@@ -1,27 +0,0 @@
-object @user.band_likes
-
-attributes :band_id
-
-node :name do |like|
- like.band.name
-end
-
-node :city do |like|
- like.band.city
-end
-
-node :state do |like|
- like.band.state
-end
-
-node :country do |like|
- like.band.country
-end
-
-node :photo_url do |like|
- like.band.photo_url
-end
-
-node :logo_url do |like|
- like.band.logo_url
-end
\ No newline at end of file
diff --git a/web/app/views/api_users/following_index.rabl b/web/app/views/api_users/following_index.rabl
index a3f46574d..09ab85c06 100644
--- a/web/app/views/api_users/following_index.rabl
+++ b/web/app/views/api_users/following_index.rabl
@@ -1,6 +1,6 @@
collection @user.followings
-node :user_id do |following|
+node :id do |following|
following.followable.id
end
diff --git a/web/app/views/api_users/like_index.rabl b/web/app/views/api_users/like_index.rabl
index daa46f44d..84f047016 100644
--- a/web/app/views/api_users/like_index.rabl
+++ b/web/app/views/api_users/like_index.rabl
@@ -1,31 +1,23 @@
object @user.likings
-attributes :user_id
-
-node :first_name do |liking|
- liking.user.first_name
+node :id do |liking|
+ liking.likable.id
end
-node :last_name do |liking|
- liking.user.last_name
+node :name do |liking|
+ liking.likable.name
end
-node :city do |liking|
- liking.user.city
-end
-
-node :state do |liking|
- liking.user.state
-end
-
-node :country do |liking|
- liking.user.country
+node :location do |liking|
+ liking.likable.location
end
node :musician do |liking|
- liking.user.musician
+ if liking.likable.instance_of?(JamRuby::User)
+ liking.likable.musician
+ end
end
node :photo_url do |liking|
- liking.user.photo_url
+ liking.likable.photo_url
end
\ No newline at end of file
diff --git a/web/app/views/api_users/show.rabl b/web/app/views/api_users/show.rabl
index 9b5c372b6..1ed5202e9 100644
--- a/web/app/views/api_users/show.rabl
+++ b/web/app/views/api_users/show.rabl
@@ -22,6 +22,9 @@ elsif current_user
node :is_liking do |uu|
current_user.likes?(@user)
end
+ node :pending_friend_request do |uu|
+ current_user.pending_friend_request?(@user)
+ end
end
child :friends => :friends do
diff --git a/web/app/views/clients/_hoverFan.html.erb b/web/app/views/clients/_hoverFan.html.erb
index 5cfbe892b..78dea24ba 100644
--- a/web/app/views/clients/_hoverFan.html.erb
+++ b/web/app/views/clients/_hoverFan.html.erb
@@ -38,8 +38,8 @@
diff --git a/web/app/views/clients/_hoverMusician.html.erb b/web/app/views/clients/_hoverMusician.html.erb
index 4787b660d..7eab7d658 100644
--- a/web/app/views/clients/_hoverMusician.html.erb
+++ b/web/app/views/clients/_hoverMusician.html.erb
@@ -54,9 +54,9 @@
diff --git a/web/spec/requests/musician_search_api_spec.rb b/web/spec/requests/musician_search_api_spec.rb
index 284a7f596..7cf8becd3 100644
--- a/web/spec/requests/musician_search_api_spec.rb
+++ b/web/spec/requests/musician_search_api_spec.rb
@@ -66,9 +66,42 @@ describe "Musician Search API", :type => :api do
context 'results have expected data' do
it "has follower stats " do
- @user4.followers.concat([@user2, @user3, @user4])
- @user3.followers.concat([@user3, @user4])
- @user2.followers.concat([@user4])
+ # @user4
+ f1 = Follow.new
+ f1.user = @user2
+ f1.followable = @user4
+ f1.save
+
+ f2 = Follow.new
+ f2.user = @user3
+ f2.followable = @user4
+ f2.save
+
+ f3 = Follow.new
+ f3.user = @user4
+ f3.followable = @user4
+ f3.save
+
+ # @user3
+ f4 = Follow.new
+ f4.user = @user3
+ f4.followable = @user3
+ f4.save
+
+ f5 = Follow.new
+ f5.user = @user4
+ f5.followable = @user3
+ f5.save
+
+ # @user2
+ f6 = Follow.new
+ f6.user = @user1
+ f6.followable = @user2
+ f6.save
+
+ # @user4.followers.concat([@user2, @user3, @user4])
+ # @user3.followers.concat([@user3, @user4])
+ # @user2.followers.concat([@user4])
expect(@user4.followers.count).to be 3
get_query
good_response
diff --git a/web/spec/requests/users_api_spec.rb b/web/spec/requests/users_api_spec.rb
index 848b817a2..2420b09da 100644
--- a/web/spec/requests/users_api_spec.rb
+++ b/web/spec/requests/users_api_spec.rb
@@ -56,7 +56,7 @@ describe "User API", :type => :api do
def delete_user_like(authenticated_user, source_user, target_user)
login(authenticated_user.email, authenticated_user.password, 200, true)
- delete "/api/users/#{source_user.id}/likes.json", { :user_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
+ delete "/api/users/#{source_user.id}/likes.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
return last_response
end
@@ -68,7 +68,7 @@ describe "User API", :type => :api do
def get_band_likes(authenticated_user, source_user)
login(authenticated_user.email, authenticated_user.password, 200, true)
- get "/api/users/#{source_user.id}/band_likes.json"
+ get "/api/users/#{source_user.id}/likes.json"
return last_response
end
@@ -99,21 +99,21 @@ describe "User API", :type => :api do
def delete_user_following(authenticated_user, source_user, target_user)
login(authenticated_user.email, authenticated_user.password, 200, true)
- delete "/api/users/#{source_user.id}/followings.json", { :user_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
+ delete "/api/users/#{source_user.id}/followings.json", { :target_entity_id => target_user.id }.to_json, "CONTENT_TYPE" => 'application/json'
return last_response
end
- # def create_band_following(authenticated_user, source_user, target_band)
- # login(authenticated_user.email, authenticated_user.password, 200, true)
- # post "/api/users/#{source_user.id}/followings.json", { :band_id => target_band.id }.to_json, "CONTENT_TYPE" => 'application/json'
- # return last_response
- # end
+ def create_band_following(authenticated_user, source_user, target_band)
+ login(authenticated_user.email, authenticated_user.password, 200, true)
+ post "/api/users/#{source_user.id}/followings.json", { :band_id => target_band.id }.to_json, "CONTENT_TYPE" => 'application/json'
+ return last_response
+ end
- # def get_band_followings(authenticated_user, source_user)
- # login(authenticated_user.email, authenticated_user.password, 200, true)
- # get "/api/users/#{source_user.id}/band_followings.json"
- # return last_response
- # end
+ def get_band_followings(authenticated_user, source_user)
+ login(authenticated_user.email, authenticated_user.password, 200, true)
+ get "/api/users/#{source_user.id}/followings.json"
+ return last_response
+ end
def get_band_followers(authenticated_user, source_band)
login(authenticated_user.email, authenticated_user.password, 200, true)
@@ -319,7 +319,7 @@ describe "User API", :type => :api do
last_response.status.should == 200
likes = JSON.parse(last_response.body)
likes.size.should == 1
- likes[0]["user_id"].should == fan.id
+ likes[0]["id"].should == fan.id
# get likers for other side of above like (fan)
last_response = get_user_likers(fan, fan)
@@ -339,7 +339,7 @@ describe "User API", :type => :api do
last_response.status.should == 200
likes = JSON.parse(last_response.body)
likes.size.should == 1
- likes[0]["band_id"].should == band.id
+ likes[0]["id"].should == band.id
# get likers for band
last_response = get_band_likers(user, band)
@@ -364,7 +364,7 @@ describe "User API", :type => :api do
last_response.status.should == 200
likes = JSON.parse(last_response.body)
likes.size.should == 1
- likes[0]["user_id"].should == fan.id
+ likes[0]["id"].should == fan.id
# delete like
last_response = delete_user_like(user, user, fan)
@@ -387,7 +387,7 @@ describe "User API", :type => :api do
last_response.status.should == 200
likes = JSON.parse(last_response.body)
likes.size.should == 1
- likes[0]["user_id"].should == fan.id
+ likes[0]["id"].should == fan.id
# attempt to delete like of another user
last_response = delete_user_like(fan, user, fan)
@@ -427,11 +427,11 @@ describe "User API", :type => :api do
last_response.status.should == 201
# get band followings
- # last_response = get_band_followings(user, user)
- # last_response.status.should == 200
- # followings = JSON.parse(last_response.body)
- # followings.size.should == 1
- # followings[0]["band_id"].should == band.id
+ last_response = get_band_followings(user, user)
+ last_response.status.should == 200
+ followings = JSON.parse(last_response.body)
+ followings.size.should == 1
+ followings[0]["band_id"].should == band.id
# get followers for band
last_response = get_band_followers(user, band)