mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-01-24 20:36:49 +00:00
Merge branch 'laura_and_will'
This commit is contained in:
BIN
app/assets/images/browser-logos/chrome.png
Normal file
BIN
app/assets/images/browser-logos/chrome.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 9.2 KiB |
BIN
app/assets/images/browser-logos/firefox.png
Normal file
BIN
app/assets/images/browser-logos/firefox.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 16 KiB |
BIN
app/assets/images/browser-logos/internet-explorer.png
Normal file
BIN
app/assets/images/browser-logos/internet-explorer.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 11 KiB |
@@ -1,11 +1,11 @@
|
||||
Darkswarm.controller "ProductsCtrl", ($scope, $rootScope, Product, OrderCycle) ->
|
||||
$scope.data = Product.data
|
||||
$scope.Product = Product
|
||||
$scope.limit = 3
|
||||
$scope.ordering = {order: "name"}
|
||||
$scope.order_cycle = OrderCycle.order_cycle
|
||||
|
||||
$scope.incrementLimit = ->
|
||||
if $scope.limit < $scope.data.products.length
|
||||
if $scope.limit < $scope.Product.products.length
|
||||
$scope.limit = $scope.limit + 1
|
||||
|
||||
$scope.searchKeypress = (e)->
|
||||
|
||||
@@ -0,0 +1,12 @@
|
||||
Darkswarm.directive "activeTableHubLink", (CurrentHub, CurrentOrder) ->
|
||||
restrict: "A"
|
||||
scope:
|
||||
hub: '=activeTableHubLink'
|
||||
template: "{{action}} <strong>{{hub.name}}</strong>"
|
||||
link: (scope, elm, attr)->
|
||||
# Swap out the text of the hub link depending on whether it'll change current hub
|
||||
# To be used with ofnEmptiesCart
|
||||
if CurrentHub.id and CurrentHub.id isnt scope.hub.id
|
||||
scope.action = attr.change
|
||||
else
|
||||
scope.action = attr.shop
|
||||
@@ -1,17 +1,12 @@
|
||||
Darkswarm.directive "ofnEmptiesCart", (CurrentHub, CurrentOrder, Navigation, storage) ->
|
||||
restrict: "A"
|
||||
scope:
|
||||
hub: '=ofnEmptiesCart'
|
||||
template: "{{action}} <strong>{{hub.name}}</strong>"
|
||||
link: (scope, elm, attr)->
|
||||
hub = scope.$eval(attr.ofnEmptiesCart)
|
||||
# A hub is selected, we're changing to a different hub, and the cart isn't empty
|
||||
if CurrentHub.id and CurrentHub.id isnt scope.hub.id
|
||||
scope.action = attr.change
|
||||
if CurrentHub.id and CurrentHub.id isnt hub.id
|
||||
unless CurrentOrder.empty()
|
||||
elm.bind 'click', (ev)->
|
||||
ev.preventDefault()
|
||||
if confirm "Are you sure? This will change your selected Hub and remove any items in you shopping cart."
|
||||
storage.clearAll() # One day this will have to be moar GRANULAR
|
||||
Navigation.go scope.hub.path
|
||||
else
|
||||
scope.action = attr.shop
|
||||
|
||||
@@ -0,0 +1,18 @@
|
||||
Darkswarm.factory 'Enterprises', (enterprises)->
|
||||
new class Enterprises
|
||||
enterprises_by_id: {} # id/object pairs for lookup
|
||||
constructor: ->
|
||||
@enterprises = enterprises
|
||||
for enterprise in enterprises
|
||||
@enterprises_by_id[enterprise.id] = enterprise
|
||||
@dereference()
|
||||
|
||||
dereference: ->
|
||||
for enterprise in @enterprises
|
||||
if enterprise.hubs
|
||||
for hub, i in enterprise.hubs
|
||||
enterprise.hubs[i] = @enterprises_by_id[hub.id]
|
||||
|
||||
if enterprise.producers
|
||||
for producer, i in enterprise.producers
|
||||
enterprise.producers[i] = @enterprises_by_id[producer.id]
|
||||
@@ -1,4 +1,8 @@
|
||||
Darkswarm.factory 'Hubs', ($location, hubs, $filter, CurrentHub) ->
|
||||
Darkswarm.factory 'Hubs', ($filter, Enterprises) ->
|
||||
new class Hubs
|
||||
constructor: ->
|
||||
@hubs = $filter('orderBy')(hubs, ['-active', '+orders_close_at'])
|
||||
@hubs = @order Enterprises.enterprises.filter (hub)->
|
||||
hub.is_distributor
|
||||
|
||||
order: (hubs)->
|
||||
$filter('orderBy')(hubs, ['-active', '+orders_close_at'])
|
||||
|
||||
@@ -1,12 +1,17 @@
|
||||
Darkswarm.factory "OfnMap", (enterprisesForMap, MapModal)->
|
||||
Darkswarm.factory "OfnMap", (Enterprises, MapModal)->
|
||||
new class OfnMap
|
||||
constructor: ->
|
||||
@enterprises = (@extend(enterprise) for enterprise in enterprisesForMap)
|
||||
@enterprises = (@extend(enterprise) for enterprise in Enterprises.enterprises)
|
||||
|
||||
|
||||
# Adding methods to each enterprise
|
||||
extend: (enterprise)->
|
||||
new class MapMarker
|
||||
constructor: ->
|
||||
@[k] = v for k, v of enterprise
|
||||
# We're whitelisting attributes because GMaps tries to crawl
|
||||
# our data, and our data is recursive, so it breaks
|
||||
latitude: enterprise.latitude
|
||||
longitude: enterprise.longitude
|
||||
icon: enterprise.icon
|
||||
id: enterprise.id
|
||||
reveal: =>
|
||||
MapModal.open @
|
||||
MapModal.open enterprise
|
||||
|
||||
@@ -2,5 +2,10 @@ Darkswarm.factory "MapModal", ($modal, $rootScope)->
|
||||
new class MapModal
|
||||
open: (enterprise)->
|
||||
scope = $rootScope.$new(true) # Spawn an isolate to contain the enterprise
|
||||
scope.enterprise = enterprise
|
||||
$modal.open(templateUrl: "map_modal.html", scope: scope)
|
||||
|
||||
if enterprise.is_distributor
|
||||
scope.hub = enterprise
|
||||
$modal.open(templateUrl: "map_modal_hub.html", scope: scope)
|
||||
else
|
||||
scope.producer = enterprise
|
||||
$modal.open(templateUrl: "map_modal_producer.html", scope: scope)
|
||||
|
||||
@@ -1,4 +1,6 @@
|
||||
Darkswarm.factory 'Producers', (producers) ->
|
||||
Darkswarm.factory 'Producers', (Enterprises) ->
|
||||
new class Producers
|
||||
constructor: ->
|
||||
@producers = producers
|
||||
@producers = Enterprises.enterprises.filter (enterprise)->
|
||||
enterprise.is_primary_producer
|
||||
|
||||
|
||||
@@ -5,11 +5,11 @@ Darkswarm.factory 'Product', ($resource) ->
|
||||
|
||||
# TODO: don't need to scope this into object
|
||||
# Already on object as far as controller scope is concerned
|
||||
data:
|
||||
products: null
|
||||
loading: true
|
||||
products: null
|
||||
loading: true
|
||||
|
||||
update: =>
|
||||
@data.products = $resource("/shop/products").query =>
|
||||
@data.loading = false
|
||||
@data
|
||||
@loading = true
|
||||
@products = $resource("/shop/products").query =>
|
||||
@loading = false
|
||||
@
|
||||
|
||||
@@ -4,4 +4,4 @@
|
||||
%ng-include{src: "'signup.html'"}
|
||||
%ng-include{src: "'forgot.html'"}
|
||||
%a.close-reveal-modal{"ng-click" => "$close()"}
|
||||
%i.ofn-i_009-close
|
||||
%i.ofn-i_009-close
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
.row
|
||||
.small-12.columns.producer-hero
|
||||
%h3.producer-name
|
||||
%i.ofn-i_036-producers
|
||||
%i.ofn-i_040-hub
|
||||
{{ enterprise.name }}
|
||||
{{ enterprise.id }}
|
||||
%img.producer-hero-img{"ng-src" => "{{enterprise.promo_image}}"}
|
||||
@@ -45,5 +45,5 @@
|
||||
%i.ofn-i_043-instagram
|
||||
{{ enterprise.instagram }}
|
||||
|
||||
%a.close-reveal-modal{"ng-click" => "$close()"}
|
||||
%a.close-reveal-modal.outside{"ng-click" => "$close()"}
|
||||
%i.ofn-i_009-close
|
||||
@@ -0,0 +1,34 @@
|
||||
.highlight
|
||||
.highlight-row
|
||||
%p.right
|
||||
{{ hub.address.city }} , {{hub.address.state}}
|
||||
%h3
|
||||
%i.ofn-i_036-producers
|
||||
{{ producer.name }}
|
||||
|
||||
%img.producer-hero-img{"ng-src" => "{{producer.promo_image}}"}
|
||||
|
||||
.row.pad-top{bindonce: true}
|
||||
.small-12.large-6.columns
|
||||
%img.producer-logo{"bo-src" => "producer.logo", "bo-if" => "producer.logo"}
|
||||
%h5.modal-header About
|
||||
%p{"ng-bind-html" => "producer.long_description"}
|
||||
|
||||
.small-12.large-6.columns
|
||||
%ng-include{src: "'partials/contact.html'"}
|
||||
%ng-include{src: "'partials/follow.html'"}
|
||||
|
||||
.row{bindonce: true}
|
||||
.modal-hubs
|
||||
%h5 Shop for {{producer.name}} products at:
|
||||
%a.button.primary.hub{"ng-repeat" => "hub in producer.hubs",
|
||||
"bo-href" => "hub.path",
|
||||
"bo-class" => "{active: hub.active, inactive: !hub.active}",
|
||||
"ofn-empties-cart" => "hub"}
|
||||
%i.ofn-i_033-open-sign{"bo-if" => "hub.active"}
|
||||
%i.ofn-i_032-closed-sign{"bo-if" => "!hub.active"}
|
||||
{{hub.name}}
|
||||
( {{ hub.address.city }} , {{hub.address.state}} )
|
||||
|
||||
%a.close-reveal-modal.outside{"ng-click" => "$close()"}
|
||||
%i.ofn-i_009-close
|
||||
12
app/assets/javascripts/templates/partials/contact.html.haml
Normal file
12
app/assets/javascripts/templates/partials/contact.html.haml
Normal file
@@ -0,0 +1,12 @@
|
||||
%div.modal-centered{"bo-if" => "producer.email || producer.website || producer.address.phone"}
|
||||
%h5.modal-header Contact
|
||||
%p{"ng-if" => "producer.address.phone"}
|
||||
{{ producer.address.phone }}
|
||||
|
||||
%p{"bo-if" => "producer.email"}
|
||||
%a{"ng-href" => "mailto:{{producer.email | stripUrl}}", target: "_blank" }
|
||||
{{ producer.email | stripUrl }}
|
||||
|
||||
%p{"ng-if" => "producer.website"}
|
||||
%a{"ng-href" => "http://{{producer.website | stripUrl}}", target: "_blank" }
|
||||
{{ producer.website | stripUrl }}
|
||||
19
app/assets/javascripts/templates/partials/follow.html.haml
Normal file
19
app/assets/javascripts/templates/partials/follow.html.haml
Normal file
@@ -0,0 +1,19 @@
|
||||
%div.modal-centered{"bo-if" => "producer.twitter || producer.facebook || producer.linkedin || producer.instagram"}
|
||||
%h5.modal-header Follow
|
||||
%ul.small-block-grid-1{bindonce: true}
|
||||
%li{"ng-if" => "producer.twitter"}
|
||||
%a{"ng-href" => "http://twitter.com/{{producer.twitter}}", target: "_blank"}
|
||||
%i.ofn-i_041-twitter
|
||||
|
||||
%li{"ng-if" => "producer.facebook"}
|
||||
%a{"ng-href" => "http://{{producer.facebook | stripUrl}}", target: "_blank"}
|
||||
%i.ofn-i_044-facebook
|
||||
|
||||
%li{"ng-if" => "producer.linkedin"}
|
||||
%a{"ng-href" => "http://{{producer.linkedin | stripUrl}}", target: "_blank"}
|
||||
%i.ofn-i_042-linkedin
|
||||
|
||||
%li{"ng-if" => "producer.instagram"}
|
||||
%a{"ng-href" => "http://instagram.com/{{producer.instagram}}", target: "_blank"}
|
||||
%i.ofn-i_043-instagram
|
||||
|
||||
@@ -15,6 +15,9 @@
|
||||
margin-bottom: 1em
|
||||
h2
|
||||
font-size: 1.6875rem
|
||||
max-width: 610px
|
||||
margin: 0 auto
|
||||
|
||||
a
|
||||
color: $clr-brick-bright
|
||||
&:hover, &:active, &:focus
|
||||
|
||||
@@ -36,22 +36,6 @@
|
||||
|
||||
//Open row
|
||||
&.open
|
||||
.fat-taxons
|
||||
@include csstrans
|
||||
margin-right: 0.5rem
|
||||
text-transform: uppercase
|
||||
font-size: 1rem
|
||||
line-height: 1
|
||||
color: $dark-grey
|
||||
// border: 1px solid $disabled-bright
|
||||
display: inline-block
|
||||
padding: 0.2rem 0.5rem 0.35rem 0.35rem
|
||||
|
||||
object.taxon
|
||||
height: 20px
|
||||
// &:hover, &.hover, &:active
|
||||
// background: rgba(255,255,255,0.5)
|
||||
|
||||
.active_table_row:first-child
|
||||
border-top: 1px solid $clr-brick
|
||||
border-left: 1px solid $clr-brick
|
||||
|
||||
32
app/assets/stylesheets/darkswarm/ie_warning.sass
Normal file
32
app/assets/stylesheets/darkswarm/ie_warning.sass
Normal file
@@ -0,0 +1,32 @@
|
||||
#ie-warning
|
||||
margin-bottom: 0
|
||||
padding-bottom: 2rem
|
||||
.ie-msg
|
||||
background: rgba(255,255,255,0.15)
|
||||
padding: 0.5rem
|
||||
margin-bottom: 1rem
|
||||
margin-top: 1rem
|
||||
.browserbtn
|
||||
text-align: center
|
||||
margin-bottom: 1rem
|
||||
a
|
||||
color: white
|
||||
font-size: 1rem
|
||||
filter: alpha(opacity=70)
|
||||
opacity: 0.7
|
||||
&:hover, &:active, &:focus
|
||||
filter: alpha(opacity=100)
|
||||
opacity: 1
|
||||
|
||||
a.browserlogo
|
||||
display: block
|
||||
width: 100%
|
||||
i
|
||||
font-size: 5rem
|
||||
color: white
|
||||
text-align: center
|
||||
display: block
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -15,23 +15,12 @@
|
||||
padding: 0
|
||||
|
||||
.producer-hero-img
|
||||
background-color: #999
|
||||
background-color: #333
|
||||
width: 100%
|
||||
min-height: 160px
|
||||
height: inherit
|
||||
max-height: 260px
|
||||
overflow: hidden
|
||||
margin-top: 2em
|
||||
margin-bottom: 1em
|
||||
|
||||
|
||||
h3.producer-name
|
||||
background-color: rgba(255,255,255,0.65)
|
||||
height: 2.5em
|
||||
width: 100%
|
||||
position: absolute
|
||||
bottom: 0
|
||||
padding: 0.5em
|
||||
|
||||
.producer-logo
|
||||
max-width: 220px
|
||||
|
||||
@@ -16,7 +16,9 @@
|
||||
right: 0
|
||||
@include user-select(none)
|
||||
h1
|
||||
-webkit-animation: blurFadeIn 0.8s ease-in-out 0s
|
||||
color: white
|
||||
font-size: 1.15rem
|
||||
position: fixed
|
||||
text-align: center
|
||||
left: 0
|
||||
@@ -24,7 +26,6 @@
|
||||
margin: 0 auto
|
||||
top: 55%
|
||||
width: 100%
|
||||
height: 400px
|
||||
overflow: visible
|
||||
|
||||
.loader
|
||||
@@ -55,6 +56,20 @@
|
||||
li:nth-child(3)
|
||||
-webkit-animation: loadbars 0.6s ease-in-out infinite -0.4s
|
||||
|
||||
@-webkit-keyframes blurFadeIn
|
||||
0%
|
||||
opacity: 0
|
||||
text-shadow: 0px 0px 10px #fff
|
||||
-webkit-transform: scale(1.3)
|
||||
50%
|
||||
opacity: 0.5
|
||||
text-shadow: 0px 0px 5px #fff
|
||||
-webkit-transform: scale(1.1)
|
||||
100%
|
||||
opacity: 1
|
||||
text-shadow: 0px 0px 0px #fff
|
||||
-webkit-transform: scale(1)
|
||||
|
||||
@-webkit-keyframes 'loadbars'
|
||||
0%
|
||||
height: 10px
|
||||
|
||||
@@ -32,6 +32,33 @@
|
||||
transition: all 100ms ease-in-out
|
||||
-webkit-transform-style: preserve-3d
|
||||
|
||||
@mixin animate-in
|
||||
-webkit-animation: cssAnimation 100ms 1 ease-in
|
||||
-moz-animation: cssAnimation 100ms 1 ease-in
|
||||
-o-animation: cssAnimation 100ms 1 ease-in
|
||||
|
||||
@-webkit-keyframes cssAnimation
|
||||
from
|
||||
-webkit-transform: rotate(180deg) scale(0.25) skew(0deg) translate(0px)
|
||||
to
|
||||
-webkit-transform: rotate(0deg) scale(1) skew(0deg) translate(0px)
|
||||
|
||||
|
||||
@-moz-keyframes cssAnimation
|
||||
from
|
||||
-moz-transform: rotate(180deg) scale(0.25) skew(0deg) translate(0px)
|
||||
to
|
||||
-moz-transform: rotate(0deg) scale(1) skew(0deg) translate(0px)
|
||||
|
||||
|
||||
@-o-keyframes cssAnimation
|
||||
from
|
||||
-o-transform: rotate(180deg) scale(0.25) skew(0deg) translate(0px)
|
||||
to
|
||||
-o-transform: rotate(0deg) scale(1) skew(0deg) translate(0px)
|
||||
|
||||
|
||||
|
||||
@mixin box-shadow($box-shadow)
|
||||
-moz-box-shadow: $box-shadow
|
||||
-webkit-box-shadow: $box-shadow
|
||||
|
||||
49
app/assets/stylesheets/darkswarm/modals.css.sass
Normal file
49
app/assets/stylesheets/darkswarm/modals.css.sass
Normal file
@@ -0,0 +1,49 @@
|
||||
@import branding
|
||||
@import mixins
|
||||
|
||||
dialog, .reveal-modal
|
||||
border: none
|
||||
outline: none
|
||||
|
||||
.reveal-modal-bg
|
||||
background-color: rgba(0,0,0,0.65)
|
||||
|
||||
.modal-centered
|
||||
text-align: center
|
||||
p
|
||||
margin-bottom: 0
|
||||
|
||||
.modal-header
|
||||
text-align: center
|
||||
text-transform: uppercase
|
||||
border-bottom: 1px solid black
|
||||
|
||||
dialog .close-reveal-modal.outside, .reveal-modal .close-reveal-modal.outside
|
||||
@include csstrans
|
||||
top: -2.2rem
|
||||
right: -2.2rem
|
||||
font-size: 2rem
|
||||
color: white
|
||||
text-shadow: none
|
||||
&:hover, &:active, &:focus
|
||||
color: $clr-brick-light-bright
|
||||
text-shadow: 0 1px 3px #333
|
||||
|
||||
.highlight
|
||||
position: relative
|
||||
|
||||
.highlight-row
|
||||
padding: 0.75rem 0.9375rem
|
||||
width: 100%
|
||||
overflow: hidden
|
||||
background-color: rgba(255,255,255,0.5)
|
||||
position: absolute
|
||||
bottom: 0
|
||||
h3, p
|
||||
margin-top: 0
|
||||
margin-bottom: 0
|
||||
padding-bottom: 0
|
||||
line-height: 1
|
||||
p
|
||||
line-height: 2
|
||||
|
||||
@@ -124,9 +124,6 @@
|
||||
.summary-header
|
||||
@include csstrans
|
||||
font-size: 1.15rem
|
||||
|
||||
object.taxon
|
||||
height: 18px
|
||||
|
||||
&, & *
|
||||
@include avenir
|
||||
|
||||
33
app/assets/stylesheets/darkswarm/taxons.css.sass
Normal file
33
app/assets/stylesheets/darkswarm/taxons.css.sass
Normal file
@@ -0,0 +1,33 @@
|
||||
@import branding
|
||||
@import mixins
|
||||
|
||||
.fat-taxons
|
||||
@include csstrans
|
||||
display: inline-block
|
||||
line-height: 1
|
||||
margin-right: 0.5rem
|
||||
margin-bottom: 0.2rem
|
||||
text-transform: uppercase
|
||||
font-size: 1rem
|
||||
// border: 1px solid $disabled-bright
|
||||
padding: 0.25rem 0.5rem 0.25rem 0.35rem
|
||||
render-svg
|
||||
svg
|
||||
width: 16px
|
||||
height: 16px
|
||||
path
|
||||
fill: $dark-grey
|
||||
&, &*
|
||||
display: inline-block
|
||||
color: $dark-grey
|
||||
// &:hover, &.hover, &:active
|
||||
// background: rgba(255,255,255,0.5)
|
||||
|
||||
.summary-header
|
||||
@include csstrans
|
||||
render-svg
|
||||
svg
|
||||
width: 18px
|
||||
height: 18px
|
||||
path
|
||||
fill: $clr-brick
|
||||
@@ -11,4 +11,8 @@ class BaseController < ApplicationController
|
||||
include Spree::ProductsHelper
|
||||
|
||||
before_filter :check_order_cycle_expiry
|
||||
|
||||
def load_active_distributors
|
||||
@active_distributors ||= Enterprise.distributors_with_active_order_cycles
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
class HomeController < BaseController
|
||||
layout 'darkswarm'
|
||||
before_filter :load_active_distributors
|
||||
|
||||
def index
|
||||
@active_distributors ||= Enterprise.distributors_with_active_order_cycles
|
||||
end
|
||||
|
||||
def about_us
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
class MapController < BaseController
|
||||
layout 'darkswarm'
|
||||
before_filter :load_active_distributors
|
||||
|
||||
def index
|
||||
@enterprises = Enterprise.visible
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
class ProducersController < BaseController
|
||||
layout 'darkswarm'
|
||||
before_filter :load_active_distributors
|
||||
|
||||
def index
|
||||
@producers = Enterprise.is_primary_producer.visible
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,7 +1,10 @@
|
||||
module SharedHelper
|
||||
def inject_enterprises
|
||||
inject_json "enterprises" , "enterprises"
|
||||
end
|
||||
|
||||
def inject_json(name, partial, opts = {})
|
||||
render "json/injection", {name: name, partial: partial}.merge(opts)
|
||||
render partial: "json/injection", locals: {name: name, partial: partial}.merge(opts)
|
||||
end
|
||||
|
||||
def distributor_link_class(distributor)
|
||||
|
||||
@@ -24,11 +24,25 @@
|
||||
%li{"ng-repeat" => "producer in hub.producers"}
|
||||
= render partial: "modals/producer"
|
||||
|
||||
.row.active_table_row.link{"ng-show" => "open()", "ng-if" => "hub.active"}
|
||||
.row.active_table_row.link{"ng-show" => "open()", "bo-if" => "hub.active"}
|
||||
.columns.small-11
|
||||
%a{"bo-href" => "hub.path", "ofn-empties-cart" => "hub",
|
||||
%a{"bo-href" => "hub.path", "ofn-empties-cart" => "hub",
|
||||
"active-table-hub-link" => "hub",
|
||||
change: "Change hub to", shop: "Shop at"}
|
||||
|
||||
.columns.small-1.text-right
|
||||
%a{"bo-href" => "hub.path"}
|
||||
%i.ofn-i_007-caret-right
|
||||
|
||||
.row.active_table_row.link{"ng-show" => "open()", "bo-if" => "!hub.active"}
|
||||
.columns.small-11
|
||||
%a{"bo-href" => "hub.path", "ofn-empties-cart" => "hub",
|
||||
"active-table-hub-link" => "hub",
|
||||
change: "Change hub to (disabled)", shop: "Shop at (disabled)"}
|
||||
|
||||
.columns.small-1.text-right
|
||||
|
||||
%a{"bo-href" => "hub.path"}
|
||||
%i.ofn-i_007-caret-right
|
||||
|
||||
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
#hubs.hubs{"ng-controller" => "HubsCtrl"}
|
||||
:javascript
|
||||
angular.module('Darkswarm').value('hubs', #{render "json/hubs"})
|
||||
= inject_enterprises
|
||||
|
||||
.row
|
||||
.small-12.columns.text-center
|
||||
|
||||
@@ -1,14 +1,7 @@
|
||||
# DON'T USE DIRECTLY - for inheritance
|
||||
attributes :name, :id, :description
|
||||
|
||||
child :address do
|
||||
extends "json/partials/address"
|
||||
end
|
||||
|
||||
node :path do |enterprise|
|
||||
shop_enterprise_path(enterprise)
|
||||
end
|
||||
|
||||
node :hash do |enterprise|
|
||||
enterprise.to_param
|
||||
end
|
||||
# TODO: This should be moved into the controller
|
||||
# RABL is tricky to pass variables into: so we do this as a workaround for now
|
||||
# I noticed some vague comments on Rabl github about this, but haven't looked into
|
||||
collection Enterprise.visible
|
||||
extends 'json/partials/enterprise'
|
||||
extends 'json/partials/producer'
|
||||
extends 'json/partials/hub'
|
||||
|
||||
@@ -1,26 +1,4 @@
|
||||
collection Enterprise.visible.is_distributor
|
||||
extends 'json/enterprises'
|
||||
collection Enterprise.is_distributor.visible
|
||||
extends 'json/partials/enterprise'
|
||||
extends 'json/partials/hub'
|
||||
|
||||
child distributed_taxons: :taxons do
|
||||
extends "json/taxon"
|
||||
end
|
||||
|
||||
child suppliers: :producers do
|
||||
extends "json/producer"
|
||||
end
|
||||
|
||||
node :pickup do |hub|
|
||||
not hub.shipping_methods.where(:require_ship_address => false).empty?
|
||||
end
|
||||
|
||||
node :delivery do |hub|
|
||||
not hub.shipping_methods.where(:require_ship_address => true).empty?
|
||||
end
|
||||
|
||||
node :active do |hub|
|
||||
@active_distributors.include?(hub)
|
||||
end
|
||||
|
||||
node :orders_close_at do |hub|
|
||||
OrderCycle.first_closing_for(hub).andand.orders_close_at
|
||||
end
|
||||
|
||||
@@ -1,2 +1,2 @@
|
||||
:javascript
|
||||
angular.module('Darkswarm').value("#{name.to_s}", #{render "json/#{partial.to_s}"})
|
||||
angular.module('Darkswarm').value("#{name.to_s}", #{render partial: "json/#{partial.to_s}"})
|
||||
|
||||
@@ -1,21 +1,3 @@
|
||||
collection @producers
|
||||
extends 'json/enterprises'
|
||||
|
||||
child supplied_taxons: :taxons do
|
||||
extends 'json/taxon'
|
||||
end
|
||||
|
||||
child distributors: :distributors do
|
||||
attributes :name, :id
|
||||
node :path do |distributor|
|
||||
shop_enterprise_path(distributor)
|
||||
end
|
||||
end
|
||||
|
||||
node :path do |producer|
|
||||
producer_path(producer)
|
||||
end
|
||||
|
||||
node :hash do |producer|
|
||||
producer.to_param
|
||||
end
|
||||
collection Enterprise.is_primary_producer.visible
|
||||
extends 'json/partials/enterprise'
|
||||
extends 'json/partials/producer'
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
attributes :city, :zipcode
|
||||
attributes :city, :zipcode, :phone
|
||||
node :state do |address|
|
||||
address.state.abbr
|
||||
end
|
||||
|
||||
@@ -1,10 +1,21 @@
|
||||
collection @enterprises
|
||||
extends 'json/enterprises'
|
||||
attributes :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, :facebook
|
||||
attributes :name, :id, :description, :latitude, :longitude, :long_description, :website, :instagram, :linkedin, :twitter, :facebook, :is_primary_producer, :is_distributor
|
||||
|
||||
node :email do |enterprise|
|
||||
enterprise.email.to_s.reverse
|
||||
end
|
||||
|
||||
child :address do
|
||||
extends "json/partials/address"
|
||||
end
|
||||
|
||||
node :hash do |enterprise|
|
||||
enterprise.to_param
|
||||
end
|
||||
|
||||
node :logo do |enterprise|
|
||||
enterprise.logo(:medium) if enterprise.logo.exists?
|
||||
end
|
||||
|
||||
node :promo_image do |enterprise|
|
||||
enterprise.promo_image(:large) if enterprise.promo_image.exists?
|
||||
end
|
||||
21
app/views/json/partials/_hub.rabl
Normal file
21
app/views/json/partials/_hub.rabl
Normal file
@@ -0,0 +1,21 @@
|
||||
child distributed_taxons: :taxons do
|
||||
extends "json/taxon"
|
||||
end
|
||||
child suppliers: :producers do
|
||||
attributes :id
|
||||
end
|
||||
node :path do |enterprise|
|
||||
shop_enterprise_path(enterprise)
|
||||
end
|
||||
node :pickup do |hub|
|
||||
hub.shipping_methods.where(:require_ship_address => false).present?
|
||||
end
|
||||
node :delivery do |hub|
|
||||
hub.shipping_methods.where(:require_ship_address => true).present?
|
||||
end
|
||||
node :active do |hub|
|
||||
@active_distributors.include?(hub)
|
||||
end
|
||||
node :orders_close_at do |hub|
|
||||
OrderCycle.first_closing_for(hub).andand.orders_close_at
|
||||
end
|
||||
9
app/views/json/partials/_producer.rabl
Normal file
9
app/views/json/partials/_producer.rabl
Normal file
@@ -0,0 +1,9 @@
|
||||
child supplied_taxons: :taxons do
|
||||
extends 'json/taxon'
|
||||
end
|
||||
child distributors: :hubs do
|
||||
attributes :id
|
||||
end
|
||||
node :path do |producer|
|
||||
producer_path(producer)
|
||||
end
|
||||
@@ -1,4 +1,3 @@
|
||||
!!!
|
||||
%html
|
||||
%head
|
||||
%meta{charset: 'utf-8'}/
|
||||
@@ -18,6 +17,34 @@
|
||||
= csrf_meta_tags
|
||||
|
||||
%body.off-canvas{"ng-app" => "Darkswarm"}
|
||||
/ [if lte IE 8]
|
||||
.alert-box.alert#ie-warning{"data-alert" => ""}
|
||||
.row.ie-msg
|
||||
.small-4.large-2.columns
|
||||
%i.ofn-i_012-warning
|
||||
.small-8.large-10.columns
|
||||
%h3 Your browser is out of date :-(
|
||||
%p For the best Open Food Network experience, we strongly recommend upgrading your browser:
|
||||
.row
|
||||
.small-4.columns.browserbtn
|
||||
%a.browserlogo{href: "https://www.google.com/intl/en_au/chrome/browser/", target: "_blank"}
|
||||
%img{src: "assets/browser-logos/chrome.png"}
|
||||
%a{href: "https://www.google.com/intl/en_au/chrome/browser/", target: "_blank"} Download Chrome
|
||||
.small-4.columns.browserbtn
|
||||
%a.browserlogo{href: "http://www.mozilla.org/en-US/firefox/new/", target: "_blank"}
|
||||
%img{src: "assets/browser-logos/firefox.png"}
|
||||
%a{href: "http://www.mozilla.org/en-US/firefox/new/", target: "_blank"} Download Firefox
|
||||
.small-4.columns.browserbtn
|
||||
%a.browserlogo{href: "http://windows.microsoft.com/en-AU/internet-explorer/download-ie", target: "_blank"}
|
||||
%img{src: "assets/browser-logos/internet-explorer.png"}
|
||||
%a{href: "http://windows.microsoft.com/en-AU/internet-explorer/download-ie", target: "_blank"} Upgrade Internet Explorer
|
||||
.row.ie-msg
|
||||
.small-12.large-12.columns
|
||||
.text-center
|
||||
%em Can't upgrade your browser? Try Open Food Network on your smartphone :-)
|
||||
%a.close{href: "#"} ×
|
||||
|
||||
|
||||
= inject_json "currentHub", "current_hub"
|
||||
= inject_json "currentOrder", "current_order"
|
||||
= inject_json "user", "current_user"
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
= inject_json "enterprisesForMap" , "enterprises_for_map", collection: @enterprises
|
||||
= inject_enterprises
|
||||
|
||||
.map-container{"fill-vertical" => true}
|
||||
%map{"ng-controller" => "MapCtrl"}
|
||||
|
||||
@@ -4,7 +4,7 @@
|
||||
%img.product-img{"ng-src" => "{{product.master.images[0].large_url}}", "ng-if" => "product.master.images[0]"}
|
||||
.columns.small-12.large-6
|
||||
%h2
|
||||
%img{"ng-src" => "{{product.primary_taxon.icon}}"}
|
||||
%render-svg{path: "{{product.primary_taxon.icon}}"}
|
||||
{{product.name}}
|
||||
%p {{product.description}}
|
||||
%a.close-reveal-modal{"ng-click" => "$close()"}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
.producers{"ng-controller" => "ProducersCtrl"}
|
||||
:javascript
|
||||
angular.module('Darkswarm').value('producers', #{render partial: "json/producers", object: @producers})
|
||||
-#%pre
|
||||
-#{{ Producers.producers | json }}
|
||||
= inject_enterprises
|
||||
|
||||
.row
|
||||
.small-12.columns.text-center.pad-top
|
||||
|
||||
@@ -14,7 +14,7 @@
|
||||
|
||||
%div{bindonce: true}
|
||||
%product{"ng-controller" => "ProductNodeCtrl",
|
||||
"ng-repeat" => "product in data.products | filter:query | orderBy:ordering.order | limitTo: limit track by product.id"}
|
||||
"ng-repeat" => "product in Product.products | filter:query | orderBy:ordering.order | limitTo: limit track by product.id"}
|
||||
%div
|
||||
= render partial: "shop/products/summary"
|
||||
%div{"bo-if" => "hasVariants"}
|
||||
@@ -22,12 +22,10 @@
|
||||
.variants.row{"bo-if" => "!hasVariants"}
|
||||
= render partial: "shop/products/master"
|
||||
|
||||
%product{"ng-show" => "data.loading"}
|
||||
%product{"ng-show" => "Product.loading"}
|
||||
.row.summary
|
||||
.small-12.columns.text-center
|
||||
Loading products
|
||||
|
||||
|
||||
.row
|
||||
.small-12.columns
|
||||
%input.button.primary.right.add_to_cart{type: :submit, value: "Add to Cart"}
|
||||
|
||||
@@ -15,7 +15,7 @@
|
||||
name: "variants[{{product.master.id}}]",
|
||||
id: "variants_{{product.master.id}}",
|
||||
"ng-model" => "product.quantity"}
|
||||
{{ product.master.unit_to_display }}
|
||||
%small {{ product.master.unit_to_display }}
|
||||
|
||||
-# WITH GROUP BUY
|
||||
.small-2.columns{"bo-if" => "product.group_buy"}
|
||||
|
||||
@@ -18,7 +18,7 @@
|
||||
max: "{{variant.on_demand && 9999 || variant.count_on_hand }}",
|
||||
name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}",
|
||||
"bo-model" => "variant.quantity"}
|
||||
{{ variant.unit_to_display }}
|
||||
%small {{ variant.unit_to_display }}
|
||||
|
||||
-# WITH GROUP BUY
|
||||
.small-2.columns{"bo-if" => "product.group_buy"}
|
||||
@@ -39,7 +39,7 @@
|
||||
max: "{{variant.on_demand && 9999 || variant.count_on_hand }}",
|
||||
name: "variant_attributes[{{variant.id}}][max_quantity]",
|
||||
"ng-model" => "variant.max_quantity"}
|
||||
{{ variant.unit_to_display }}
|
||||
%small {{ variant.unit_to_display }}
|
||||
|
||||
.small-2.columns.text-right.price
|
||||
{{ variant.price | currency }}
|
||||
|
||||
@@ -6,9 +6,9 @@
|
||||
Next order closing
|
||||
%strong {{ OrderCycle.orders_close_at() | date_in_words }}
|
||||
|
||||
%span Ready for pickup
|
||||
%span Ready for
|
||||
|
||||
/ Will this label should be a variable to reflect pickup or delivery as appropriate
|
||||
/ Will this label should be a variable to reflect 'Ready for pickup / delivery' as appropriate
|
||||
|
||||
%select.avenir#order_cycle_id{"ng-model" => "order_cycle.order_cycle_id",
|
||||
"ng-change" => "changeOrderCycle()",
|
||||
|
||||
@@ -18,4 +18,9 @@ describe BaseController do
|
||||
response.should redirect_to root_url
|
||||
flash[:info].should == "The order cycle you've selected has just closed. Please try again!"
|
||||
end
|
||||
|
||||
it "loads active_distributors" do
|
||||
Enterprise.should_receive(:distributors_with_active_order_cycles)
|
||||
controller.load_active_distributors
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,8 +1,8 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe MapController do
|
||||
it "loads all visible enterprises" do
|
||||
Enterprise.should_receive(:visible)
|
||||
it "loads active distributors" do
|
||||
Enterprise.should_receive(:distributors_with_active_order_cycles)
|
||||
get :index
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,9 +1,15 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe ProducersController do
|
||||
it "gets all active producers" do
|
||||
Enterprise.stub_chain(:is_primary_producer, :visible)
|
||||
Enterprise.should_receive(:is_primary_producer)
|
||||
let!(:distributor) { create(:distributor_enterprise) }
|
||||
|
||||
before do
|
||||
Enterprise.stub(:distributors_with_active_order_cycles).and_return [distributor]
|
||||
Enterprise.stub(:visible).and_return [distributor]
|
||||
end
|
||||
|
||||
it "sets active distributors" do
|
||||
get :index
|
||||
assigns[:active_distributors].should == [distributor]
|
||||
end
|
||||
end
|
||||
|
||||
@@ -77,7 +77,6 @@ feature "As a consumer I want to shop with a distributor", js: true do
|
||||
page.should have_content "Next order closing in 2 days"
|
||||
Spree::Order.last.order_cycle.should == oc1
|
||||
page.should have_content product.name
|
||||
save_screenshot "/Users/willmarshall/Desktop/shop.png"
|
||||
page.should have_content product.master.display_name
|
||||
page.should have_content product.master.display_as
|
||||
end
|
||||
|
||||
@@ -5,7 +5,10 @@
|
||||
//= require angular-mocks
|
||||
//= require angular-cookies
|
||||
//= require angular-backstretch.js
|
||||
//= require lodash.underscore.js
|
||||
//= require angular-flash.min.js
|
||||
//= require moment
|
||||
|
||||
angular.module('templates', [])
|
||||
angular.module('google-maps', []);
|
||||
angular.module('duScroll', []);
|
||||
|
||||
68
spec/javascripts/mock_google_maps.js.coffee
Normal file
68
spec/javascripts/mock_google_maps.js.coffee
Normal file
@@ -0,0 +1,68 @@
|
||||
@google =
|
||||
maps:
|
||||
event:
|
||||
addDomListener: ->
|
||||
addDomListenerOnce: ->
|
||||
addListener: ->
|
||||
addListenerOnce: ->
|
||||
bind: ->
|
||||
clearInstanceListeners: ->
|
||||
clearListeners: ->
|
||||
forward: ->
|
||||
removeListener: ->
|
||||
trigger: ->
|
||||
vf: ->
|
||||
|
||||
class google.maps.LatLng
|
||||
constructor: (lat, lng) ->
|
||||
@latitude = parseFloat(lat)
|
||||
@longitude = parseFloat(lng)
|
||||
|
||||
lat: -> @latitude
|
||||
lng: -> @longitude
|
||||
|
||||
class google.maps.LatLngBounds
|
||||
constructor: (@ne, @sw) ->
|
||||
|
||||
getSouthWest: -> @sw
|
||||
getNorthEast: -> @ne
|
||||
|
||||
class google.maps.OverlayView
|
||||
|
||||
class google.maps.Marker
|
||||
getAnimation: ->
|
||||
getClickable: ->
|
||||
getCursor: ->
|
||||
getDraggable: ->
|
||||
getFlat: ->
|
||||
getIcon: ->
|
||||
getPosition: ->
|
||||
getShadow: ->
|
||||
getShape: ->
|
||||
getTitle: ->
|
||||
getVisible: ->
|
||||
getZIndex: ->
|
||||
setAnimation: ->
|
||||
setClickable: ->
|
||||
setCursor: ->
|
||||
setDraggable: ->
|
||||
setFlat: ->
|
||||
setIcon: ->
|
||||
setPosition: ->
|
||||
setShadow: ->
|
||||
setShape: ->
|
||||
setTitle: ->
|
||||
setVisible: ->
|
||||
setZIndex: ->
|
||||
setMap: ->
|
||||
getMap: ->
|
||||
|
||||
class google.maps.MarkerImage
|
||||
|
||||
class google.maps.Map
|
||||
|
||||
class google.maps.Point
|
||||
|
||||
class google.maps.Size
|
||||
|
||||
class google.maps.InfoWindow
|
||||
@@ -1,9 +1,14 @@
|
||||
describe "AccordionCtrl", ->
|
||||
ctrl = null
|
||||
scope = null
|
||||
CurrentHubMock =
|
||||
id: 1
|
||||
|
||||
beforeEach ->
|
||||
module "Darkswarm"
|
||||
module ($provide)->
|
||||
$provide.value "CurrentHub", CurrentHubMock
|
||||
null
|
||||
localStorage.clear()
|
||||
|
||||
describe "loading incomplete form", ->
|
||||
|
||||
@@ -9,7 +9,7 @@ describe 'ProductsCtrl', ->
|
||||
Product =
|
||||
all: ->
|
||||
update: ->
|
||||
data: "testy mctest"
|
||||
products: "testy mctest"
|
||||
OrderCycle =
|
||||
order_cycle: {}
|
||||
|
||||
@@ -18,4 +18,4 @@ describe 'ProductsCtrl', ->
|
||||
ctrl = $controller 'ProductsCtrl', {$scope: scope, Product: Product, OrderCycle: OrderCycle}
|
||||
|
||||
it 'fetches products from Product', ->
|
||||
expect(scope.data).toEqual 'testy mctest'
|
||||
expect(scope.Product.products).toEqual 'testy mctest'
|
||||
|
||||
@@ -0,0 +1,27 @@
|
||||
describe "Enterprises service", ->
|
||||
Enterprises = null
|
||||
enterprises = [
|
||||
{id: 1, type: "hub", producers: [{id: 2}]},
|
||||
{id: 2, type: "producer", hubs: [{id: 1}]},
|
||||
{id: 3, type: "producer", hubs: [{id: 1}]}
|
||||
]
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
angular.module('Darkswarm').value('enterprises', enterprises)
|
||||
|
||||
inject ($injector)->
|
||||
Enterprises = $injector.get("Enterprises")
|
||||
|
||||
it "stores enterprises as id/object pairs", ->
|
||||
expect(Enterprises.enterprises_by_id["1"]).toBe enterprises[0]
|
||||
expect(Enterprises.enterprises_by_id["2"]).toBe enterprises[1]
|
||||
|
||||
it "stores enterprises as an array", ->
|
||||
expect(Enterprises.enterprises).toBe enterprises
|
||||
|
||||
it "puts the same objects in enterprises and enterprises_by_id", ->
|
||||
expect(Enterprises.enterprises[0]).toBe Enterprises.enterprises_by_id["1"]
|
||||
|
||||
it "dereferences references to other enterprises", ->
|
||||
expect(Enterprises.enterprises_by_id["1"].producers[0]).toBe enterprises[1]
|
||||
expect(Enterprises.enterprises_by_id["3"].hubs[0]).toBe enterprises[0]
|
||||
39
spec/javascripts/unit/darkswarm/services/hubs_spec.js.coffee
Normal file
39
spec/javascripts/unit/darkswarm/services/hubs_spec.js.coffee
Normal file
@@ -0,0 +1,39 @@
|
||||
describe "Hubs service", ->
|
||||
Hubs = null
|
||||
Enterprises = null
|
||||
hubs = [
|
||||
{
|
||||
id: 2
|
||||
active: false
|
||||
orders_close_at: new Date()
|
||||
is_distributor: true
|
||||
}
|
||||
{
|
||||
id: 3
|
||||
active: false
|
||||
orders_close_at: new Date()
|
||||
is_distributor: true
|
||||
}
|
||||
{
|
||||
id: 1
|
||||
active: true
|
||||
orders_close_at: new Date()
|
||||
is_distributor: true
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
angular.module('Darkswarm').value('enterprises', hubs)
|
||||
inject ($injector)->
|
||||
Enterprises = $injector.get("Enterprises")
|
||||
Hubs = $injector.get("Hubs")
|
||||
|
||||
it "filters Enterprise.hubs into a new array", ->
|
||||
expect(Hubs.hubs[0]).toBe Enterprises.enterprises[2]
|
||||
# Because the $filter is a new sorted array
|
||||
# We check to see the objects in both arrays are still the same
|
||||
Enterprises.enterprises[2].active = false
|
||||
expect(Hubs.hubs[0].active).toBe false
|
||||
|
||||
19
spec/javascripts/unit/darkswarm/services/map_spec.js.coffee
Normal file
19
spec/javascripts/unit/darkswarm/services/map_spec.js.coffee
Normal file
@@ -0,0 +1,19 @@
|
||||
describe "Hubs service", ->
|
||||
OfnMap = null
|
||||
enterprises = [
|
||||
{
|
||||
id: 2
|
||||
active: false
|
||||
orders_close_at: new Date()
|
||||
type: "hub"
|
||||
}
|
||||
]
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
angular.module('Darkswarm').value('enterprises', enterprises)
|
||||
inject ($injector)->
|
||||
OfnMap = $injector.get("OfnMap")
|
||||
|
||||
it "builds MapMarkers from enterprises", ->
|
||||
expect(OfnMap.enterprises[0].id).toBe enterprises[0].id
|
||||
@@ -6,6 +6,10 @@ describe 'Order service', ->
|
||||
flash = null
|
||||
storage = null
|
||||
scope = null
|
||||
CurrentHubMock =
|
||||
id: 1
|
||||
FlashLoaderMock =
|
||||
loadFlash: (arg)->
|
||||
|
||||
beforeEach ->
|
||||
orderData =
|
||||
@@ -36,6 +40,10 @@ describe 'Order service', ->
|
||||
|
||||
angular.module('Darkswarm').value('order', orderData)
|
||||
module 'Darkswarm'
|
||||
module ($provide)->
|
||||
$provide.value "CurrentHub", CurrentHubMock
|
||||
$provide.value "RailsFlashLoader", FlashLoaderMock
|
||||
null
|
||||
|
||||
inject ($injector, _$httpBackend_, _storage_, $rootScope)->
|
||||
$httpBackend = _$httpBackend_
|
||||
@@ -58,13 +66,13 @@ describe 'Order service', ->
|
||||
spyOn(storage, "bind")
|
||||
Order.fieldsToBind = ["testy"]
|
||||
Order.bindFieldsToLocalStorage({})
|
||||
prefix = "order_#{Order.order.id}#{Order.order.user_id}"
|
||||
prefix = "order_#{Order.order.id}#{Order.order.user_id}#{CurrentHubMock.id}"
|
||||
expect(storage.bind).toHaveBeenCalledWith({}, "Order.order.testy", {storeName: "#{prefix}_testy"})
|
||||
expect(storage.bind).toHaveBeenCalledWith({}, "Order.ship_address_same_as_billing", {storeName: "#{prefix}_sameasbilling", defaultValue: true})
|
||||
|
||||
it "binds order to local storage", ->
|
||||
Order.bindFieldsToLocalStorage(scope)
|
||||
prefix = "order_#{Order.order.id}#{Order.order.user_id}"
|
||||
prefix = "order_#{Order.order.id}#{Order.order.user_id}#{CurrentHubMock.id}"
|
||||
expect(localStorage.getItem("#{prefix}_email")).toMatch "test@test.com"
|
||||
|
||||
it "does not store secrets in local storage", ->
|
||||
@@ -100,10 +108,11 @@ describe 'Order service', ->
|
||||
$httpBackend.flush()
|
||||
|
||||
it "sends flash messages to the flash service", ->
|
||||
spyOn(FlashLoaderMock, "loadFlash") # Stubbing out writes to window.location
|
||||
$httpBackend.expectPUT("/checkout").respond 400, {flash: {error: "frogs"}}
|
||||
Order.submit()
|
||||
$httpBackend.flush()
|
||||
expect(flash.error).toEqual "frogs"
|
||||
expect(FlashLoaderMock.loadFlash).toHaveBeenCalledWith {error: "frogs"}
|
||||
|
||||
it "puts errors into the scope", ->
|
||||
$httpBackend.expectPUT("/checkout").respond 400, {errors: {error: "frogs"}}
|
||||
|
||||
@@ -0,0 +1,15 @@
|
||||
describe "Producers service", ->
|
||||
Producers = null
|
||||
Enterprises = null
|
||||
enterprises = [
|
||||
{is_primary_producer: true}
|
||||
]
|
||||
|
||||
beforeEach ->
|
||||
module 'Darkswarm'
|
||||
angular.module('Darkswarm').value('enterprises', enterprises)
|
||||
inject ($injector)->
|
||||
Producers = $injector.get("Producers")
|
||||
|
||||
it "delegates producers array to Enterprises", ->
|
||||
expect(Producers.producers[0]).toBe enterprises[0]
|
||||
@@ -11,4 +11,4 @@ describe 'Product service', ->
|
||||
it "Fetches products from the backend on init", ->
|
||||
$httpBackend.expectGET("/shop/products").respond([{test : "cats"}])
|
||||
$httpBackend.flush()
|
||||
expect(Product.data.products[0].test).toEqual "cats"
|
||||
expect(Product.products[0].test).toEqual "cats"
|
||||
|
||||
Reference in New Issue
Block a user