Skip to content
Snippets Groups Projects
Commit aeb5dbb6 authored by Giovanne Marcelo's avatar Giovanne Marcelo
Browse files

add tag and untag tests

parent bd3335c7
No related branches found
No related tags found
No related merge requests found
...@@ -36,19 +36,43 @@ class V1::CollectionsControllerTest < ActionController::TestCase ...@@ -36,19 +36,43 @@ class V1::CollectionsControllerTest < ActionController::TestCase
test 'should user tagging a collection' do test 'should user tagging a collection' do
auth_request users(:jack) auth_request users(:jack)
tag = tags(:tag_three).name
post :tagging, id: collections(:ufpr).id, tag: { name: 'Test', owner_id: users(:jack).id, owner_type: 'User' } post :tagging, id: collections(:ufpr).id, tag: { name: tag, owner_id: users(:jack).id, owner_type: 'User' }
assert_response :created assert_response :created
end end
test 'should user untagging a collection' do test 'should user untagging a collection' do
auth_request users(:john) auth_request users(:john)
tag = tags(:tag_one).name tag = tags(:tag_one).name
delete :untagging, id: collections(:ufpr).id, tag: { name: tag } post :untagging, id: collections(:ufpr).id, tag: { name: tag, owner_id: users(:jack).id, owner_type: 'User' }
assert_response :ok
end
test 'should institution tagging a collection' do
auth_request users(:jack)
institution = institutions(:ufpr)
institution.users << users(:jack)
tag = tags(:tag_one).name
post :tagging, id: collections(:ufpr).id, tag: { name: tag, owner_id: institutions(:ufpr).id, owner_type: 'Institution' }
assert_response :created
end
test 'should institution untagging a collection' do
auth_request users(:john)
institution = institutions(:ufpr)
institution.users << users(:john)
tag = tags(:tag_two).name
delete :untagging, id: collections(:ufpr).id, tag: { name: tag , owner_id: institutions(:ufpr).id, owner_type: 'Institution' }
assert_response :ok assert_response :ok
end end
private private
def ensure_collection_is_persisted!(collection) def ensure_collection_is_persisted!(collection)
......
...@@ -6,4 +6,9 @@ tagging_one: ...@@ -6,4 +6,9 @@ tagging_one:
tagging_two: tagging_two:
tag: tag_one tag: tag_one
tagger: jack (User) tagger: jack (User)
taggable: one (LearningObject) taggable: one (LearningObject)
\ No newline at end of file
tagging_three:
tag: tag_two
tagger: ufpr (Institution)
taggable: ufpr (Collection)
\ No newline at end of file
tag_one: tag_one:
name: 'Português' name: 'Português'
tag_two:
name: 'Matemática'
tag_three:
name: 'Biologia'
\ No newline at end of file
...@@ -33,7 +33,7 @@ class TagTest < ActiveSupport::TestCase ...@@ -33,7 +33,7 @@ class TagTest < ActiveSupport::TestCase
assert john.tag(collection, with: ['Tag']) assert john.tag(collection, with: ['Tag'])
# check ufpr tags # check ufpr tags
assert_count 2, collection.tags assert_count 3, collection.tags
assert_count 2, john.taggings assert_count 2, john.taggings
end end
...@@ -44,7 +44,7 @@ class TagTest < ActiveSupport::TestCase ...@@ -44,7 +44,7 @@ class TagTest < ActiveSupport::TestCase
assert john.untag(collection, 'Tag') assert john.untag(collection, 'Tag')
# check ufpr tags # check ufpr tags
assert_count 1, collection.tags assert_count 2, collection.tags
assert_count 1, john.taggings assert_count 1, john.taggings
end end
......
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