mirror of
https://github.com/sudoxnym/habitica-self-host.git
synced 2026-08-03 04:29:40 +00:00
parent
ed702a437d
commit
9d537d93d8
5 changed files with 110 additions and 2 deletions
|
|
@ -125,6 +125,8 @@
|
|||
"copyMessageAsToDo": "Copy message as To-Do",
|
||||
"messageAddedAsToDo": "Message copied as To-Do.",
|
||||
"messageWroteIn": "<%= user %> wrote in <%= group %>",
|
||||
"taskFromInbox": "<%= from %> wrote '<%= message %>'",
|
||||
"taskTextFromInbox": "Message from <%= from %>",
|
||||
"msgPreviewHeading": "Message Preview",
|
||||
"leaderOnlyChallenges": "Only group leader can create challenges",
|
||||
"sendGift": "Send Gift",
|
||||
|
|
|
|||
73
test/spec/controllers/inboxCtrlSpec.js
Normal file
73
test/spec/controllers/inboxCtrlSpec.js
Normal file
|
|
@ -0,0 +1,73 @@
|
|||
'use strict';
|
||||
|
||||
describe('inbox Controller', function() {
|
||||
var scope, ctrl, user, $rootScope, $controller;
|
||||
|
||||
beforeEach(function() {
|
||||
module(function($provide) {
|
||||
$provide.value('User', {});
|
||||
});
|
||||
|
||||
inject(function(_$rootScope_, _$controller_){
|
||||
user = specHelper.newUser();
|
||||
user._id = 'unique-user-id';
|
||||
$rootScope = _$rootScope_;
|
||||
|
||||
scope = _$rootScope_.$new();
|
||||
|
||||
$controller = _$controller_;
|
||||
|
||||
// Load RootCtrl to ensure shared behaviors are loaded
|
||||
$controller('RootCtrl', {$scope: scope, User: {user: user}});
|
||||
|
||||
ctrl = $controller('InboxCtrl', {$scope: scope});
|
||||
});
|
||||
});
|
||||
|
||||
describe('copyToDo', function() {
|
||||
it('when copying a user message it opens modal with information from message', function() {
|
||||
scope.group = {
|
||||
name: 'Princess Bride'
|
||||
};
|
||||
|
||||
sandbox.spy($rootScope, 'openModal');
|
||||
var message = {
|
||||
uuid: 'the-dread-pirate-roberts',
|
||||
user: 'Wesley',
|
||||
text: 'As you wish'
|
||||
};
|
||||
|
||||
scope.copyToDo(message);
|
||||
|
||||
expect($rootScope.openModal).to.be.calledOnce;
|
||||
expect($rootScope.openModal).to.be.calledWith('copyChatToDo', sinon.match(function(callArgToMatch){
|
||||
var taskText = env.t('taskTextFromInbox', {
|
||||
from: message.user
|
||||
});
|
||||
return callArgToMatch.controller == 'CopyMessageModalCtrl'
|
||||
&& callArgToMatch.scope.text == taskText
|
||||
}));
|
||||
});
|
||||
|
||||
it('when copying a system message it opens modal with information from message', function() {
|
||||
|
||||
var modalSpy = sandbox.spy($rootScope, 'openModal');
|
||||
var message = {
|
||||
uuid: 'system',
|
||||
text: 'Wesley attacked the ROUS in the Fire Swamp'
|
||||
};
|
||||
|
||||
scope.copyToDo(message);
|
||||
|
||||
modalSpy.should.have.been.calledOnce;
|
||||
|
||||
modalSpy.should.have.been.calledWith('copyChatToDo', sinon.match(function(callArgToMatch){
|
||||
var taskText = env.t('taskTextFromInbox', {
|
||||
from: 'system'
|
||||
});
|
||||
return callArgToMatch.controller == 'CopyMessageModalCtrl'
|
||||
&& callArgToMatch.scope.text == taskText
|
||||
}));
|
||||
});
|
||||
});
|
||||
});
|
||||
|
|
@ -97,8 +97,9 @@ window.habitrpg = angular.module('habitrpg',
|
|||
})
|
||||
|
||||
.state('options.social.inbox', {
|
||||
url: "/inbox",
|
||||
templateUrl: "partials/options.social.inbox.html",
|
||||
url: '/inbox',
|
||||
templateUrl: 'partials/options.social.inbox.html',
|
||||
controller: 'InboxCtrl',
|
||||
title: env.t('titleInbox')
|
||||
})
|
||||
|
||||
|
|
|
|||
31
website/client/js/controllers/inboxCtrl.js
Normal file
31
website/client/js/controllers/inboxCtrl.js
Normal file
|
|
@ -0,0 +1,31 @@
|
|||
'use strict';
|
||||
|
||||
habitrpg.controller('InboxCtrl', ['$scope', '$rootScope',
|
||||
function ($scope, $rootScope) {
|
||||
$scope.copyToDo = function (message) {
|
||||
var messageUser;
|
||||
|
||||
if (message.uuid == 'system') {
|
||||
messageUser = 'system';
|
||||
} else {
|
||||
messageUser = message.user;
|
||||
}
|
||||
|
||||
var newScope = $scope.$new();
|
||||
|
||||
newScope.notes = env.t('taskFromInbox', {
|
||||
from: messageUser,
|
||||
message: message.text
|
||||
});
|
||||
|
||||
newScope.text = env.t('taskTextFromInbox', {
|
||||
from: messageUser
|
||||
});
|
||||
|
||||
$rootScope.openModal('copyChatToDo',{
|
||||
controller: 'CopyMessageModalCtrl',
|
||||
scope: newScope
|
||||
});
|
||||
};
|
||||
}
|
||||
]);
|
||||
|
|
@ -90,6 +90,7 @@
|
|||
"js/controllers/guildsCtrl.js",
|
||||
"js/controllers/hallCtrl.js",
|
||||
"js/controllers/headerCtrl.js",
|
||||
"js/controllers/inboxCtrl.js",
|
||||
"js/controllers/inventoryCtrl.js",
|
||||
"js/controllers/inviteToGroupCtrl.js",
|
||||
"js/controllers/memberModalCtrl.js",
|
||||
|
|
|
|||
Loading…
Reference in a new issue