Skip to content
Snippets Groups Projects
Commit d918e0b5 authored by Marcela Ribeiro de Oliveira's avatar Marcela Ribeiro de Oliveira
Browse files

Merge branch 'fix-activities-test' into 'master'

Fix activities test

See merge request !442
parents 4b32941d 17abcf0e
No related branches found
No related tags found
No related merge requests found
...@@ -4,7 +4,7 @@ module FollowableController ...@@ -4,7 +4,7 @@ module FollowableController
extend ActiveSupport::Concern extend ActiveSupport::Concern
included do included do
before_action :authenticate_user!, only: [:follow, :unfollow] before_action :authenticate_user!, only: [:follow, :unfollow, :follow_toggle]
end end
# POST /v1/users/1/follow # POST /v1/users/1/follow
......
...@@ -9,10 +9,10 @@ class V1::CollectionsController < ApplicationController ...@@ -9,10 +9,10 @@ class V1::CollectionsController < ApplicationController
include ::SubjectableController include ::SubjectableController
include ::StageableController include ::StageableController
before_action :authenticate_user!, only: [:create, :update, :destroy, :tagging, :untagging] before_action :authenticate_user!, only: [:create, :update, :destroy, :tagging, :untagging, :follow, :unfollow, :follow_toggle]
before_action :set_collection, only: [:show, :update, :destroy, :add_object, :delete_object, :subjecting, :unsubjecting, :add_stages, :remove_stages] before_action :set_collection, only: [:show, :update, :destroy, :add_object, :delete_object, :subjecting, :unsubjecting, :add_stages, :remove_stages, :follow, :unfollow, :follow_toggle]
before_action :set_new_collection, only: :index before_action :set_new_collection, only: :index
before_action :authorize!, except: [:create, :tagging, :untagging, :follow, :unfollow, :download] before_action :authorize!, except: [:create, :tagging, :untagging, :download]
# GET /v1/collections # GET /v1/collections
# GET /v1/collections.json # GET /v1/collections.json
......
class V1::FeedController < ApplicationController class V1::FeedController < ApplicationController
include ::Paginator include ::Paginator
include ActivitiesFilterService
before_action :authenticate_user! before_action :authenticate_user!
# GET v1/feed # GET v1/feed
...@@ -13,11 +14,23 @@ class V1::FeedController < ApplicationController ...@@ -13,11 +14,23 @@ class V1::FeedController < ApplicationController
private private
def activities_followed def activities_followed
activities = [] query = ""
values = [""]
current_user.watching.each do |watching| current_user.watching.each do |watching|
activities.push(*watching.activities_filtered.to_a) if !watching.respond_to?(:state) || watching.state == "published"
query += " (trackable_type = ? and trackable_id = ?) or (owner_type = ? and owner_id = ?) or (recipient_type = ? and recipient_id = ?) or"
values << watching.class.to_s
values << watching.id
values << watching.class.to_s
values << watching.id
values << watching.class.to_s
values << watching.id
end
end end
activities
values[0] = query[0..-3]
PublicActivity::Activity.where(key: activities_filter).where(values).order(created_at: :desc)
end end
end end
...@@ -7,4 +7,8 @@ module FollowablePolicy ...@@ -7,4 +7,8 @@ module FollowablePolicy
def unfollow? def unfollow?
record if user_exists? record if user_exists?
end end
def follow_toggle?
record if user_exists?
end
end end
...@@ -40,9 +40,10 @@ resource 'Activities' do ...@@ -40,9 +40,10 @@ resource 'Activities' do
include_context "authenticate_user" include_context "authenticate_user"
let(:id) { users.first.id } let(:id) { users.first.id }
before do before do
create(:follow, followable: users.first, user: @user) create(:follow, followable: users.first, user: @user)
create(:like, user: users.first)
end end
example 'Showing activities from a specific user' do example 'Showing activities from a specific user' do
...@@ -56,7 +57,8 @@ resource 'Activities' do ...@@ -56,7 +57,8 @@ resource 'Activities' do
include_context "authenticate_user" include_context "authenticate_user"
before do before do
create(:like, user: @user) create(:follow, followable: users.first, user: @user)
create(:like, user: users.first)
end end
example 'Showing all activities that logged user can see' do example 'Showing all activities that logged user can see' do
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment