|
|
@@ -5,14 +5,14 @@ sinon = require('sinon')
|
|
|
modulePath = require('path').join __dirname, '../../../../app/js/Features/Tags/TagsController.js'
|
|
|
|
|
|
|
|
|
-describe 'Tags controller', ->
|
|
|
+describe 'TagsController', ->
|
|
|
user_id = "123nd3ijdks"
|
|
|
project_id = "123njdskj9jlk"
|
|
|
tag = "some_class101"
|
|
|
|
|
|
beforeEach ->
|
|
|
@handler =
|
|
|
- addTag: sinon.stub().callsArgWith(3)
|
|
|
+ addProjectToTag: sinon.stub().callsArgWith(3)
|
|
|
removeProjectFromTag: sinon.stub().callsArgWith(3)
|
|
|
deleteTag: sinon.stub().callsArg(2)
|
|
|
renameTag: sinon.stub().callsArg(3)
|
|
|
@@ -31,13 +31,6 @@ describe 'Tags controller', ->
|
|
|
@res = {}
|
|
|
@res.status = sinon.stub().returns @res
|
|
|
@res.end = sinon.stub()
|
|
|
-
|
|
|
- describe "processTagsUpdate", ->
|
|
|
- it 'Should post the request to the tags api with the user id in the url', (done)->
|
|
|
- @req.body = {tag:tag}
|
|
|
- @controller.processTagsUpdate @req, send:=>
|
|
|
- @handler.addTag.calledWith(user_id, project_id, tag).should.equal true
|
|
|
- done()
|
|
|
|
|
|
describe "getAllTags", ->
|
|
|
it 'should ask the handler for all tags', (done)->
|
|
|
@@ -93,6 +86,22 @@ describe 'Tags controller', ->
|
|
|
@res.status.calledWith(400).should.equal true
|
|
|
@res.end.called.should.equal true
|
|
|
|
|
|
+ describe "addProjectToTag", ->
|
|
|
+ beforeEach ->
|
|
|
+ @req.params.tag_id = @tag_id = "tag-id-123"
|
|
|
+ @req.params.project_id = @project_id = "project-id-123"
|
|
|
+ @req.session.user._id = @user_id = "user-id-123"
|
|
|
+ @controller.addProjectToTag @req, @res
|
|
|
+
|
|
|
+ it "should add the tag to the project in the backend", ->
|
|
|
+ @handler.addProjectToTag
|
|
|
+ .calledWith(@user_id, @tag_id, @project_id)
|
|
|
+ .should.equal true
|
|
|
+
|
|
|
+ it "should return 204 status code", ->
|
|
|
+ @res.status.calledWith(204).should.equal true
|
|
|
+ @res.end.called.should.equal true
|
|
|
+
|
|
|
describe "removeProjectFromTag", ->
|
|
|
beforeEach ->
|
|
|
@req.params.tag_id = @tag_id = "tag-id-123"
|