File tree Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Expand file tree Collapse file tree 2 files changed +20
-5
lines changed Original file line number Diff line number Diff line change 1
1
module CirroIO
2
2
module Client
3
3
class Payout < Base
4
- belongs_to :app_worker
4
+ has_one :app_worker
5
5
end
6
6
end
7
7
end
Original file line number Diff line number Diff line change 23
23
end
24
24
25
25
describe '.create' do
26
- let ( :payout ) { described_class . create app_worker_id : app_worker . id , ** attributes }
27
-
26
+ let ( :request_url ) { " #{ test_site } /v1/payouts" }
27
+ let ( :payout ) { described_class . create app_worker : app_worker , ** attributes }
28
28
let ( :attributes ) do
29
29
{
30
30
title : Faker ::Hipster . sentence ,
35
35
end
36
36
37
37
before do
38
- stub_request ( :post , " #{ test_site } /v1/app-workers/ #{ app_worker . id } /payouts" )
38
+ stub_request ( :post , request_url )
39
39
. with ( headers : request_headers )
40
40
. to_return ( body : File . read ( './spec/fixtures/payout.json' ) , headers : response_headers )
41
41
end
42
42
43
43
it 'creates a payout for the app worker' do
44
+ request_body = {
45
+ data : {
46
+ type : 'payouts' ,
47
+ relationships : {
48
+ 'app-worker' : {
49
+ data : {
50
+ type : 'app-workers' ,
51
+ id : 1 ,
52
+ } ,
53
+ } ,
54
+ } ,
55
+ attributes : attributes
56
+ }
57
+ }
58
+
44
59
expect ( payout ) . to be_persisted
45
- expect ( payout . app_worker_id ) . to eq 1
60
+ expect ( a_request ( :post , request_url ) . with ( body : request_body . to_json ) ) . to have_been_made
46
61
end
47
62
end
48
63
end
You can’t perform that action at this time.
0 commit comments