Merge pull request #2538 from webzwo0i/check-author-attribution

Check author attribution and fix clearAuthorship test
This commit is contained in:
John McLear 2015-03-31 23:14:22 +01:00
commit e47992f5b7
2 changed files with 12 additions and 2 deletions

View File

@ -656,12 +656,17 @@ function handleUserChanges(data, cb)
, op , op
while(iterator.hasNext()) { while(iterator.hasNext()) {
op = iterator.next() op = iterator.next()
if(op.opcode != '+') continue;
//+ can add text with attribs
//= can change or add attribs
//- can have attribs, but they are discarded and don't show up in the attribs - but do show up in the pool
op.attribs.split('*').forEach(function(attr) { op.attribs.split('*').forEach(function(attr) {
if(!attr) return if(!attr) return
attr = wireApool.getAttrib(attr) attr = wireApool.getAttrib(attr)
if(!attr) return if(!attr) return
if('author' == attr[0] && attr[1] != thisSession.author) throw new Error("Trying to submit changes as another author in changeset "+changeset); //the empty author is used in the clearAuthorship functionality so this should be the only exception
if('author' == attr[0] && (attr[1] != thisSession.author && attr[1] != '')) throw new Error("Trying to submit changes as another author in changeset "+changeset);
}) })
} }

View File

@ -47,6 +47,11 @@ describe("clear authorship colors button", function(){
var hasAuthorClass = inner$("div").first().attr("class").indexOf("author") !== -1; var hasAuthorClass = inner$("div").first().attr("class").indexOf("author") !== -1;
expect(hasAuthorClass).to.be(false); expect(hasAuthorClass).to.be(false);
setTimeout(function(){
var disconnectVisible = chrome$("div.disconnected").attr("class").indexOf("visible") === -1
expect(disconnectVisible).to.be(true);
},1000);
done(); done();
}); });