Skip to content

Commit 5e0ff46

Browse files
author
Giorgio Torres
committed
Failing test for non-registered user creating ticket and beign registered.
1 parent 6b7aeaa commit 5e0ff46

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

test/controllers/api/v1/topics_test.rb

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -207,6 +207,30 @@ def app
207207
assert object['error'] == 'User not registered. Insufficient access priviledges.'
208208
end
209209

210+
test "a non-registered API user should be registered and able to create a ticket by email if name provided" do
211+
params = {
212+
name: "Got a problem",
213+
body: "This is some really profound question",
214+
user_email: 'not-registered-test-user@my-test-domain.com',
215+
user_name: 'User Not Registered',
216+
tag_list: 'tag1, tag2',
217+
}
218+
219+
assert_nil User.find_by(email: params[:user_email])
220+
221+
post '/api/v1/tickets.json', @default_params.merge(params)
222+
223+
assert_not_nil User.find_by(email: params[:user_email])
224+
object = JSON.parse(last_response.body)
225+
226+
assert_equal 1, object['forum_id']
227+
assert object['name'] == "Got a problem"
228+
assert object['posts'].count == 1
229+
assert object['posts'][0]['body'] == "This is some really profound question"
230+
assert_equal "api", object['channel']
231+
assert_equal 2, object['tag_list'].count
232+
end
233+
210234
test "an API user should be able to assign a ticket" do
211235
user = User.find(1)
212236
ticket = Topic.find(2)

0 commit comments

Comments
 (0)