xing-framework 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (216) hide show
  1. checksums.yaml +4 -4
  2. data/default_configuration/base_app/API_DOC/README +23 -0
  3. data/default_configuration/base_app/API_DOC/admin-menus +167 -0
  4. data/default_configuration/base_app/API_DOC/admin-pages +173 -0
  5. data/default_configuration/base_app/API_DOC/content-block +10 -0
  6. data/default_configuration/base_app/API_DOC/navigation +54 -0
  7. data/default_configuration/base_app/API_DOC/page +38 -0
  8. data/default_configuration/base_app/CHANGELOG.md +122 -0
  9. data/default_configuration/base_app/Capfile +26 -0
  10. data/default_configuration/base_app/Gemfile +7 -0
  11. data/default_configuration/base_app/Gemfile.lock +155 -0
  12. data/default_configuration/base_app/README.md +24 -0
  13. data/default_configuration/base_app/Rakefile +25 -0
  14. data/default_configuration/base_app/backend/Gemfile +45 -0
  15. data/default_configuration/base_app/backend/Gemfile.lock +292 -0
  16. data/default_configuration/base_app/backend/README +12 -0
  17. data/default_configuration/base_app/backend/Rakefile +10 -0
  18. data/default_configuration/base_app/backend/app/controllers/application_controller.rb +3 -0
  19. data/default_configuration/base_app/backend/app/controllers/confirmations_controller.rb +3 -0
  20. data/default_configuration/base_app/backend/app/controllers/passwords_controller.rb +3 -0
  21. data/default_configuration/base_app/backend/app/controllers/registrations_controller.rb +15 -0
  22. data/default_configuration/base_app/backend/app/models/ability.rb +13 -0
  23. data/default_configuration/base_app/backend/app/models/role/admin.rb +8 -0
  24. data/default_configuration/base_app/backend/app/models/user.rb +43 -0
  25. data/default_configuration/base_app/backend/autotest/discover.rb +2 -0
  26. data/default_configuration/base_app/backend/bin/bundle +3 -0
  27. data/default_configuration/base_app/backend/bin/rails +4 -0
  28. data/default_configuration/base_app/backend/bin/rake +4 -0
  29. data/default_configuration/base_app/backend/config.ru +6 -0
  30. data/default_configuration/base_app/backend/config/application.rb +71 -0
  31. data/default_configuration/base_app/backend/config/boot.rb +4 -0
  32. data/default_configuration/base_app/backend/config/database.yml.ci +9 -0
  33. data/default_configuration/base_app/backend/config/database.yml.example +22 -0
  34. data/default_configuration/base_app/backend/config/environment.rb +5 -0
  35. data/default_configuration/base_app/backend/config/environments/development.rb +45 -0
  36. data/default_configuration/base_app/backend/config/environments/production.rb +78 -0
  37. data/default_configuration/base_app/backend/config/environments/staging.rb +48 -0
  38. data/default_configuration/base_app/backend/config/environments/test.rb +47 -0
  39. data/default_configuration/base_app/backend/config/initializers/assets.rb +8 -0
  40. data/default_configuration/base_app/backend/config/initializers/backtrace_silencers.rb +7 -0
  41. data/default_configuration/base_app/backend/config/initializers/constants.rb +1 -0
  42. data/default_configuration/base_app/backend/config/initializers/cookies_serializer.rb +3 -0
  43. data/default_configuration/base_app/backend/config/initializers/devise.rb +241 -0
  44. data/default_configuration/base_app/backend/config/initializers/devise_token_auth.rb +22 -0
  45. data/default_configuration/base_app/backend/config/initializers/filter_parameter_logging.rb +4 -0
  46. data/default_configuration/base_app/backend/config/initializers/inflections.rb +16 -0
  47. data/default_configuration/base_app/backend/config/initializers/mime_types.rb +4 -0
  48. data/default_configuration/base_app/backend/config/initializers/session_store.rb +3 -0
  49. data/default_configuration/base_app/backend/config/initializers/smtp.rb +25 -0
  50. data/default_configuration/base_app/backend/config/initializers/time_formats.rb +12 -0
  51. data/default_configuration/base_app/backend/config/initializers/wrap_parameters.rb +14 -0
  52. data/default_configuration/base_app/backend/config/locales/en.yml +23 -0
  53. data/default_configuration/base_app/backend/config/locales/json.yml +29 -0
  54. data/default_configuration/base_app/backend/config/routes.rb +33 -0
  55. data/default_configuration/base_app/backend/config/secrets.yml.ci +22 -0
  56. data/default_configuration/base_app/backend/config/secrets.yml.example +57 -0
  57. data/default_configuration/base_app/backend/config/sidekiq.yml +4 -0
  58. data/default_configuration/base_app/backend/db/sample_data/users.rake +10 -0
  59. data/default_configuration/base_app/backend/db/seeds.rb +14 -0
  60. data/default_configuration/base_app/backend/lib/static-app.rb +15 -0
  61. data/default_configuration/base_app/backend/public/404.html +26 -0
  62. data/default_configuration/base_app/backend/public/422.html +26 -0
  63. data/default_configuration/base_app/backend/public/500.html +26 -0
  64. data/default_configuration/base_app/backend/public/favicon.ico +0 -0
  65. data/default_configuration/base_app/backend/public/index.html +0 -0
  66. data/default_configuration/base_app/backend/public/robots.txt +5 -0
  67. data/default_configuration/base_app/backend/script/rails +6 -0
  68. data/default_configuration/base_app/backend/spec/factories/user_sessions_factory.rb +6 -0
  69. data/default_configuration/base_app/backend/spec/factories/users_factory.rb +35 -0
  70. data/default_configuration/base_app/backend/spec/features/user_sends_reset_password_email_spec.rb +30 -0
  71. data/default_configuration/base_app/backend/spec/features/user_signs_up_spec.rb +32 -0
  72. data/default_configuration/base_app/backend/spec/models/role/admin_spec.rb +12 -0
  73. data/default_configuration/base_app/backend/spec/models/role_spec.rb +48 -0
  74. data/default_configuration/base_app/backend/spec/models/user_spec.rb +59 -0
  75. data/default_configuration/base_app/backend/spec/requests/resources_index_spec.rb +22 -0
  76. data/default_configuration/base_app/backend/spec/spec_helper.rb +65 -0
  77. data/default_configuration/base_app/backend/spec/support/devise_helper.rb +78 -0
  78. data/default_configuration/base_app/backend/spec/support/log_tests.rb +5 -0
  79. data/default_configuration/base_app/backend/spec/support/session_helpers.rb +67 -0
  80. data/default_configuration/base_app/backend/spec/tasks/sample_data_rake_spec.rb +17 -0
  81. data/default_configuration/base_app/backend/static-app.ru +3 -0
  82. data/default_configuration/base_app/codeclimate.yml +7 -0
  83. data/default_configuration/base_app/config/compass.rb +21 -0
  84. data/default_configuration/base_app/config/deploy.rb +157 -0
  85. data/default_configuration/base_app/config/deploy/bundle-config +4 -0
  86. data/default_configuration/base_app/config/deploy/production.rb +7 -0
  87. data/default_configuration/base_app/config/deploy/staging.rb +6 -0
  88. data/default_configuration/base_app/doc/01_fail_resources.txt +173 -0
  89. data/default_configuration/base_app/doc/02_fail_auth.txt +165 -0
  90. data/default_configuration/base_app/doc/03_fail_menus.txt +174 -0
  91. data/default_configuration/base_app/dummy-api/admin/menu_items/10.json +15 -0
  92. data/default_configuration/base_app/dummy-api/admin/menu_items/11.json +15 -0
  93. data/default_configuration/base_app/dummy-api/admin/menu_items/12.json +15 -0
  94. data/default_configuration/base_app/dummy-api/admin/menu_items/13.json +15 -0
  95. data/default_configuration/base_app/dummy-api/admin/menu_items/14.json +15 -0
  96. data/default_configuration/base_app/dummy-api/admin/menu_items/15.json +15 -0
  97. data/default_configuration/base_app/dummy-api/admin/menu_items/16.json +15 -0
  98. data/default_configuration/base_app/dummy-api/admin/menus.json +23 -0
  99. data/default_configuration/base_app/dummy-api/admin/menus/1.json +118 -0
  100. data/default_configuration/base_app/dummy-api/admin/menus/2.json +8 -0
  101. data/default_configuration/base_app/dummy-api/admin/pages.json +105 -0
  102. data/default_configuration/base_app/dummy-api/admin/pages/about_us.json +45 -0
  103. data/default_configuration/base_app/dummy-api/admin/pages/contact_us.json +36 -0
  104. data/default_configuration/base_app/dummy-api/admin/pages/gallery.json +36 -0
  105. data/default_configuration/base_app/dummy-api/admin/pages/home.json +36 -0
  106. data/default_configuration/base_app/dummy-api/admin/pages/homepage.json +18 -0
  107. data/default_configuration/base_app/dummy-api/admin/pages/links.json +36 -0
  108. data/default_configuration/base_app/dummy-api/admin/pages/newsletter.json +54 -0
  109. data/default_configuration/base_app/dummy-api/homepage.json +14 -0
  110. data/default_configuration/base_app/dummy-api/navigation/main.json +119 -0
  111. data/default_configuration/base_app/dummy-api/pages/about_us.json +41 -0
  112. data/default_configuration/base_app/dummy-api/pages/contact_us.json +32 -0
  113. data/default_configuration/base_app/dummy-api/pages/gallery.json +32 -0
  114. data/default_configuration/base_app/dummy-api/pages/home.json +32 -0
  115. data/default_configuration/base_app/dummy-api/pages/homepage.json +14 -0
  116. data/default_configuration/base_app/dummy-api/pages/links.json +32 -0
  117. data/default_configuration/base_app/dummy-api/pages/newsletter.json +50 -0
  118. data/default_configuration/base_app/dump.rdb +0 -0
  119. data/default_configuration/base_app/example-lrd-dev-tmux.conf +17 -0
  120. data/default_configuration/base_app/frontend/CHANGELOG.md +125 -0
  121. data/default_configuration/base_app/frontend/Gemfile +5 -0
  122. data/default_configuration/base_app/frontend/Gemfile.lock +34 -0
  123. data/default_configuration/base_app/frontend/Gruntfile.js +3 -0
  124. data/default_configuration/base_app/frontend/LICENSE +19 -0
  125. data/default_configuration/base_app/frontend/README.md +5 -0
  126. data/default_configuration/base_app/frontend/bin/index.html +0 -0
  127. data/default_configuration/base_app/frontend/build.config.js +110 -0
  128. data/default_configuration/base_app/frontend/changelog.tpl +23 -0
  129. data/default_configuration/base_app/frontend/config/compass.rb +33 -0
  130. data/default_configuration/base_app/frontend/config/environments/development.js +4 -0
  131. data/default_configuration/base_app/frontend/config/environments/integration.js +4 -0
  132. data/default_configuration/base_app/frontend/config/environments/production.js +3 -0
  133. data/default_configuration/base_app/frontend/config/environments/test.js +4 -0
  134. data/default_configuration/base_app/frontend/create +0 -0
  135. data/default_configuration/base_app/frontend/karma/karma-unit.tpl.js +80 -0
  136. data/default_configuration/base_app/frontend/module.prefix +1 -0
  137. data/default_configuration/base_app/frontend/module.suffix +1 -0
  138. data/default_configuration/base_app/frontend/npm-shrinkwrap.json +4334 -0
  139. data/default_configuration/base_app/frontend/package.json +75 -0
  140. data/default_configuration/base_app/frontend/sprockets/index.tpl.js +2 -0
  141. data/default_configuration/base_app/frontend/src/README.md +48 -0
  142. data/default_configuration/base_app/frontend/src/app/README.md +68 -0
  143. data/default_configuration/base_app/frontend/src/app/app.js +47 -0
  144. data/default_configuration/base_app/frontend/src/app/appConfig.js +19 -0
  145. data/default_configuration/base_app/frontend/src/app/auth/auth.js +66 -0
  146. data/default_configuration/base_app/frontend/src/app/auth/config.js +22 -0
  147. data/default_configuration/base_app/frontend/src/app/auth/confirmations/confirmations-success.tpl.html +1 -0
  148. data/default_configuration/base_app/frontend/src/app/auth/confirmations/confirmations.js +8 -0
  149. data/default_configuration/base_app/frontend/src/app/auth/confirmations/confirmationsStates.js +12 -0
  150. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-request-success.tpl.html +3 -0
  151. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-request.tpl.html +16 -0
  152. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-update-success.tpl.html +3 -0
  153. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-update.tpl.html +21 -0
  154. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords.js +11 -0
  155. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwordsControllers.js +47 -0
  156. data/default_configuration/base_app/frontend/src/app/auth/passwords/passwordsStates.js +38 -0
  157. data/default_configuration/base_app/frontend/src/app/auth/registrations/registrations-success.tpl.html +1 -0
  158. data/default_configuration/base_app/frontend/src/app/auth/registrations/registrations.js +14 -0
  159. data/default_configuration/base_app/frontend/src/app/auth/registrations/registrations.tpl.html +37 -0
  160. data/default_configuration/base_app/frontend/src/app/auth/registrations/registrationsControllers.js +25 -0
  161. data/default_configuration/base_app/frontend/src/app/auth/registrations/registrationsStates.js +18 -0
  162. data/default_configuration/base_app/frontend/src/app/auth/sessions/sessions-success.tpl.html +1 -0
  163. data/default_configuration/base_app/frontend/src/app/auth/sessions/sessions.js +18 -0
  164. data/default_configuration/base_app/frontend/src/app/auth/sessions/sessions.tpl.html +25 -0
  165. data/default_configuration/base_app/frontend/src/app/auth/sessions/sessionsControllers.js +26 -0
  166. data/default_configuration/base_app/frontend/src/app/auth/sessions/sessionsStates.js +20 -0
  167. data/default_configuration/base_app/frontend/src/app/homepage/homepage-show.tpl.html +2 -0
  168. data/default_configuration/base_app/frontend/src/app/homepage/homepage.js +10 -0
  169. data/default_configuration/base_app/frontend/src/app/homepage/homepage.tpl.html +13 -0
  170. data/default_configuration/base_app/frontend/src/app/homepage/homepageControllers.js +9 -0
  171. data/default_configuration/base_app/frontend/src/app/homepage/homepageStates.js +22 -0
  172. data/default_configuration/base_app/frontend/src/app/inner.tpl.html +16 -0
  173. data/default_configuration/base_app/frontend/src/app/root.tpl.html +2 -0
  174. data/default_configuration/base_app/frontend/src/app/rootController.js +8 -0
  175. data/default_configuration/base_app/frontend/src/app/rootStates.js +20 -0
  176. data/default_configuration/base_app/frontend/src/assets/README.md +4 -0
  177. data/default_configuration/base_app/frontend/src/assets/icons/alert.svg +1 -0
  178. data/default_configuration/base_app/frontend/src/common/README.md +19 -0
  179. data/default_configuration/base_app/frontend/src/common/components/OnLoginDirective/OnLoginDirective.js +17 -0
  180. data/default_configuration/base_app/frontend/src/common/components/adminOnly/admin-only.tpl.html +4 -0
  181. data/default_configuration/base_app/frontend/src/common/components/adminOnly/adminOnly.js +23 -0
  182. data/default_configuration/base_app/frontend/src/common/components/sessionLinks/session-links.tpl.html +5 -0
  183. data/default_configuration/base_app/frontend/src/common/components/sessionLinks/sessionLinks.js +25 -0
  184. data/default_configuration/base_app/frontend/src/common/components/signOut/signOut.js +19 -0
  185. data/default_configuration/base_app/frontend/src/common/config.js +27 -0
  186. data/default_configuration/base_app/frontend/src/index.html +86 -0
  187. data/default_configuration/base_app/frontend/src/styles/_constants.sass +14 -0
  188. data/default_configuration/base_app/frontend/src/styles/main.sass +52 -0
  189. data/default_configuration/base_app/frontend/src/styles/partials/_footer.sass +18 -0
  190. data/default_configuration/base_app/frontend/src/styles/partials/_forms.sass +9 -0
  191. data/default_configuration/base_app/frontend/src/styles/partials/_layout.sass +17 -0
  192. data/default_configuration/base_app/frontend/src/styles/partials/_navbar.sass +10 -0
  193. data/default_configuration/base_app/frontend/src/styles/partials/_typography.sass +18 -0
  194. data/default_configuration/base_app/frontend/src/styles/states/_errorFallback.sass +7 -0
  195. data/default_configuration/base_app/frontend/src/styles/states/_root_homepage.sass +8 -0
  196. data/default_configuration/base_app/frontend/test-help/xpath.js +9 -0
  197. data/default_configuration/base_app/frontend/test/app.js +24 -0
  198. data/default_configuration/base_app/frontend/test/auth/confirmations/confirmationsStates.js +46 -0
  199. data/default_configuration/base_app/frontend/test/auth/passwords/passwordsControllers.js +193 -0
  200. data/default_configuration/base_app/frontend/test/auth/passwords/passwordsStates.js +108 -0
  201. data/default_configuration/base_app/frontend/test/auth/registrations/registrationsControllers.js +117 -0
  202. data/default_configuration/base_app/frontend/test/auth/registrations/registrationsStates.js +64 -0
  203. data/default_configuration/base_app/frontend/test/auth/sessions/sessionsControllers.js +95 -0
  204. data/default_configuration/base_app/frontend/test/auth/sessions/sessionsStates.js +67 -0
  205. data/default_configuration/base_app/frontend/test/specHelper.js +33 -0
  206. data/default_configuration/base_app/frontend/test/support/mockDirective.js +13 -0
  207. data/default_configuration/base_app/frontend/test/support/stateResolveFn.js +3 -0
  208. data/default_configuration/base_app/frontend/test/support/testStates.js +20 -0
  209. data/default_configuration/base_app/frontend/tools.md +223 -0
  210. data/default_configuration/base_app/lib/capistrano/tasks/sidekiq.rake +218 -0
  211. data/default_configuration/base_app/static-app.ru +3 -0
  212. data/default_configuration/base_app/tmux-windows +68 -0
  213. data/default_configuration/base_app/tmux-windows.txt +53 -0
  214. data/lib/xing/cli.rb +8 -3
  215. data/lib/xing/cli/generators/new_project.rb +48 -13
  216. metadata +219 -7
@@ -0,0 +1,193 @@
1
+ import {appName} from 'config';
2
+ import {} from '../../../src/app/auth/passwords/passwords.js';
3
+
4
+ describe( 'Passwords controllers', function() {
5
+
6
+ beforeEach( module( `${appName}.auth.passwords` ) );
7
+
8
+ var $scope, $stateMock, $authMock, $toastMock, mockSerializer, mockLocation;
9
+
10
+ beforeEach(inject(function($q) {
11
+ $toastMock = {};
12
+ $toastMock.errorList = jasmine.createSpy('errorList');
13
+
14
+ $stateMock = jasmine.createSpyObj('$state', ["go", "href"]);
15
+
16
+ mockSerializer = function() {
17
+ this.serialize = function(data) {
18
+ return data;
19
+ };
20
+ };
21
+
22
+ // Lest anyone see this and think to imitate: don't.
23
+ // What should be happening is that we check that the authMock receives
24
+ // calls to requestPasswordReset with certain arguments, possibly returning
25
+ // certain values - *not* building a little mini $auth service in the test.
26
+ $authMock = {
27
+ requestPasswordReset(password_request) {
28
+ if (password_request.user.email) {
29
+ return $q((resolve, reject) => {
30
+ resolve();
31
+ });
32
+ } else {
33
+ return $q((resolve, reject) => {
34
+ reject({
35
+ data: {
36
+ errors: ["Missing Email"]
37
+ }
38
+ });
39
+ });
40
+ }
41
+ },
42
+ updatePassword(password_update) {
43
+ if (password_update.user.password &&
44
+ (password_update.user.password == password_update.user.passwordConfirmation)) {
45
+ return $q((resolve, reject) => {
46
+ resolve();
47
+ });
48
+ } else {
49
+ return $q((resolve, reject) => {
50
+ reject({
51
+ data: {
52
+ errors: { passwordConfirmation: "must match password" }
53
+ }
54
+ });
55
+ });
56
+ }
57
+ }
58
+ };
59
+
60
+ // And just to be clear "and.callThrough()" is the code smell here.
61
+ spyOn($authMock, 'requestPasswordReset').and.callThrough();
62
+ spyOn($authMock, 'updatePassword').and.callThrough();
63
+ }));
64
+
65
+ describe("Passwords Request Controller", function() {
66
+ var theUpdateUrl;
67
+
68
+ beforeEach( inject(function($controller, $rootScope) {
69
+ theUpdateUrl = "the://update.url/for_passwords";
70
+ $scope = $rootScope.$new();
71
+ $controller('PasswordsRequestCtrl', {
72
+ $scope: $scope,
73
+ $state: $stateMock,
74
+ $auth: $authMock,
75
+ $lrdToast: $toastMock,
76
+ $location: mockLocation,
77
+ Serializer: mockSerializer
78
+ });
79
+ $scope.$apply();
80
+ }));
81
+
82
+ it('should assign password request', function(){
83
+ expect($scope.passwordRequest).toEqualData({
84
+ email: ""});
85
+ });
86
+
87
+ describe("passwordRequestSubmit", function() {
88
+ describe("with valid request", function() {
89
+ beforeEach(function() {
90
+ $stateMock.href.and.returnValue(theUpdateUrl);
91
+ $scope.passwordRequest = { email: "bob@bob.com" };
92
+ $scope.passwordRequestSubmit();
93
+ $scope.$apply();
94
+ });
95
+
96
+ it ("should call the auth service", function() {
97
+ expect($authMock.requestPasswordReset).toHaveBeenCalled();
98
+ expect($authMock.requestPasswordReset.calls.mostRecent().args[0].update_url).toEqual(theUpdateUrl);
99
+ });
100
+
101
+ it ("should redirect to the password request success page", function() {
102
+ expect($stateMock.go).toHaveBeenCalledWith("root.inner.passwordsRequestSuccess");
103
+ });
104
+ });
105
+
106
+ describe("with invalid request", function() {
107
+ beforeEach(function() {
108
+ $scope.passwordRequest = { email: ''};
109
+ $scope.passwordRequestSubmit();
110
+ $scope.$apply();
111
+ });
112
+
113
+ it ("should call the auth service", function() {
114
+ expect($authMock.requestPasswordReset).toHaveBeenCalled();
115
+ });
116
+
117
+ it ("should set the toast error message", function() {
118
+ expect($toastMock.errorList).toHaveBeenCalledWith(["Missing Email"]);
119
+ });
120
+ });
121
+ });
122
+ });
123
+
124
+ describe("Passwords Update Controller", function() {
125
+ var theToken;
126
+
127
+ beforeEach( inject(function($controller, $rootScope) {
128
+ theToken = "someCryptoThingOrWhat";
129
+ mockLocation = jasmine.createSpyObj('$location', ['search']);
130
+ mockLocation.search.and.returnValue({token: theToken});
131
+
132
+ $scope = $rootScope.$new();
133
+ $controller('PasswordsUpdateCtrl', {
134
+ $scope: $scope,
135
+ $state: $stateMock,
136
+ $auth: $authMock,
137
+ $lrdToast: $toastMock,
138
+ Serializer: mockSerializer,
139
+ $location: mockLocation
140
+ });
141
+ $scope.$apply();
142
+ }));
143
+
144
+ it('should assign password update', function(){
145
+ expect($scope.passwordUpdate).toEqualData({
146
+ password: "",
147
+ passwordConfirmation: ""
148
+ });
149
+ });
150
+
151
+ describe("passwordUpdateSubmit", function() {
152
+ describe("with valid update", function() {
153
+ beforeEach(function() {
154
+ $scope.passwordUpdate = {
155
+ password: "jimbo",
156
+ passwordConfirmation: "jimbo"
157
+ };
158
+ $scope.passwordUpdateSubmit();
159
+ $scope.$apply();
160
+ });
161
+
162
+ it ("should call the auth service", function() {
163
+ expect($authMock.updatePassword).toHaveBeenCalled();
164
+ expect($authMock.updatePassword.calls.mostRecent().args[0].token).toEqual(theToken);
165
+ });
166
+
167
+ it ("should redirect to the passwords update success page", function() {
168
+ expect($stateMock.go).toHaveBeenCalledWith("root.inner.passwordsUpdateSuccess");
169
+ });
170
+ });
171
+
172
+ describe("with invalid request", function() {
173
+ beforeEach(function() {
174
+ $scope.passwordUpdate = {
175
+ password: "jimbo",
176
+ passwordConfirmation: "billyBob"
177
+ };
178
+ $scope.passwordUpdateSubmit();
179
+ $scope.$apply();
180
+ });
181
+
182
+ it ("should call the auth service", function() {
183
+ expect($authMock.updatePassword).toHaveBeenCalled();
184
+ });
185
+
186
+ it ("should set the toast error message", function() {
187
+ expect($toastMock.errorList).toHaveBeenCalledWith({ passwordConfirmation: "must match password" },
188
+ "We could not update your password because:");
189
+ });
190
+ });
191
+ });
192
+ });
193
+ });
@@ -0,0 +1,108 @@
1
+ import {appName} from 'config';
2
+ import {} from '../../../src/app/auth/passwords/passwords.js';
3
+ import {} from '../../support/testStates.js';
4
+ import {LoggedInOnlyState} from "stateClasses";
5
+
6
+ describe('Password Recovery states', function() {
7
+
8
+ var $rootScope, $state, $injector, state, $auth, $q;
9
+
10
+ beforeEach(function() {
11
+
12
+ module(`${appName}.testStates`);
13
+
14
+ module(`${appName}.auth.passwords`);
15
+
16
+ inject(function(_$rootScope_, _$state_, _$injector_, $templateCache, _$q_, _$auth_) {
17
+ $rootScope = _$rootScope_;
18
+ $state = _$state_;
19
+ $injector = _$injector_;
20
+ $q = _$q_;
21
+
22
+ $auth = _$auth_;
23
+
24
+ $templateCache.put('auth/passwords/passwords-request.tpl.html', '');
25
+ $templateCache.put('auth/passwords/passwords-request-success.tpl.html', '');
26
+ $templateCache.put('auth/passwords/passwords-update.tpl.html', '');
27
+ $templateCache.put('auth/passwords/passwords-update-success.tpl.html', '');
28
+ });
29
+ });
30
+
31
+ describe("passwordsRequest", function() {
32
+
33
+ beforeEach(function() {
34
+ state = $state.get('root.inner.passwordsRequest');
35
+ });
36
+
37
+ it('should respond to URL', function() {
38
+ expect($state.href(state)).toEqual('#/reset-password');
39
+ });
40
+
41
+ it('should render the passwords request template', function() {
42
+ expect(state.templateUrl).toEqual('auth/passwords/passwords-request.tpl.html');
43
+ });
44
+
45
+ it('should use the passwords request controller', function() {
46
+ expect(state.controller).toEqual('PasswordsRequestCtrl');
47
+ });
48
+
49
+ });
50
+
51
+ describe("passwordsRequestSuccess", function() {
52
+
53
+ beforeEach(function() {
54
+ state = $state.get('root.inner.passwordsRequestSuccess');
55
+ });
56
+
57
+ it('should respond to URL', function() {
58
+ expect($state.href(state)).toEqual('#/reset-password-sent');
59
+ });
60
+
61
+ it('should render the passwords request template', function() {
62
+ expect(state.templateUrl).toEqual('auth/passwords/passwords-request-success.tpl.html');
63
+ });
64
+
65
+ });
66
+
67
+ describe("passwordsUpdate", function() {
68
+
69
+ beforeEach(function() {
70
+ state = $state.get('root.inner.passwordsUpdate');
71
+ });
72
+
73
+ it('should extend LoggedInOnlyState', function() {
74
+ expect(state instanceof LoggedInOnlyState).toBe(true);
75
+ });
76
+
77
+ it('should respond to URL', function() {
78
+ expect($state.href(state)).toEqual('#/update-password');
79
+ });
80
+
81
+ it('should render the passwords update template', function() {
82
+ expect(state.templateUrl).toEqual('auth/passwords/passwords-update.tpl.html');
83
+ });
84
+
85
+ it('should use the passwords request controller', function() {
86
+ expect(state.controller).toEqual('PasswordsUpdateCtrl');
87
+ });
88
+ });
89
+
90
+ describe("passwordsUpdateSuccess", function() {
91
+
92
+ beforeEach(function() {
93
+ state = $state.get('root.inner.passwordsUpdateSuccess');
94
+ });
95
+
96
+ it('should extend LoggedInOnlyState', function() {
97
+ expect(state instanceof LoggedInOnlyState).toBe(true);
98
+ });
99
+
100
+ it('should respond to URL', function() {
101
+ expect($state.href(state)).toEqual('#/updated-password');
102
+ });
103
+
104
+ it('should render the sessions template', function() {
105
+ expect(state.templateUrl).toEqual('auth/passwords/passwords-update-success.tpl.html');
106
+ });
107
+ });
108
+ });
@@ -0,0 +1,117 @@
1
+ import {appName} from '../../../src/common/config.js';
2
+ import {} from '../../../src/app/auth/registrations/registrations.js';
3
+
4
+ describe( 'Registrations controllers', function() {
5
+
6
+ beforeEach( module( `${appName}.auth.registrations` ) );
7
+
8
+ var $scope, $stateMock, $authMock, $toastMock, mockSerializer;
9
+
10
+ beforeEach(inject(function($q) {
11
+ $toastMock = {};
12
+ $toastMock.errorList = jasmine.createSpy('errorList');
13
+
14
+ $stateMock = {
15
+ go(state){}
16
+ };
17
+
18
+ mockSerializer = function() {
19
+ this.serialize = function(data) {
20
+ return data;
21
+ };
22
+ };
23
+
24
+ spyOn($stateMock, 'go').and.callThrough();
25
+
26
+ $authMock = {
27
+ submitRegistration(registration) {
28
+ if (registration.user.email &&
29
+ (registration.user.email == registration.user.emailConfirmation) &&
30
+ registration.user.password &&
31
+ (registration.user.password == registration.user.passwordConfirmation)) {
32
+ return $q((resolve, reject) => {
33
+ resolve();
34
+ });
35
+ } else {
36
+ return $q((resolve, reject) => {
37
+ reject({
38
+ data: {
39
+ errors: { emailConfirmation: "must match email" }
40
+ }
41
+ });
42
+ });
43
+ }
44
+ }
45
+ };
46
+
47
+ spyOn($authMock, 'submitRegistration').and.callThrough();
48
+
49
+ }));
50
+
51
+ describe("Registrations Controller", function() {
52
+
53
+ beforeEach( inject(function($controller, $rootScope) {
54
+ $scope = $rootScope.$new();
55
+ $controller('RegistrationsCtrl', {
56
+ $scope: $scope,
57
+ $state: $stateMock,
58
+ $auth: $authMock,
59
+ $lrdToast: $toastMock,
60
+ Serializer: mockSerializer
61
+ });
62
+ $scope.$apply();
63
+ }));
64
+
65
+ it('should assign session', function(){
66
+ expect($scope.registration).toEqualData({
67
+ email: "",
68
+ emailConfirmation: "",
69
+ password: "",
70
+ passwordConfirmation: ""});
71
+ });
72
+
73
+ describe("registrationSubmit", function() {
74
+ describe("with valid sign up", function() {
75
+ beforeEach(function() {
76
+ $scope.registration = { email: "bob@bob.com",
77
+ emailConfirmation: "bob@bob.com",
78
+ password: "password",
79
+ passwordConfirmation: "password"
80
+ };
81
+ $scope.registrationSubmit();
82
+ $scope.$apply();
83
+ });
84
+
85
+ it ("should call the auth service", function() {
86
+ expect($authMock.submitRegistration).toHaveBeenCalled();
87
+ });
88
+
89
+ it ("should redirect to the sign in success page", function() {
90
+ expect($stateMock.go).toHaveBeenCalledWith("root.inner.registrationsSuccess");
91
+ });
92
+
93
+ });
94
+
95
+ describe("with invalid login", function() {
96
+ beforeEach(function() {
97
+ $scope.registration = { email: "bob@bob.com",
98
+ emailConfirmation: "jill@jill.com",
99
+ password: "wrong password",
100
+ passwordConfirmation: "wrong password"
101
+ };
102
+ $scope.registrationSubmit();
103
+ $scope.$apply();
104
+ });
105
+
106
+ it ("should call the auth service", function() {
107
+ expect($authMock.submitRegistration).toHaveBeenCalled();
108
+ });
109
+
110
+ it ("should set the toast error message", function() {
111
+ expect($toastMock.errorList).toHaveBeenCalledWith({ emailConfirmation: "must match email" },
112
+ "We cannot process your registration because:");
113
+ });
114
+ });
115
+ });
116
+ });
117
+ });
@@ -0,0 +1,64 @@
1
+ import {appName} from 'config';
2
+ import {} from '../../../src/app/auth/registrations/registrations.js';
3
+ import {} from '../../support/testStates.js';
4
+
5
+ describe('registrations states', function() {
6
+
7
+ var $rootScope, $state, $injector, state, $auth, $q;
8
+
9
+ beforeEach(function() {
10
+
11
+ module(`${appName}.testStates`);
12
+
13
+ module(`${appName}.auth.registrations`);
14
+
15
+ inject(function(_$rootScope_, _$state_, _$injector_, $templateCache, _$q_, _$auth_) {
16
+ $rootScope = _$rootScope_;
17
+ $state = _$state_;
18
+ $injector = _$injector_;
19
+ $q = _$q_;
20
+
21
+ $auth = _$auth_;
22
+
23
+ $templateCache.put('auth/registrations/registrations.tpl.html', '');
24
+ $templateCache.put('auth/registrations/registrations-success.tpl.html', '');
25
+ });
26
+ });
27
+
28
+ describe("registrations", function() {
29
+
30
+ beforeEach(function() {
31
+ state = $state.get('root.inner.registrations');
32
+ });
33
+
34
+ it('should respond to URL', function() {
35
+ expect($state.href(state)).toEqual('#/sign-up');
36
+ });
37
+
38
+ it('should render the sessions template', function() {
39
+ expect(state.templateUrl).toEqual('auth/registrations/registrations.tpl.html');
40
+ });
41
+
42
+ it('should use the sessions controller', function() {
43
+ expect(state.controller).toEqual('RegistrationsCtrl');
44
+ });
45
+
46
+ });
47
+
48
+ describe("registrationsSuccess", function() {
49
+
50
+ beforeEach(function() {
51
+ state = $state.get('root.inner.registrationsSuccess');
52
+ });
53
+
54
+ it('should respond to URL', function() {
55
+ expect($state.href(state)).toEqual('#/signed-up');
56
+ });
57
+
58
+ it('should render the sessions template', function() {
59
+ expect(state.templateUrl).toEqual('auth/registrations/registrations-success.tpl.html');
60
+ });
61
+
62
+ });
63
+
64
+ });