profiles_test.rb
939 Bytes
require_relative 'test_helper'
class ProfilesTest < ActiveSupport::TestCase
def setup
Profile.delete_all
login_api
end
should 'list all profiles' do
person1 = fast_create(Person)
person2 = fast_create(Person)
community = fast_create(Community)
get "/api/v1/profiles?#{params.to_query}"
json = JSON.parse(last_response.body)
assert_equivalent [person.id, person1.id, person2.id, community.id], json.map {|p| p['id']}
end
should 'get person from profile id' do
some_person = fast_create(Person)
get "/api/v1/profiles/#{some_person.id}?#{params.to_query}"
json = JSON.parse(last_response.body)
assert_equal some_person.id, json['id']
end
should 'get community from profile id' do
community = fast_create(Community)
get "/api/v1/profiles/#{community.id}?#{params.to_query}"
json = JSON.parse(last_response.body)
assert_equal community.id, json['id']
end
end