1
0
mirror of https://github.com/LaCasemate/fab-manager.git synced 2025-01-30 19:52:20 +01:00

(bug) fix users api tests

This commit is contained in:
Sylvain 2022-05-11 16:43:01 +02:00
parent ca5ccf7036
commit 752c46bd00

View File

@ -1,5 +1,7 @@
# frozen_string_literal: true # frozen_string_literal: true
require 'test_helper'
class MembersTest < ActionDispatch::IntegrationTest class MembersTest < ActionDispatch::IntegrationTest
# Called before every test method runs. Can be used # Called before every test method runs. Can be used
# to set up fixture information. # to set up fixture information.
@ -63,18 +65,14 @@ class MembersTest < ActionDispatch::IntegrationTest
test 'admin successfully updates a member' do test 'admin successfully updates a member' do
user = User.friendly.find('vlonchamp') user = User.friendly.find('vlonchamp')
user_hash = { user_hash = { user: JSON.parse(user.to_json) }
user: {
profile_attributes: JSON.parse(user.to_json)['profile']
}.merge(JSON.parse(user.to_json))
}
instagram = 'https://www.instagram.com/vanessa/' instagram = 'https://www.instagram.com/vanessa/'
put "/api/members/#{user.id}", params: user_hash.deep_merge( put "/api/members/#{user.id}", params: user_hash.deep_merge(
user: { user: {
group_id: 2, 'group_id' => 1,
profile_attributes: { 'profile_attributes' => {
instagram: instagram 'instagram' => instagram
} }
} }
).to_json, headers: default_headers ).to_json, headers: default_headers
@ -85,21 +83,21 @@ class MembersTest < ActionDispatch::IntegrationTest
# Check update result # Check update result
res = json_response(response.body) res = json_response(response.body)
assert_equal 2, res[:group_id], "user's group does not match" assert_equal 1, res[:group_id], "user's group does not match"
assert_equal instagram, res[:profile][:instagram], "user's social network not updated" assert_equal instagram, res[:profile_attributes][:instagram], "user's social network not updated"
end end
# test 'admin search for autocompletion of a member s name' do test 'admin search for autocompletion of a member s name' do
# get '/api/members/search/kevin?subscription=true' get '/api/members/search/kevin?subscription=true'
## Check response format & status # Check response format & status
# assert_equal 200, response.status, response.body assert_equal 200, response.status, response.body
# assert_equal Mime[:json], response.content_type assert_equal Mime[:json], response.content_type
## Check search result # Check search result
# res = json_response(response.body) res = json_response(response.body)
# assert_equal 1, res.length assert_equal 1, res.length
# assert_match /Kevin/, res[0][:name] assert_match /Kevin/, res[0][:name]
# end end
end end