Skip to content
This repository was archived by the owner on Mar 4, 2025. It is now read-only.

Qa integration #873

Merged
merged 9 commits into from
Aug 4, 2016
1 change: 0 additions & 1 deletion app/profile/profile.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,6 @@ import moment from 'moment'
'COPILOT': 'copilot'
}

logger.debug()
vm.status = {
'badges': CONSTANTS.STATE_LOADING,
'stats': CONSTANTS.STATE_LOADING,
Expand Down
8 changes: 2 additions & 6 deletions app/services/jwtInterceptor.service.js
Original file line number Diff line number Diff line change
Expand Up @@ -27,8 +27,6 @@ import { isTokenExpired, getFreshToken } from 'tc-accounts'
.catch(function(err) {
// Server will not or cannot refresh token
logger.debug('Unable to refresh V3 token, redirecting to login')
var next = $state.href('dashboard', {}, {absolute: true})
$window.location = CONSTANTS.ACCOUNTS_APP_URL + '?retUrl=' + encodeURIComponent(next)

return null
})
Expand Down Expand Up @@ -82,10 +80,8 @@ import { isTokenExpired, getFreshToken } from 'tc-accounts'

// logger.debug('idToken: ' + idToken)
if (!TcAuthService.isAuthenticated() || idToken == null) {
// logger.debug('redirecting to accounts app')
var next = $state.href('dashboard', {}, {absolute: true})
$window.location = CONSTANTS.ACCOUNTS_APP_URL + '?retUrl=' + encodeURIComponent(next)
return
logger.debug(String.supplant('Skipping authToken for "{url}, UnAuthenticated user"', config))
return null
}

// Note only v3tokens expire
Expand Down
16 changes: 6 additions & 10 deletions app/services/jwtInterceptor.service.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -78,28 +78,24 @@ describe('JWT Interceptor Service', function() {
expect(TcAuthService.isAuthenticated).to.be.have.been.calledOnce
})

it('should redirect to login page for other endpoints', function() {
it('should return null as token for other endpoints', function() {
var config = {
method: 'get',
url: apiUrl + '/v3/members/test'
}
service.getToken(config)
expect($window.location).not.null
expect($window.location).to.have.string(CONSTANTS.ACCOUNTS_APP_URL)
var token = service.getToken(config)
expect(TcAuthService.isAuthenticated).to.be.have.been.calledOnce
expect(fakeState.href).to.be.calledWith('dashboard')
expect(token).to.be.null
})

it('should redirect to login page for other endpoints', function() {
it('should return null as token for other endpoints', function() {
var config = {
method: 'get',
url: apiUrl + '/v3.0.0-BETA/members/test'
}
service.getToken(config)
expect($window.location).not.null
expect($window.location).to.have.string(CONSTANTS.ACCOUNTS_APP_URL)
var token = service.getToken(config)
expect(TcAuthService.isAuthenticated).to.be.have.been.calledOnce
expect(fakeState.href).to.be.calledWith('dashboard')
expect(token).to.be.null
})

afterEach(function() {
Expand Down
24 changes: 2 additions & 22 deletions app/skill-picker/skill-picker.controller.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import _ from 'lodash'

angular.module('tc.skill-picker').controller('SkillPickerController', SkillPickerController)

SkillPickerController.$inject = ['$scope', 'CONSTANTS', 'ProfileService', '$state', 'userProfile', 'featuredSkills', 'logger', 'toaster', 'MemberCertService', '$q', 'UserPreferencesService']
SkillPickerController.$inject = ['$scope', 'CONSTANTS', 'ProfileService', '$state', 'userProfile', 'featuredSkills', 'logger', 'toaster', 'MemberCertService', '$q']

function SkillPickerController($scope, CONSTANTS, ProfileService, $state, userProfile, featuredSkills, logger, toaster, MemberCertService, $q, UserPreferencesService) {
function SkillPickerController($scope, CONSTANTS, ProfileService, $state, userProfile, featuredSkills, logger, toaster, MemberCertService, $q) {
var vm = this
vm.ASSET_PREFIX = CONSTANTS.ASSET_PREFIX
vm.IOS_PROGRAM_ID = CONSTANTS.SWIFT_PROGRAM_ID
Expand All @@ -32,7 +32,6 @@ import _ from 'lodash'
* Activates the controller.
*/
function activate() {
addToMailingList()
initCommunities()
checkCommunityStatus()
}
Expand Down Expand Up @@ -138,25 +137,6 @@ import _ from 'lodash'
}
}

function addToMailingList() {
return UserPreferencesService.getEmailPreferences(userProfile).then(function(subscription) {
logger.debug(subscription)
if (!subscription) {
return UserPreferencesService.saveEmailPreferences(userProfile).then(function(resp) {
logger.debug(resp)
}).catch(function(err) {
// no error to user
//TODO some error alert to community admin
logger.debug('error in adding user to member list')
})
}
}).catch(function(err) {
// no error to user
//TODO some error alert to community admin
logger.debug('error in adding user to member list')
})
}

/**
* Persists the user's altered information.
*/
Expand Down
33 changes: 0 additions & 33 deletions app/skill-picker/skill-picker.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,39 +138,6 @@ describe('Skill Picker Controller', function() {
CONSTANTS.SWIFT_PROGRAM_ID = origSwiftProgId
})

it('should call mailchimp service to add subscription', function() {
expect(vm).to.exist
// getEmailPreferences should always be called
expect(userPrefSvc.getEmailPreferences).to.be.calledOnce
// saveEmailPreferences should be called once if not subscribed
// getEmailPreferences service mock returns null for mockProfile.userId
expect(userPrefSvc.saveEmailPreferences).to.be.calledOnce
})

it('should not call mailchimp service to add subscription', function() {
// reset getEmailPreferences, saveEmailPreferences spy's called count
userPrefSvc.getEmailPreferences.reset()
userPrefSvc.saveEmailPreferences.reset()
var scope = $rootScope.$new()

var profile = angular.copy(mockProfile)
// update userId to return valid object in service mock
profile.userId = 12345
vm = $controller('SkillPickerController', {
$scope: scope,
userProfile: profile,
featuredSkills: [],
$state: state
})
$rootScope.$digest()
expect(vm).to.exist
// getEmailPreferences should always be called
expect(userPrefSvc.getEmailPreferences).to.be.calledOnce
// saveEmailPreferences should not be called if already subscribed
// getEmailPreferences service mock returns valid object for userId 12345
expect(userPrefSvc.saveEmailPreferences).not.to.be.called
})

it('should add skill ', function() {
vm.toggleSkill(409)
expect(vm.mySkills).to.exist.have.length(1)
Expand Down
12 changes: 12 additions & 0 deletions webpack.config.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,18 @@ const config = require('appirio-tech-webpack-config')({
}
})

if (process.env.ENV === 'DEV') {
config.devServer = config.devServer ? config.devServer : {}
config.devServer.proxy = [
{
path: /\/members\/.*/,
bypass: function(req, res, proxyOptions) {
return '/index.html'
}
}
]
}

if (CI) config.output.publicPath = process.env.ASSET_PREFIX

if (accountsAppURL) {
Expand Down