This repository was archived by the owner on Oct 7, 2022. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Expand file tree Collapse file tree 2 files changed +36
-0
lines changed Original file line number Diff line number Diff line change @@ -33,6 +33,16 @@ def update_tags(tags)
33
33
@connection . put ( "creations/#{ id } " , :body => { 'data' => { 'type' => 'creations' , 'attributes' : { 'tags' => tags } } } )
34
34
end
35
35
36
+ def add_tags ( tags )
37
+ tags_data = tags . map { |tag | { type : 'tags' , id : tag } }
38
+ @connection . post ( "creations/#{ id } /tags" , body : { data : tags_data } )
39
+ end
40
+
41
+ def remove_tags ( tags )
42
+ tags_data = tags . map { |tag | { type : 'tags' , id : tag } }
43
+ @connection . delete ( "creations/#{ id } /tags" , body : { data : tags_data } )
44
+ end
45
+
36
46
def upload ( file )
37
47
extension = File . extname ( file ) [ 1 ..-1 ]
38
48
res = @connection . post ( "creations/#{ id } /uploads" , :params => { 'extension' => extension } )
Original file line number Diff line number Diff line change 38
38
expect ( subject . creators ) . to eq [ 'xUt6Feou' ]
39
39
end
40
40
end
41
+
42
+ describe 'add_tags' do
43
+ it "should trigger post on connection with correct params" do
44
+ expect ( connection ) . to receive ( :post ) . with (
45
+ "creations/#{ subject . id } /tags" , {
46
+ body : {
47
+ data : [
48
+ { type : "tags" , id : "a" } ,
49
+ { type : "tags" , id : "b" }
50
+ ] } } )
51
+ subject . add_tags ( [ 'a' , 'b' ] )
52
+ end
53
+ end
54
+
55
+ describe 'remove_tags' do
56
+ it "should trigger post on connection with correct params" do
57
+ expect ( connection ) . to receive ( :delete ) . with (
58
+ "creations/#{ subject . id } /tags" , {
59
+ body : {
60
+ data : [
61
+ { type : "tags" , id : "a" } ,
62
+ { type : "tags" , id : "b" }
63
+ ] } } )
64
+ subject . remove_tags ( [ 'a' , 'b' ] )
65
+ end
66
+ end
41
67
end
You can’t perform that action at this time.
0 commit comments