diff --git a/services/spelling/app/coffee/SpellingAPIManager.coffee b/services/spelling/app/coffee/SpellingAPIManager.coffee index b8a7f10072..8830155671 100644 --- a/services/spelling/app/coffee/SpellingAPIManager.coffee +++ b/services/spelling/app/coffee/SpellingAPIManager.coffee @@ -4,7 +4,7 @@ async = require 'async' module.exports = SpellingAPIManager = - wordWhitelist: [ + whitelist: [ 'ShareLaTeX', 'sharelatex', 'LaTeX', @@ -23,12 +23,7 @@ module.exports = SpellingAPIManager = ASpell.checkWords lang, words, (error, misspellings) -> callback error, misspellings: misspellings - wordsToCheck = (request.words || []).map (word) -> - # blank out whitelisted words - if SpellingAPIManager.wordWhitelist.indexOf(word) == -1 - word - else - '...' + wordsToCheck = request.words || [] if token? LearnedWordsManager.getLearnedWords token, (error, learnedWords) -> @@ -38,7 +33,7 @@ module.exports = SpellingAPIManager = return callback error if error? result.misspellings = result.misspellings.filter (m) -> word = words[m.index] - learnedWords.indexOf(word) == -1 + learnedWords.indexOf(word) == -1 and SpellingAPIManager.whitelist.indexOf(word) == -1 callback error, result else check(wordsToCheck, callback) diff --git a/services/spelling/test/unit/coffee/SpellingAPIManagerTests.coffee b/services/spelling/test/unit/coffee/SpellingAPIManagerTests.coffee index 1394a68c9d..83e117f252 100644 --- a/services/spelling/test/unit/coffee/SpellingAPIManagerTests.coffee +++ b/services/spelling/test/unit/coffee/SpellingAPIManagerTests.coffee @@ -84,12 +84,12 @@ describe "SpellingAPIManager", -> describe 'with words from the whitelist', -> beforeEach (done) -> - @whitelistWord = @SpellingAPIManager.wordWhitelist[0] - @words = ["One", @whitelistWord, "Two"] + @whitelistWord = @SpellingAPIManager.whitelist[0] + @words = ["One", "Two", @whitelistWord] @SpellingAPIManager.runRequest @token, words: @words, (error, @result) => done() it 'should ignore the white-listed word', -> - expect(@ASpell.checkWords.lastCall.args[1]).to.deep.equal ["One", "...", "Two"] + expect(@result.misspellings.length).to.equal @misspellings.length-1 describe "learnWord", -> describe "without a token", ->