Browse Source

test custom first and last name for exports

hugh-obrien 8 năm trước cách đây
mục cha
commit
54ce196500

+ 2 - 2
services/web/app/coffee/Features/Exports/ExportsController.coffee

@@ -14,8 +14,8 @@ module.exports =
 		}
 
 		if req.body && req.body.firstName && req.body.firstName
-			export_params.first_name = req.body.firstName
-			export_params.last_name = req.body.lastName
+			export_params.first_name = req.body.firstName.trim()
+			export_params.last_name = req.body.lastName.trim()
 
 		ExportsHandler.exportProject export_params, (err, export_data) ->
 			return next(err) if err?

+ 29 - 0
services/web/test/unit/coffee/Exports/ExportsHandlerTests.coffee

@@ -109,6 +109,35 @@ describe 'ExportsHandler', ->
 				@callback.calledWith(null, expected_export_data)
 				.should.equal true
 
+		describe "when we send replacement user first and last name", ->
+			beforeEach (done) ->
+				@custom_first_name = "FIRST"
+				@custom_last_name = "LAST"
+				@export_params.first_name = @custom_first_name
+				@export_params.last_name = @custom_last_name
+				@ExportsHandler._buildExport @export_params, (error, export_data) =>
+					@callback(error, export_data)
+					done()
+
+			it "should send the data from the user input", ->
+				expected_export_data =
+					project:
+						id: @project_id
+						rootDocPath: @rootDocPath
+						historyId: @project_history_id
+						historyVersion: @historyVersion
+					user:
+						id: @user_id
+						firstName: @custom_first_name
+						lastName: @custom_last_name
+						email: @user.email
+						orcidId: null
+					destination:
+						brandVariationId: @brand_variation_id
+					options:
+						callbackUrl: null
+				@callback.calledWith(null, expected_export_data)
+				.should.equal true
 
 		describe "when project is not found", ->
 			beforeEach (done) ->