Skip to content

Commit bda7392

Browse files
committed
Merge pull request #11 from tonycapone/master
interceptor intercepts angular-ui templates
2 parents 97dbbda + c1d8061 commit bda7392

File tree

4 files changed

+23
-2
lines changed

4 files changed

+23
-2
lines changed

dist/angular-spring-data-rest.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ angular.module("spring-data-rest").provider("SpringDataRestInterceptor",
386386

387387
return {
388388
response: function (response) {
389+
if(!angular.isObject(response.data)){
390+
return response;
391+
}
389392
return SpringDataRestAdapter.process(response.data).then(function (processedResponse) {
390393
response.data = processedResponse;
391394
return response;

dist/angular-spring-data-rest.min.js

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/angular-spring-data-rest-interceptor-provider.js

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ angular.module("spring-data-rest").provider("SpringDataRestInterceptor",
1717

1818
return {
1919
response: function (response) {
20+
if(!angular.isObject(response.data)){
21+
return response;
22+
}
2023
return SpringDataRestAdapter.process(response.data).then(function (processedResponse) {
2124
response.data = processedResponse;
2225
return response;

test/angular-spring-data-rest-interceptor-provider.spec.js

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,9 +89,10 @@ describe("if the spring data rest interceptor is added", function () {
8989
// start the injectors previously registered with calls to angular.mock.module and assign it to the
9090
// this scope. See above for the description.
9191
var httpBackendVar = undefined;
92-
inject(function (_SpringDataRestAdapter_, $httpBackend) {
92+
inject(function (_SpringDataRestAdapter_, $httpBackend, _$http_) {
9393
SpringDataRestAdapter = _SpringDataRestAdapter_;
9494
httpBackendVar = $httpBackend;
95+
$http = _$http_;
9596
});
9697
this.httpBackend = httpBackendVar;
9798

@@ -133,4 +134,18 @@ describe("if the spring data rest interceptor is added", function () {
133134
this.httpBackend.verifyNoOutstandingExpectation();
134135
});
135136

137+
it(" it must not execute when a response is of type string", function () {
138+
var linkHref = "http://localhost:8080/categories";
139+
var responseString = "<html>test</html>";
140+
this.httpBackend.whenGET(linkHref).respond(200, responseString);
141+
this.httpBackend.expectGET(linkHref);
142+
143+
var data = $http.get(linkHref).then(function(response){
144+
data = response.data;
145+
});
146+
147+
this.httpBackend.flush();
148+
expect(data).toBe(responseString);
149+
});
150+
136151
});

0 commit comments

Comments
 (0)