Commit cdd1f702fef8c26321fb6855a774cddb25f71f0b
1 parent
a766ba55
Exists in
profile_api_improvements
and in
1 other branch
Ticket #85: Adding API endpoint to retrieve tags from a person
Showing
3 changed files
with
40 additions
and
0 deletions
Show diff stats
plugins/person_tags/lib/person_tags_plugin.rb
| ... | ... | @@ -0,0 +1,27 @@ |
| 1 | +require_relative '../test_helper' | |
| 2 | +require_relative '../../../../test/api/test_helper' | |
| 3 | + | |
| 4 | +class APITest < ActiveSupport::TestCase | |
| 5 | + | |
| 6 | + def setup | |
| 7 | + create_and_activate_user | |
| 8 | + environment.enable_plugin(PersonTagsPlugin) | |
| 9 | + end | |
| 10 | + | |
| 11 | + should 'return tags for a person' do | |
| 12 | + person = create_user('person').person | |
| 13 | + person.interest_list.add('linux') | |
| 14 | + person.save! | |
| 15 | + person.reload | |
| 16 | + get "/api/v1/people/#{person.id}/tags?#{params.to_query}" | |
| 17 | + json = JSON.parse(last_response.body) | |
| 18 | + assert_equal ['linux'], json | |
| 19 | + end | |
| 20 | + | |
| 21 | + should 'return empty list if person has no tags' do | |
| 22 | + person = create_user('person').person | |
| 23 | + get "/api/v1/people/#{person.id}/tags?#{params.to_query}" | |
| 24 | + json = JSON.parse(last_response.body) | |
| 25 | + assert_equal [], json | |
| 26 | + end | |
| 27 | +end | ... | ... |