Permalink
Browse files

Merge pull request #132 from dgreisen/auth

expose action.responded to authorize() function
  • Loading branch information...
2 parents 7b835a1 + a97be9d commit 7334263a0cf49ef55a46d06e4c7cfc640f0e71d7 @josephg committed Oct 21, 2012
Showing with 23 additions and 5 deletions.
  1. +5 −5 src/server/useragent.coffee
  2. +18 −0 test/client.coffee
@@ -51,14 +51,14 @@ module.exports = (model, options) ->
when 'delete' then 'delete'
else throw new Error "Invalid action name #{name}"
- responded = false
+ action.responded = false
action.reject = ->
- throw new Error 'Multiple accept/reject calls made' if responded
- responded = true
+ throw new Error 'Multiple accept/reject calls made' if @responded
+ @responded = true
userCallback 'forbidden', null
action.accept = ->
- throw new Error 'Multiple accept/reject calls made' if responded
- responded = true
+ throw new Error 'Multiple accept/reject calls made' if @responded
+ @responded = true
acceptCallback()
auth this, action
View
@@ -412,6 +412,24 @@ genTests = (client) -> testCase
@model.applyOp @name, {op:[{i:'dD', p:3}], v:1, meta:{}}, =>
@model.getSnapshot @name, e
+ 'If operation is rejected, action.responded == true': (test) ->
+ @auth = (client, action) ->
+ test.strictEqual action.responded, false
+ action.reject()
+ test.strictEqual action.responded, true
+ test.done()
+
+ client.open @name, 'text', "http://localhost:#{@port}/sjs", (error, doc) =>
+
+ 'If operation is accepted, action.responded == true': (test) ->
+ @auth = (client, action) ->
+ test.strictEqual action.responded, false
+ action.accept()
+ test.strictEqual action.responded, true
+ test.done()
+
+ client.open @name, 'text', "http://localhost:#{@port}/sjs", (error, doc) =>
+
'Text API is advertised': (test) ->
@c.open @name, 'text', (error, doc) ->
test.strictEqual doc.provides?.text, true

0 comments on commit 7334263

Please sign in to comment.