diff --git a/app/assets/javascripts/darkswarm/directives/flash.js.coffee b/app/assets/javascripts/darkswarm/directives/flash.js.coffee index 454c3304bd..a302a2a891 100644 --- a/app/assets/javascripts/darkswarm/directives/flash.js.coffee +++ b/app/assets/javascripts/darkswarm/directives/flash.js.coffee @@ -1,10 +1,11 @@ -Darkswarm.directive "ofnFlash", (flash, $timeout)-> +Darkswarm.directive "ofnFlash", (flash, $timeout, RailsFlashLoader)-> + # Mappings between flash types (left) and Foundation classes typePairings = - info: "standard" + info: "info" error: "alert" success: "success" scope: {} - restrict: 'AE' + restrict: 'E' templateUrl: "flash.html" controller: ($scope)-> $scope.closeAlert = (index)-> @@ -21,3 +22,4 @@ Darkswarm.directive "ofnFlash", (flash, $timeout)-> $scope.flashes.shift() flash.subscribe(show) + RailsFlashLoader.initFlash() diff --git a/app/assets/javascripts/darkswarm/services/flash.js.coffee b/app/assets/javascripts/darkswarm/services/flash.js.coffee deleted file mode 100644 index 2be131da1d..0000000000 --- a/app/assets/javascripts/darkswarm/services/flash.js.coffee +++ /dev/null @@ -1,9 +0,0 @@ -Darkswarm.factory 'Flash', (flash)-> - new class Flash - loadFlash: (rails_flash)-> - for type, message of rails_flash - switch type - when "notice" - flash.info = message - else - flash[type] = message diff --git a/app/assets/javascripts/darkswarm/services/map.js.coffee b/app/assets/javascripts/darkswarm/services/map.js.coffee index a59631a741..eb1a195490 100644 --- a/app/assets/javascripts/darkswarm/services/map.js.coffee +++ b/app/assets/javascripts/darkswarm/services/map.js.coffee @@ -6,11 +6,7 @@ Darkswarm.factory "OfnMap", (enterprisesForMap, MapModal)-> # Adding methods to each enterprise extend: (enterprise)-> new class MapMarker - icon: "/test.opng" constructor: -> @[k] = v for k, v of enterprise - reveal: => - - console.log @ MapModal.open @ diff --git a/app/assets/javascripts/darkswarm/services/order.js.coffee b/app/assets/javascripts/darkswarm/services/order.js.coffee index 73a27012e5..a90cec9e34 100644 --- a/app/assets/javascripts/darkswarm/services/order.js.coffee +++ b/app/assets/javascripts/darkswarm/services/order.js.coffee @@ -1,4 +1,4 @@ -Darkswarm.factory 'Order', ($resource, order, $http, flash, Navigation, storage, CurrentHub)-> +Darkswarm.factory 'Order', ($resource, order, $http, Navigation, storage, CurrentHub, RailsFlashLoader)-> new class Order errors: {} secrets: {} @@ -24,8 +24,8 @@ Darkswarm.factory 'Order', ($resource, order, $http, flash, Navigation, storage, Navigation.go data.path .error (response, status)=> @errors = response.errors - flash.error = response.flash?.error - flash.success = response.flash?.notice + RailsFlashLoader.loadFlash(response.flash) + # Rails wants our Spree::Address data to be provided with _attributes preprocess: -> diff --git a/app/assets/javascripts/darkswarm/services/rails_flash_loader.js.coffee b/app/assets/javascripts/darkswarm/services/rails_flash_loader.js.coffee new file mode 100644 index 0000000000..9398b5f5cc --- /dev/null +++ b/app/assets/javascripts/darkswarm/services/rails_flash_loader.js.coffee @@ -0,0 +1,7 @@ +Darkswarm.factory 'RailsFlashLoader', (flash, railsFlash)-> + new class RailsFlashLoader + initFlash: -> + @loadFlash railsFlash + loadFlash: (rails_flash)-> + for type, message of rails_flash + flash[type] = message diff --git a/app/assets/javascripts/templates/map_modal.html.haml b/app/assets/javascripts/templates/map_modal.html.haml index 4e2067f7d0..54c834253a 100644 --- a/app/assets/javascripts/templates/map_modal.html.haml +++ b/app/assets/javascripts/templates/map_modal.html.haml @@ -2,7 +2,8 @@ .small-12.columns.producer-hero %h3.producer-name %i.ofn-i_036-producers - {{ producer.name }} + {{ enterprise.name }} + {{ enterprise.id }} %img.producer-hero-img{"ng-src" => "{{enterprise.promo_image}}"} .row diff --git a/app/controllers/application_controller.rb b/app/controllers/application_controller.rb index a19f92c918..07e1029991 100644 --- a/app/controllers/application_controller.rb +++ b/app/controllers/application_controller.rb @@ -37,7 +37,7 @@ class ApplicationController < ActionController::Base session[:expired_order_cycle_id] = current_order_cycle.id current_order.empty! current_order.set_order_cycle! nil - flash[:notice] = "The order cycle you've selected has just closed. Please try again!" + flash[:info] = "The order cycle you've selected has just closed. Please try again!" redirect_to root_url end end diff --git a/app/controllers/checkout_controller.rb b/app/controllers/checkout_controller.rb index b0cdeebba2..998f0ceeea 100644 --- a/app/controllers/checkout_controller.rb +++ b/app/controllers/checkout_controller.rb @@ -35,7 +35,7 @@ class CheckoutController < Spree::CheckoutController end end if @order.state == "complete" || @order.completed? - flash.notice = t(:order_processed_successfully) + flash[:success] = t(:order_processed_successfully) respond_to do |format| format.html do respond_with(@order, :location => order_path(@order)) diff --git a/app/controllers/user_passwords_controller.rb b/app/controllers/user_passwords_controller.rb index c46d294457..ed3be07f35 100644 --- a/app/controllers/user_passwords_controller.rb +++ b/app/controllers/user_passwords_controller.rb @@ -5,7 +5,7 @@ class UserPasswordsController < Spree::UserPasswordsController self.resource = resource_class.send_reset_password_instructions(params[resource_name]) if resource.errors.empty? - set_flash_message(:notice, :send_instructions) if is_navigational_format? + set_flash_message(:success, :send_instructions) if is_navigational_format? respond_with resource, :location => spree.login_path else respond_to do |format| diff --git a/app/controllers/user_registrations_controller.rb b/app/controllers/user_registrations_controller.rb index 3d106bbc96..a6a0074553 100644 --- a/app/controllers/user_registrations_controller.rb +++ b/app/controllers/user_registrations_controller.rb @@ -4,7 +4,7 @@ class UserRegistrationsController < Spree::UserRegistrationsController def create @user = build_resource(params[:spree_user]) if resource.save - set_flash_message(:notice, :signed_up) + set_flash_message(:success, :signed_up) sign_in(:spree_user, @user) session[:spree_user_signup] = true associate_user diff --git a/app/views/json/_flash.rabl b/app/views/json/_flash.rabl new file mode 100644 index 0000000000..dce07f849a --- /dev/null +++ b/app/views/json/_flash.rabl @@ -0,0 +1,2 @@ +object OpenStruct.new(flash) +attributes :info, :success, :error diff --git a/app/views/layouts/darkswarm.html.haml b/app/views/layouts/darkswarm.html.haml index d34e63fa53..1b1d97f85d 100644 --- a/app/views/layouts/darkswarm.html.haml +++ b/app/views/layouts/darkswarm.html.haml @@ -21,12 +21,12 @@ = inject_json "currentHub", "current_hub" = inject_json "currentOrder", "current_order" = inject_json "user", "current_user" + = inject_json "railsFlash", "flash" .off-canvas-wrap{offcanvas: true} .inner-wrap = render partial: "shared/menu/menu" - = display_flash_messages %ofn-flash %section{ role: "main" } diff --git a/spec/controllers/base_controller_spec.rb b/spec/controllers/base_controller_spec.rb index 140259555a..8269c9374d 100644 --- a/spec/controllers/base_controller_spec.rb +++ b/spec/controllers/base_controller_spec.rb @@ -16,6 +16,6 @@ describe BaseController do oc.stub(:closed?).and_return true get :index response.should redirect_to root_url - flash[:notice].should == "The order cycle you've selected has just closed. Please try again!" + flash[:info].should == "The order cycle you've selected has just closed. Please try again!" end end diff --git a/spec/features/consumer/shopping/checkout_spec.rb b/spec/features/consumer/shopping/checkout_spec.rb index fddda4e199..f0c2590b1c 100644 --- a/spec/features/consumer/shopping/checkout_spec.rb +++ b/spec/features/consumer/shopping/checkout_spec.rb @@ -146,6 +146,17 @@ feature "As a consumer I want to check out my cart", js: true do place_order page.should have_content "Your order has been processed successfully" end + + it "shows the payment processing failed message when submitted with an invalid credit card" do + toggle_payment + fill_in 'Card Number', with: "9999999988887777" + select 'February', from: 'secrets.card_month' + select (Date.today.year+1).to_s, from: 'secrets.card_year' + fill_in 'Security Code', with: '123' + + place_order + page.should have_content "Payment could not be processed, please check the details you entered" + end end end end