diff --git a/features/step_definitions/trumpeter_steps.rb b/features/step_definitions/trumpeter_steps.rb index 5f7434193..378d30aeb 100644 --- a/features/step_definitions/trumpeter_steps.rb +++ b/features/step_definitions/trumpeter_steps.rb @@ -43,7 +43,6 @@ end When /^I upload a fixture picture with filename "([^"]*)"$/ do |file_name| within ".new_photo" do attach_file "photo[user_file]", Rails.root.join("spec", "fixtures", file_name) - click_button :submit end @image_source = find(".photos img")["src"] diff --git a/public/javascripts/app/forms/picture_form.js b/public/javascripts/app/forms/picture_form.js index 9e1e66c77..cd16fbf84 100644 --- a/public/javascripts/app/forms/picture_form.js +++ b/public/javascripts/app/forms/picture_form.js @@ -2,7 +2,8 @@ app.forms.Picture = app.forms.Base.extend({ templateName : "picture-form", events : { - 'ajax:complete .new_photo' : "photoUploaded" + 'ajax:complete .new_photo' : "photoUploaded", + "change input[name='photo[user_file]']" : "submitForm" }, initialize : function() { @@ -10,6 +11,17 @@ app.forms.Picture = app.forms.Base.extend({ this.photos.bind("add", this.render, this) }, + postRenderTemplate : function(){ + this.$("input[name=authenticity_token]").val($("meta[name=csrf-token]").attr("content")) + this.$("input[name=photo_ids]").val(this.photos.pluck("id")) + this.renderPhotos(); + }, + + submitForm : function (){ + console.log("meow") + this.$("form").submit(); + }, + photoUploaded : function(evt, xhr) { resp = JSON.parse(xhr.responseText) if(resp.success) { @@ -19,12 +31,6 @@ app.forms.Picture = app.forms.Base.extend({ } }, - postRenderTemplate : function(){ - this.$("input[name=authenticity_token]").val($("meta[name=csrf-token]").attr("content")) - this.$("input[name=photo_ids]").val(this.photos.pluck("id")) - this.renderPhotos(); - }, - renderPhotos : function(){ var photoContainer = this.$(".photos") this.photos.each(function(photo){ diff --git a/public/javascripts/app/templates/picture-form.handlebars b/public/javascripts/app/templates/picture-form.handlebars index d48d10a7b..665aed54f 100644 --- a/public/javascripts/app/templates/picture-form.handlebars +++ b/public/javascripts/app/templates/picture-form.handlebars @@ -3,7 +3,6 @@