Commit 327b72d0

mo k <mo@mokhan.ca>
2012-09-18 21:40:38
add new tag to the hidden tag list.
1 parent 9acee58
Changed files (2)
app
assets
javascripts
spec
javascripts
app/assets/javascripts/presenters/new_tutorial_presenter.js.coffee
@@ -3,7 +3,10 @@ class window.NewTutorialPresenter
 
   present:() ->
     @view.add_tag_button.bind 'click', (event) =>
-      @view.tag_list.append(this.create_list_item_for(@view.tag_input.val()))
+      new_tag = @view.tag_input.val()
+      @view.tag_list.append(this.create_list_item_for(new_tag))
+      current = @view.hidden_tag_list.val()
+      @view.hidden_tag_list.val( new_tag )
 
   create_list_item_for:(tag) ->
     '<li><a href="#" class="label">'+tag+'</a></li>'
spec/javascripts/presenters/new_tutorial_presenter_spec.js
@@ -4,6 +4,7 @@ describe ("NewTutorialPresenter", function() {
       add_tag_button: $('<button id="add-tag-button">'),
       tag_list: $('<ul id="tag-list">'),
       tag_input: $('<input type="text" />'),
+      hidden_tag_list: $('<input type="hidden" />'),
     };
     sut = new NewTutorialPresenter(view);
   });
@@ -13,6 +14,9 @@ describe ("NewTutorialPresenter", function() {
     it ("should add the new tag to the list of tags", function() {
       expect(view.tag_list.html()).toEqual('<li><a href="#" class="label">ruby</a></li>');
     });
+    it ("should add the new tag to the hidden list of tags", function() {
+      expect(view.hidden_tag_list.val()).toEqual('ruby');
+    });
     beforeEach (function() {
       sut.present();
       view.tag_input.val('ruby');