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.
- checksums.yaml +4 -4
- data/default_configuration/base_app/API_DOC/README +23 -0
- data/default_configuration/base_app/API_DOC/admin-menus +167 -0
- data/default_configuration/base_app/API_DOC/admin-pages +173 -0
- data/default_configuration/base_app/API_DOC/content-block +10 -0
- data/default_configuration/base_app/API_DOC/navigation +54 -0
- data/default_configuration/base_app/API_DOC/page +38 -0
- data/default_configuration/base_app/CHANGELOG.md +122 -0
- data/default_configuration/base_app/Capfile +26 -0
- data/default_configuration/base_app/Gemfile +7 -0
- data/default_configuration/base_app/Gemfile.lock +155 -0
- data/default_configuration/base_app/README.md +24 -0
- data/default_configuration/base_app/Rakefile +25 -0
- data/default_configuration/base_app/backend/Gemfile +45 -0
- data/default_configuration/base_app/backend/Gemfile.lock +292 -0
- data/default_configuration/base_app/backend/README +12 -0
- data/default_configuration/base_app/backend/Rakefile +10 -0
- data/default_configuration/base_app/backend/app/controllers/application_controller.rb +3 -0
- data/default_configuration/base_app/backend/app/controllers/confirmations_controller.rb +3 -0
- data/default_configuration/base_app/backend/app/controllers/passwords_controller.rb +3 -0
- data/default_configuration/base_app/backend/app/controllers/registrations_controller.rb +15 -0
- data/default_configuration/base_app/backend/app/models/ability.rb +13 -0
- data/default_configuration/base_app/backend/app/models/role/admin.rb +8 -0
- data/default_configuration/base_app/backend/app/models/user.rb +43 -0
- data/default_configuration/base_app/backend/autotest/discover.rb +2 -0
- data/default_configuration/base_app/backend/bin/bundle +3 -0
- data/default_configuration/base_app/backend/bin/rails +4 -0
- data/default_configuration/base_app/backend/bin/rake +4 -0
- data/default_configuration/base_app/backend/config.ru +6 -0
- data/default_configuration/base_app/backend/config/application.rb +71 -0
- data/default_configuration/base_app/backend/config/boot.rb +4 -0
- data/default_configuration/base_app/backend/config/database.yml.ci +9 -0
- data/default_configuration/base_app/backend/config/database.yml.example +22 -0
- data/default_configuration/base_app/backend/config/environment.rb +5 -0
- data/default_configuration/base_app/backend/config/environments/development.rb +45 -0
- data/default_configuration/base_app/backend/config/environments/production.rb +78 -0
- data/default_configuration/base_app/backend/config/environments/staging.rb +48 -0
- data/default_configuration/base_app/backend/config/environments/test.rb +47 -0
- data/default_configuration/base_app/backend/config/initializers/assets.rb +8 -0
- data/default_configuration/base_app/backend/config/initializers/backtrace_silencers.rb +7 -0
- data/default_configuration/base_app/backend/config/initializers/constants.rb +1 -0
- data/default_configuration/base_app/backend/config/initializers/cookies_serializer.rb +3 -0
- data/default_configuration/base_app/backend/config/initializers/devise.rb +241 -0
- data/default_configuration/base_app/backend/config/initializers/devise_token_auth.rb +22 -0
- data/default_configuration/base_app/backend/config/initializers/filter_parameter_logging.rb +4 -0
- data/default_configuration/base_app/backend/config/initializers/inflections.rb +16 -0
- data/default_configuration/base_app/backend/config/initializers/mime_types.rb +4 -0
- data/default_configuration/base_app/backend/config/initializers/session_store.rb +3 -0
- data/default_configuration/base_app/backend/config/initializers/smtp.rb +25 -0
- data/default_configuration/base_app/backend/config/initializers/time_formats.rb +12 -0
- data/default_configuration/base_app/backend/config/initializers/wrap_parameters.rb +14 -0
- data/default_configuration/base_app/backend/config/locales/en.yml +23 -0
- data/default_configuration/base_app/backend/config/locales/json.yml +29 -0
- data/default_configuration/base_app/backend/config/routes.rb +33 -0
- data/default_configuration/base_app/backend/config/secrets.yml.ci +22 -0
- data/default_configuration/base_app/backend/config/secrets.yml.example +57 -0
- data/default_configuration/base_app/backend/config/sidekiq.yml +4 -0
- data/default_configuration/base_app/backend/db/sample_data/users.rake +10 -0
- data/default_configuration/base_app/backend/db/seeds.rb +14 -0
- data/default_configuration/base_app/backend/lib/static-app.rb +15 -0
- data/default_configuration/base_app/backend/public/404.html +26 -0
- data/default_configuration/base_app/backend/public/422.html +26 -0
- data/default_configuration/base_app/backend/public/500.html +26 -0
- data/default_configuration/base_app/backend/public/favicon.ico +0 -0
- data/default_configuration/base_app/backend/public/index.html +0 -0
- data/default_configuration/base_app/backend/public/robots.txt +5 -0
- data/default_configuration/base_app/backend/script/rails +6 -0
- data/default_configuration/base_app/backend/spec/factories/user_sessions_factory.rb +6 -0
- data/default_configuration/base_app/backend/spec/factories/users_factory.rb +35 -0
- data/default_configuration/base_app/backend/spec/features/user_sends_reset_password_email_spec.rb +30 -0
- data/default_configuration/base_app/backend/spec/features/user_signs_up_spec.rb +32 -0
- data/default_configuration/base_app/backend/spec/models/role/admin_spec.rb +12 -0
- data/default_configuration/base_app/backend/spec/models/role_spec.rb +48 -0
- data/default_configuration/base_app/backend/spec/models/user_spec.rb +59 -0
- data/default_configuration/base_app/backend/spec/requests/resources_index_spec.rb +22 -0
- data/default_configuration/base_app/backend/spec/spec_helper.rb +65 -0
- data/default_configuration/base_app/backend/spec/support/devise_helper.rb +78 -0
- data/default_configuration/base_app/backend/spec/support/log_tests.rb +5 -0
- data/default_configuration/base_app/backend/spec/support/session_helpers.rb +67 -0
- data/default_configuration/base_app/backend/spec/tasks/sample_data_rake_spec.rb +17 -0
- data/default_configuration/base_app/backend/static-app.ru +3 -0
- data/default_configuration/base_app/codeclimate.yml +7 -0
- data/default_configuration/base_app/config/compass.rb +21 -0
- data/default_configuration/base_app/config/deploy.rb +157 -0
- data/default_configuration/base_app/config/deploy/bundle-config +4 -0
- data/default_configuration/base_app/config/deploy/production.rb +7 -0
- data/default_configuration/base_app/config/deploy/staging.rb +6 -0
- data/default_configuration/base_app/doc/01_fail_resources.txt +173 -0
- data/default_configuration/base_app/doc/02_fail_auth.txt +165 -0
- data/default_configuration/base_app/doc/03_fail_menus.txt +174 -0
- data/default_configuration/base_app/dummy-api/admin/menu_items/10.json +15 -0
- data/default_configuration/base_app/dummy-api/admin/menu_items/11.json +15 -0
- data/default_configuration/base_app/dummy-api/admin/menu_items/12.json +15 -0
- data/default_configuration/base_app/dummy-api/admin/menu_items/13.json +15 -0
- data/default_configuration/base_app/dummy-api/admin/menu_items/14.json +15 -0
- data/default_configuration/base_app/dummy-api/admin/menu_items/15.json +15 -0
- data/default_configuration/base_app/dummy-api/admin/menu_items/16.json +15 -0
- data/default_configuration/base_app/dummy-api/admin/menus.json +23 -0
- data/default_configuration/base_app/dummy-api/admin/menus/1.json +118 -0
- data/default_configuration/base_app/dummy-api/admin/menus/2.json +8 -0
- data/default_configuration/base_app/dummy-api/admin/pages.json +105 -0
- data/default_configuration/base_app/dummy-api/admin/pages/about_us.json +45 -0
- data/default_configuration/base_app/dummy-api/admin/pages/contact_us.json +36 -0
- data/default_configuration/base_app/dummy-api/admin/pages/gallery.json +36 -0
- data/default_configuration/base_app/dummy-api/admin/pages/home.json +36 -0
- data/default_configuration/base_app/dummy-api/admin/pages/homepage.json +18 -0
- data/default_configuration/base_app/dummy-api/admin/pages/links.json +36 -0
- data/default_configuration/base_app/dummy-api/admin/pages/newsletter.json +54 -0
- data/default_configuration/base_app/dummy-api/homepage.json +14 -0
- data/default_configuration/base_app/dummy-api/navigation/main.json +119 -0
- data/default_configuration/base_app/dummy-api/pages/about_us.json +41 -0
- data/default_configuration/base_app/dummy-api/pages/contact_us.json +32 -0
- data/default_configuration/base_app/dummy-api/pages/gallery.json +32 -0
- data/default_configuration/base_app/dummy-api/pages/home.json +32 -0
- data/default_configuration/base_app/dummy-api/pages/homepage.json +14 -0
- data/default_configuration/base_app/dummy-api/pages/links.json +32 -0
- data/default_configuration/base_app/dummy-api/pages/newsletter.json +50 -0
- data/default_configuration/base_app/dump.rdb +0 -0
- data/default_configuration/base_app/example-lrd-dev-tmux.conf +17 -0
- data/default_configuration/base_app/frontend/CHANGELOG.md +125 -0
- data/default_configuration/base_app/frontend/Gemfile +5 -0
- data/default_configuration/base_app/frontend/Gemfile.lock +34 -0
- data/default_configuration/base_app/frontend/Gruntfile.js +3 -0
- data/default_configuration/base_app/frontend/LICENSE +19 -0
- data/default_configuration/base_app/frontend/README.md +5 -0
- data/default_configuration/base_app/frontend/bin/index.html +0 -0
- data/default_configuration/base_app/frontend/build.config.js +110 -0
- data/default_configuration/base_app/frontend/changelog.tpl +23 -0
- data/default_configuration/base_app/frontend/config/compass.rb +33 -0
- data/default_configuration/base_app/frontend/config/environments/development.js +4 -0
- data/default_configuration/base_app/frontend/config/environments/integration.js +4 -0
- data/default_configuration/base_app/frontend/config/environments/production.js +3 -0
- data/default_configuration/base_app/frontend/config/environments/test.js +4 -0
- data/default_configuration/base_app/frontend/create +0 -0
- data/default_configuration/base_app/frontend/karma/karma-unit.tpl.js +80 -0
- data/default_configuration/base_app/frontend/module.prefix +1 -0
- data/default_configuration/base_app/frontend/module.suffix +1 -0
- data/default_configuration/base_app/frontend/npm-shrinkwrap.json +4334 -0
- data/default_configuration/base_app/frontend/package.json +75 -0
- data/default_configuration/base_app/frontend/sprockets/index.tpl.js +2 -0
- data/default_configuration/base_app/frontend/src/README.md +48 -0
- data/default_configuration/base_app/frontend/src/app/README.md +68 -0
- data/default_configuration/base_app/frontend/src/app/app.js +47 -0
- data/default_configuration/base_app/frontend/src/app/appConfig.js +19 -0
- data/default_configuration/base_app/frontend/src/app/auth/auth.js +66 -0
- data/default_configuration/base_app/frontend/src/app/auth/config.js +22 -0
- data/default_configuration/base_app/frontend/src/app/auth/confirmations/confirmations-success.tpl.html +1 -0
- data/default_configuration/base_app/frontend/src/app/auth/confirmations/confirmations.js +8 -0
- data/default_configuration/base_app/frontend/src/app/auth/confirmations/confirmationsStates.js +12 -0
- data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-request-success.tpl.html +3 -0
- data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-request.tpl.html +16 -0
- data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-update-success.tpl.html +3 -0
- data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords-update.tpl.html +21 -0
- data/default_configuration/base_app/frontend/src/app/auth/passwords/passwords.js +11 -0
- data/default_configuration/base_app/frontend/src/app/auth/passwords/passwordsControllers.js +47 -0
- data/default_configuration/base_app/frontend/src/app/auth/passwords/passwordsStates.js +38 -0
- data/default_configuration/base_app/frontend/src/app/auth/registrations/registrations-success.tpl.html +1 -0
- data/default_configuration/base_app/frontend/src/app/auth/registrations/registrations.js +14 -0
- data/default_configuration/base_app/frontend/src/app/auth/registrations/registrations.tpl.html +37 -0
- data/default_configuration/base_app/frontend/src/app/auth/registrations/registrationsControllers.js +25 -0
- data/default_configuration/base_app/frontend/src/app/auth/registrations/registrationsStates.js +18 -0
- data/default_configuration/base_app/frontend/src/app/auth/sessions/sessions-success.tpl.html +1 -0
- data/default_configuration/base_app/frontend/src/app/auth/sessions/sessions.js +18 -0
- data/default_configuration/base_app/frontend/src/app/auth/sessions/sessions.tpl.html +25 -0
- data/default_configuration/base_app/frontend/src/app/auth/sessions/sessionsControllers.js +26 -0
- data/default_configuration/base_app/frontend/src/app/auth/sessions/sessionsStates.js +20 -0
- data/default_configuration/base_app/frontend/src/app/homepage/homepage-show.tpl.html +2 -0
- data/default_configuration/base_app/frontend/src/app/homepage/homepage.js +10 -0
- data/default_configuration/base_app/frontend/src/app/homepage/homepage.tpl.html +13 -0
- data/default_configuration/base_app/frontend/src/app/homepage/homepageControllers.js +9 -0
- data/default_configuration/base_app/frontend/src/app/homepage/homepageStates.js +22 -0
- data/default_configuration/base_app/frontend/src/app/inner.tpl.html +16 -0
- data/default_configuration/base_app/frontend/src/app/root.tpl.html +2 -0
- data/default_configuration/base_app/frontend/src/app/rootController.js +8 -0
- data/default_configuration/base_app/frontend/src/app/rootStates.js +20 -0
- data/default_configuration/base_app/frontend/src/assets/README.md +4 -0
- data/default_configuration/base_app/frontend/src/assets/icons/alert.svg +1 -0
- data/default_configuration/base_app/frontend/src/common/README.md +19 -0
- data/default_configuration/base_app/frontend/src/common/components/OnLoginDirective/OnLoginDirective.js +17 -0
- data/default_configuration/base_app/frontend/src/common/components/adminOnly/admin-only.tpl.html +4 -0
- data/default_configuration/base_app/frontend/src/common/components/adminOnly/adminOnly.js +23 -0
- data/default_configuration/base_app/frontend/src/common/components/sessionLinks/session-links.tpl.html +5 -0
- data/default_configuration/base_app/frontend/src/common/components/sessionLinks/sessionLinks.js +25 -0
- data/default_configuration/base_app/frontend/src/common/components/signOut/signOut.js +19 -0
- data/default_configuration/base_app/frontend/src/common/config.js +27 -0
- data/default_configuration/base_app/frontend/src/index.html +86 -0
- data/default_configuration/base_app/frontend/src/styles/_constants.sass +14 -0
- data/default_configuration/base_app/frontend/src/styles/main.sass +52 -0
- data/default_configuration/base_app/frontend/src/styles/partials/_footer.sass +18 -0
- data/default_configuration/base_app/frontend/src/styles/partials/_forms.sass +9 -0
- data/default_configuration/base_app/frontend/src/styles/partials/_layout.sass +17 -0
- data/default_configuration/base_app/frontend/src/styles/partials/_navbar.sass +10 -0
- data/default_configuration/base_app/frontend/src/styles/partials/_typography.sass +18 -0
- data/default_configuration/base_app/frontend/src/styles/states/_errorFallback.sass +7 -0
- data/default_configuration/base_app/frontend/src/styles/states/_root_homepage.sass +8 -0
- data/default_configuration/base_app/frontend/test-help/xpath.js +9 -0
- data/default_configuration/base_app/frontend/test/app.js +24 -0
- data/default_configuration/base_app/frontend/test/auth/confirmations/confirmationsStates.js +46 -0
- data/default_configuration/base_app/frontend/test/auth/passwords/passwordsControllers.js +193 -0
- data/default_configuration/base_app/frontend/test/auth/passwords/passwordsStates.js +108 -0
- data/default_configuration/base_app/frontend/test/auth/registrations/registrationsControllers.js +117 -0
- data/default_configuration/base_app/frontend/test/auth/registrations/registrationsStates.js +64 -0
- data/default_configuration/base_app/frontend/test/auth/sessions/sessionsControllers.js +95 -0
- data/default_configuration/base_app/frontend/test/auth/sessions/sessionsStates.js +67 -0
- data/default_configuration/base_app/frontend/test/specHelper.js +33 -0
- data/default_configuration/base_app/frontend/test/support/mockDirective.js +13 -0
- data/default_configuration/base_app/frontend/test/support/stateResolveFn.js +3 -0
- data/default_configuration/base_app/frontend/test/support/testStates.js +20 -0
- data/default_configuration/base_app/frontend/tools.md +223 -0
- data/default_configuration/base_app/lib/capistrano/tasks/sidekiq.rake +218 -0
- data/default_configuration/base_app/static-app.ru +3 -0
- data/default_configuration/base_app/tmux-windows +68 -0
- data/default_configuration/base_app/tmux-windows.txt +53 -0
- data/lib/xing/cli.rb +8 -3
- data/lib/xing/cli/generators/new_project.rb +48 -13
- 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
|
+
});
|
data/default_configuration/base_app/frontend/test/auth/registrations/registrationsControllers.js
ADDED
@@ -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
|
+
});
|