favourite_object 0.0.3 → 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/app/controllers/favourite_object/base_favourites_controller.rb +73 -81
- data/app/models/favourite_object/favourite.rb +58 -55
- data/app/serializer/favourite_object/favourite_serializer.rb +3 -5
- data/app/serializer/favourite_object/lite_favourite_serializer.rb +22 -0
- data/config/routes.rb +8 -8
- data/lib/favourite_object/engine.rb +4 -1
- data/lib/favourite_object/version.rb +1 -1
- data/lib/favourite_object.rb +1 -1
- data/lib/generators/favourite_object/install/install_generator.rb +8 -13
- data/lib/responders/json_responder.rb +15 -0
- data/spec/controllers/favourite_object/favourites_controller_spec.rb +80 -65
- data/spec/dummy/rails-4.0.2/Gemfile.lock +118 -0
- data/spec/dummy/rails-4.0.2/config/routes.rb +2 -0
- data/spec/dummy/rails-4.0.2/log/development.log +0 -0
- data/spec/dummy/rails-4.0.2/log/test.log +2938 -0
- data/spec/spec_helper.rb +8 -2
- metadata +51 -3
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e27704e25abb1b02018b0ba69c02b0af493123b2
|
4
|
+
data.tar.gz: 0958d771a5ad4a2241361d02436023cdb378bd85
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: c329fd5c05b62984903606d9b5b01a4f77aad64b9a52484a095640c0859388edb6e73fa34e8840d038e62481de36785c0334c15b4be64b44fe8a33b736d12354
|
7
|
+
data.tar.gz: 7ac833d5cba4aad23823c1969f443f78f14df94fa4863f769cb28a5ddfbc8ceea7cf43c34310bbe837233dc9fb4e6386d0d5e0cbca7f597f8ddd6f23ed829622
|
@@ -1,100 +1,92 @@
|
|
1
|
-
|
1
|
+
module FavouriteObject
|
2
|
+
class BaseFavouritesController < ApplicationController
|
3
|
+
respond_to :json
|
4
|
+
responders :json
|
2
5
|
|
3
|
-
|
4
|
-
#remove before commiting
|
5
|
-
skip_before_filter :verify_authenticity_token
|
6
|
+
before_filter :authenticate!
|
6
7
|
|
7
|
-
|
8
|
-
|
8
|
+
def index
|
9
|
+
collection
|
9
10
|
|
10
|
-
|
11
|
-
|
11
|
+
respond_to_method(params[:serializer])
|
12
|
+
end
|
12
13
|
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
.order("created_at DESC")
|
17
|
-
@favourites = @favourites.with_type(params[:type]) if params[:type]
|
18
|
-
collection_pagination
|
19
|
-
end
|
14
|
+
def collection
|
15
|
+
@favourites = Favourite.for_owner(@user)
|
16
|
+
.where(is_favourited: true).order("created_at DESC")
|
20
17
|
|
21
|
-
|
22
|
-
|
23
|
-
end
|
18
|
+
@favourites = @favourites.where(target_type: params[:target_type]) if params[:target_type]
|
19
|
+
@favourites = @favourites.where(target_id: params[:target_ids]) if params[:target_ids]
|
24
20
|
|
25
|
-
|
26
|
-
respond_to do |format|
|
27
|
-
format.html
|
28
|
-
format.json {render :json => @favourites, meta: { pagination: { per_page: @favourites.limit_value, total_pages: @favourites.total_pages, total_objects: @favourites.total_count } }}
|
21
|
+
collection_pagination
|
29
22
|
end
|
30
|
-
end
|
31
23
|
|
32
|
-
|
33
|
-
|
34
|
-
@favourite = FavouriteObject::Favourite.where(owner: @user, third_party_id: params[:target_id],
|
35
|
-
third_party_type: params[:target_type], third_party_flag: true).first_or_initialize
|
36
|
-
else
|
37
|
-
@favourite = FavouriteObject::Favourite.where(owner: @user, target_id: params[:target_id],
|
38
|
-
target_type: params[:target_type]).first_or_initialize
|
39
|
-
end
|
40
|
-
|
41
|
-
if @favourite.is_favourited == false
|
42
|
-
@favourite = {}
|
43
|
-
@favourite[:favourite] = nil
|
24
|
+
def collection_pagination
|
25
|
+
@favourites = @favourites.page(params[:page]).per(params[:per_page])
|
44
26
|
end
|
45
27
|
|
46
|
-
|
47
|
-
|
28
|
+
def respond_to_method(serializer)
|
29
|
+
if serializer == 'lite'
|
30
|
+
return respond_with @favourites, each_serializer: LiteFavouriteSerializer
|
31
|
+
end
|
32
|
+
respond_with @favourites
|
33
|
+
end
|
34
|
+
|
35
|
+
def show
|
36
|
+
@favourite = Favourite.find_with_target(@user, params[:target_id],
|
37
|
+
params[:target_type], params[:third_party_flag])
|
48
38
|
|
49
|
-
|
50
|
-
#endpoint for favouriting an object
|
51
|
-
if params[:third_party_flag] == 'true' || params[:third_party_flag] == '1'
|
52
|
-
favourite = FavouriteObject::Favourite.where(owner: @user, third_party_id: params[:target_id],
|
53
|
-
third_party_type: params[:target_type], third_party_flag: true).first_or_initialize
|
54
|
-
else
|
55
|
-
favourite = FavouriteObject::Favourite.where(owner: @user, target_id: params[:target_id],
|
56
|
-
target_type: params[:target_type]).first_or_initialize
|
57
|
-
end
|
58
|
-
|
59
|
-
# favourite.params = params[:data] if params[:data]
|
60
|
-
favourite.params = params[:data] if params[:data]
|
61
|
-
favourite.params[:description] = params[:description] if params[:description]
|
62
|
-
|
63
|
-
if params[:favourite] == 'true' || params[:favourite] == '1'
|
64
|
-
favourite.is_favourited = true
|
65
|
-
favourite.save
|
66
|
-
else
|
67
|
-
favourite.is_favourited = false
|
68
|
-
favourite.destroy
|
69
|
-
favourite = {}
|
70
|
-
favourite[:favourite] = nil
|
39
|
+
respond_with @favourite, serializer: LiteFavouriteSerializer
|
71
40
|
end
|
72
41
|
|
42
|
+
def update
|
43
|
+
@favourite = Favourite.find_with_target(@user, params[:target_id],
|
44
|
+
params[:target_type], params[:third_party_flag])
|
73
45
|
|
74
|
-
|
75
|
-
end
|
46
|
+
@favourite.update(permitted_params[:favourite])
|
76
47
|
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
else
|
85
|
-
favourite = FavouriteObject::Favourite.where(owner: @user, target_id: params[:target_id],
|
86
|
-
target_type: params[:target_type]).first_or_initialize
|
87
|
-
end
|
88
|
-
favourite.toggle
|
89
|
-
|
90
|
-
render :json => favourite, root: 'favourite'
|
91
|
-
end
|
48
|
+
respond_with @favourite, serializer: LiteFavouriteSerializer
|
49
|
+
end
|
50
|
+
|
51
|
+
def toggle
|
52
|
+
# toggle for web interface
|
53
|
+
@favourite = Favourite.find_with_target(@user, params[:target_id],
|
54
|
+
params[:target_type], params[:third_party_flag])
|
92
55
|
|
93
|
-
|
56
|
+
@favourite.toggle
|
94
57
|
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
58
|
+
respond_with @favourite
|
59
|
+
end
|
60
|
+
|
61
|
+
def meta
|
62
|
+
if action_name == 'index'
|
63
|
+
{
|
64
|
+
pagination: {
|
65
|
+
per_page: @favourites.limit_value,
|
66
|
+
total_pages: @favourites.total_pages,
|
67
|
+
total_objects: @favourites.total_count
|
68
|
+
}
|
69
|
+
}
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
private
|
74
|
+
|
75
|
+
def permitted_params
|
76
|
+
params.permit(favourite: [
|
77
|
+
:is_favourited,
|
78
|
+
:target_id,
|
79
|
+
:target_type,
|
80
|
+
:third_party_flag,
|
81
|
+
:third_party_id,
|
82
|
+
:third_party_type,
|
83
|
+
:params
|
84
|
+
])
|
85
|
+
end
|
86
|
+
|
87
|
+
def authenticate!
|
88
|
+
method(FavouriteObject.authentication_method).call
|
89
|
+
@user = method(FavouriteObject.current_user_method).call
|
90
|
+
end
|
99
91
|
end
|
100
92
|
end
|
@@ -1,73 +1,76 @@
|
|
1
1
|
module FavouriteObject
|
2
2
|
class Favourite < ActiveRecord::Base
|
3
|
-
|
3
|
+
self.table_name = "favourite_object_favourites"
|
4
4
|
|
5
|
-
|
6
|
-
|
5
|
+
belongs_to :target, polymorphic: true
|
6
|
+
belongs_to :owner, polymorphic: true
|
7
7
|
|
8
|
-
|
9
|
-
|
8
|
+
# Params for creating the notification message.
|
9
|
+
serialize :params, Hash
|
10
10
|
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
11
|
+
mattr_accessor :views
|
12
|
+
@@views = {
|
13
|
+
message: {
|
14
|
+
template_path: Proc.new {|n| "favourite_object/#{n.target_type.underscore}/message" }
|
15
|
+
}
|
16
|
+
}
|
17
17
|
|
18
|
-
|
19
|
-
|
20
|
-
|
18
|
+
if ActiveRecord::VERSION::MAJOR < 4
|
19
|
+
attr_accessible :target, :owner
|
20
|
+
end
|
21
21
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
22
|
+
def self.find_with_target(owner, target_id, target_type, third_party_flag=false)
|
23
|
+
if third_party_flag
|
24
|
+
return Favourite.for_owner(owner).find_or_initialize_by(third_party_id: target_id,
|
25
|
+
third_party_type: target_type, third_party_flag: true)
|
26
|
+
end
|
26
27
|
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
:template => self.class.views[:message][:template_path].call(self), :formats => [:html],
|
31
|
-
:locals => {object: self.target }, :layout => false)
|
32
|
-
end
|
28
|
+
Favourite.for_owner(owner).find_or_initialize_by(target_id: target_id,
|
29
|
+
target_type: target_type)
|
30
|
+
end
|
33
31
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
else
|
39
|
-
self.is_favourited = true
|
40
|
-
end
|
41
|
-
self.save
|
42
|
-
end
|
32
|
+
def self.for_owner(owner)
|
33
|
+
where(owner_id: owner.id)
|
34
|
+
.where(owner_type: owner.class.base_class)
|
35
|
+
end
|
43
36
|
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
37
|
+
def message
|
38
|
+
ActionView::Base.new(
|
39
|
+
Rails.configuration.paths["app/views"]).render(
|
40
|
+
:template => self.class.views[:message][:template_path].call(self), :formats => [:html],
|
41
|
+
:locals => {object: self.target }, :layout => false)
|
42
|
+
end
|
48
43
|
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
44
|
+
#toggles the is_favourited status
|
45
|
+
def toggle
|
46
|
+
if is_favourited
|
47
|
+
self.is_favourited = false
|
48
|
+
else
|
49
|
+
self.is_favourited = true
|
50
|
+
end
|
51
|
+
self.save
|
52
|
+
end
|
53
53
|
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
else
|
59
|
-
favourite = FavouriteObject::Favourite.where(owner: owner, target_id: target_id,
|
60
|
-
target_type: target_type).first
|
61
|
-
end
|
54
|
+
def favourite
|
55
|
+
self.is_favourited = true
|
56
|
+
self.save
|
57
|
+
end
|
62
58
|
|
63
|
-
|
59
|
+
def un_favourite
|
60
|
+
self.is_favourited = false
|
61
|
+
self.save
|
62
|
+
end
|
64
63
|
|
65
|
-
|
66
|
-
|
64
|
+
def self.is_favourited?(owner, target_id, target_type, third_party_flag=false)
|
65
|
+
favourite = self.find_with_target(owner, target_id, target_type, third_party_flag)
|
67
66
|
|
68
|
-
|
69
|
-
|
70
|
-
|
67
|
+
return false if favourite.blank? || favourite.is_favourited == false
|
68
|
+
true
|
69
|
+
end
|
70
|
+
|
71
|
+
def self.with_type(type)
|
72
|
+
where('target_type = ?', type)
|
73
|
+
end
|
71
74
|
|
72
75
|
end
|
73
76
|
end
|
@@ -1,9 +1,7 @@
|
|
1
1
|
class FavouriteObject::FavouriteSerializer < ActiveModel::Serializer
|
2
|
-
root :favourites
|
3
|
-
|
4
2
|
attributes :id, :target_id, :target_type, :is_favourited, :description, :third_party_flag, :data
|
5
3
|
embed :ids, :include => true
|
6
|
-
has_one :target, polymorphic: true
|
4
|
+
# has_one :target, polymorphic: true
|
7
5
|
|
8
6
|
def include_target?
|
9
7
|
(self.object.third_party_flag != true)
|
@@ -14,7 +12,7 @@ class FavouriteObject::FavouriteSerializer < ActiveModel::Serializer
|
|
14
12
|
self.object.params[:description]
|
15
13
|
else
|
16
14
|
self.object.message
|
17
|
-
end
|
15
|
+
end
|
18
16
|
end
|
19
17
|
|
20
18
|
def data
|
@@ -22,7 +20,7 @@ class FavouriteObject::FavouriteSerializer < ActiveModel::Serializer
|
|
22
20
|
self.object.params
|
23
21
|
else
|
24
22
|
[]
|
25
|
-
end
|
23
|
+
end
|
26
24
|
end
|
27
25
|
|
28
26
|
def target_id
|
@@ -0,0 +1,22 @@
|
|
1
|
+
class FavouriteObject::LiteFavouriteSerializer < ActiveModel::Serializer
|
2
|
+
root :favourite
|
3
|
+
|
4
|
+
attributes :id, :target_id, :target_type, :is_favourited, :third_party_flag
|
5
|
+
|
6
|
+
def target_id
|
7
|
+
if self.object.third_party_flag == true
|
8
|
+
self.object.third_party_id
|
9
|
+
else
|
10
|
+
self.object.target_id
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def target_type
|
15
|
+
if self.object.third_party_flag == true
|
16
|
+
self.object.third_party_type
|
17
|
+
else
|
18
|
+
self.object.target_type
|
19
|
+
end
|
20
|
+
end
|
21
|
+
|
22
|
+
end
|
data/config/routes.rb
CHANGED
@@ -1,8 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
end
|
1
|
+
FavouriteObject::Engine.routes.draw do
|
2
|
+
namespace :favourite_object do
|
3
|
+
resources :favourites, only: [:index]
|
4
|
+
get 'favourites/:target_type/:target_id' => 'favourites#show'
|
5
|
+
put 'favourites/:target_type/:target_id' => 'favourites#update'
|
6
|
+
put 'favourites/:target_type/:target_id/toggle' => 'favourites#toggle'
|
7
|
+
end
|
8
|
+
end
|
@@ -1,11 +1,14 @@
|
|
1
1
|
module FavouriteObject
|
2
2
|
class Engine < ::Rails::Engine
|
3
|
+
isolate_namespace FavouriteObject
|
4
|
+
|
3
5
|
config.generators do |g|
|
4
6
|
g.test_framework :rspec, :fixture => false
|
5
7
|
g.fixture_replacement :factory_girl, :dir => 'spec/factories'
|
6
8
|
g.assets false
|
7
9
|
g.helper false
|
8
10
|
end
|
9
|
-
|
11
|
+
|
12
|
+
config.autoload_paths += %W(#{config.root}/lib)
|
10
13
|
end
|
11
14
|
end
|
data/lib/favourite_object.rb
CHANGED
@@ -31,23 +31,18 @@ class FavouriteObject::InstallGenerator < Rails::Generators::Base
|
|
31
31
|
# This is defined in ActiveRecord::Generators::Base, but that inherits from NamedBase, so it expects a name argument
|
32
32
|
# which we don't want here. So we redefine it here. Yuck.
|
33
33
|
def self.next_migration_number(dirname)
|
34
|
-
|
35
|
-
|
36
|
-
else
|
37
|
-
"%.3d" % (current_migration_number(dirname) + 1)
|
38
|
-
end
|
34
|
+
next_migration_number = current_migration_number(dirname) + 1
|
35
|
+
ActiveRecord::Migration.next_migration_number(next_migration_number)
|
39
36
|
end
|
40
37
|
|
41
|
-
|
42
|
-
|
43
38
|
protected
|
44
39
|
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
end
|
40
|
+
def copy_migration(filename)
|
41
|
+
if self.class.migration_exists?("db/migrate", "#{filename}")
|
42
|
+
say_status("skipped", "Migration #{filename}.rb already exists")
|
43
|
+
else
|
44
|
+
migration_template "#{filename}.rb", "db/migrate/#{filename}.rb"
|
51
45
|
end
|
46
|
+
end
|
52
47
|
|
53
48
|
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
module Responders::JsonResponder
|
2
|
+
protected
|
3
|
+
|
4
|
+
# simply render the resource even on POST instead of redirecting for ajax
|
5
|
+
def api_behavior(error)
|
6
|
+
if post?
|
7
|
+
display resource, status: :created
|
8
|
+
# render resource instead of 204 no content
|
9
|
+
elsif put?
|
10
|
+
display resource, status: :ok
|
11
|
+
else
|
12
|
+
super
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -1,68 +1,83 @@
|
|
1
1
|
require 'spec_helper'
|
2
2
|
|
3
|
-
|
4
|
-
describe
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
3
|
+
module FavouriteObject
|
4
|
+
describe FavouritesController do
|
5
|
+
|
6
|
+
let(:user) { User.create({email: "user@example.com" })}
|
7
|
+
let(:arbitrary_object) { ArbitraryObject.create() }
|
8
|
+
let(:favourite) { Favourite.create(owner: user, target: arbitrary_object) }
|
9
|
+
|
10
|
+
before :each do
|
11
|
+
FavouritesController.any_instance.stub(:current_user).and_return(user)
|
12
|
+
FavouritesController.any_instance.stub(:authenticate_user!).and_return(true)
|
13
|
+
Favourite.any_instance.stub(:message).and_return("Mr. Blobby")
|
14
|
+
end
|
15
|
+
|
16
|
+
describe 'GET show' do
|
17
|
+
it "returns 200" do
|
18
|
+
get :show, target_type: arbitrary_object.class.name, target_id: arbitrary_object.id, format: :json, use_route: :favourite_object
|
19
|
+
expect(response.response_code).to eq 200
|
20
|
+
end
|
21
|
+
|
22
|
+
it "returns favourite status" do
|
23
|
+
favourite.update(is_favourited: true)
|
24
|
+
|
25
|
+
get :show, target_type: arbitrary_object.class.name, target_id: arbitrary_object.id, format: :json, use_route: :favourite_object
|
26
|
+
expect(json[:favourite][:is_favourited]).to eq true
|
27
|
+
end
|
28
|
+
end
|
29
|
+
|
30
|
+
describe "PUT update" do
|
31
|
+
it "favouriting object returns is_favourite true" do
|
32
|
+
put :update, target_type: arbitrary_object.class.name, target_id: arbitrary_object.id, favourite: {is_favourited: true}, format: :json, use_route: :favourite_object
|
33
|
+
expect(json[:favourite][:is_favourited]).to eq true
|
34
|
+
end
|
35
|
+
|
36
|
+
it "unfavouriting object returns is_favourite false" do
|
37
|
+
put :update, target_type: arbitrary_object.class.name, target_id: arbitrary_object.id, favourite: {is_favourited: false}, format: :json, use_route: :favourite_object
|
38
|
+
expect(json[:favourite][:is_favourited]).to eq false
|
39
|
+
end
|
40
|
+
end
|
41
|
+
|
42
|
+
## Index is used to display a list view of favourites
|
43
|
+
describe "GET index" do
|
44
|
+
it "returns 200" do
|
45
|
+
get :index, format: :json, use_route: :favourite_object
|
46
|
+
expect(response.response_code).to eq 200
|
47
|
+
end
|
48
|
+
|
49
|
+
## doesn't include message data, which adds response_time due to rendering n templates
|
50
|
+
it "returns lite payload" do
|
51
|
+
favourite.update(is_favourited: true)
|
52
|
+
|
53
|
+
get :index, format: :json, use_route: :favourite_object, serializer: 'lite'
|
54
|
+
expect(json[:favourites][0][:description]).to be_nil
|
55
|
+
end
|
56
|
+
|
57
|
+
it "filter by type only" do
|
58
|
+
favourite.update(is_favourited: true)
|
59
|
+
Favourite.create(owner: user, target_type: 'FakeObject', target_id: 5, is_favourited: true)
|
60
|
+
|
61
|
+
get :index, format: :json, use_route: :favourite_object, target_type: 'FakeObject'
|
62
|
+
expect(json[:favourites].count).to eq 1
|
63
|
+
end
|
64
|
+
|
65
|
+
it "returns favourite filtered by type and id" do
|
66
|
+
favourite.update(is_favourited: true)
|
67
|
+
Favourite.create(owner: user, target_type: 'FakeObject', target_id: 5, is_favourited: true)
|
68
|
+
|
69
|
+
get :index, format: :json, use_route: :favourite_object, target_type: 'FakeObject', target_ids: [5]
|
70
|
+
expect(json[:favourites].count).to eq 1
|
71
|
+
end
|
72
|
+
|
73
|
+
it "doesn't return favourite with another id" do
|
74
|
+
favourite.update(is_favourited: true)
|
75
|
+
Favourite.create(owner: user, target_type: 'FakeObject', target_id: 5, is_favourited: true)
|
76
|
+
|
77
|
+
get :index, format: :json, use_route: :favourite_object, target_type: 'FakeObject', target_ids: [6]
|
78
|
+
expect(json[:favourites].count).to eq 0
|
79
|
+
end
|
80
|
+
end
|
81
|
+
|
82
|
+
end
|
68
83
|
end
|