Merge branch 'master' into laura_and_will

This commit is contained in:
summerscope
2014-06-26 11:16:42 +10:00
45 changed files with 303 additions and 167 deletions

View File

@@ -6,11 +6,12 @@
#= require angular
#= require angular-cookies
#= require angular-sanitize
#= require angular-animate
#= require angular-resource
#= require lodash.underscore.js
#= require angular-scroll.min.js
#= require angular-google-maps.min.js
#= require ../shared/mm-foundation-tpls-0.2.0-SNAPSHOT
#= require ../shared/mm-foundation-tpls-0.2.2.min.js
#= require ../shared/bindonce.min.js
#= require ../shared/ng-infinite-scroll.min.js
#= require ../shared/angular-local-storage.js

View File

@@ -2,5 +2,7 @@ Darkswarm.controller "GroupsCtrl", ($scope, Groups, $anchorScroll, $rootScope) -
$scope.Groups = Groups
$scope.order = 'position'
$rootScope.$on "$locationChangeSuccess", (newRoute, oldRoute) ->
$anchorScroll()
#$rootScope.$on "$locationChangeSuccess", (newRoute, oldRoute) ->
#$anchorScroll()
#
#

View File

@@ -1,2 +1,3 @@
Darkswarm.controller "ProducersTabCtrl", ($scope, CurrentHub) ->
Darkswarm.controller "ProducersTabCtrl", ($scope, CurrentHub, Enterprises) ->
# Injecting Enterprises so CurrentHub.producers is dereferenced
$scope.CurrentHub = CurrentHub

View File

@@ -6,9 +6,10 @@ window.Darkswarm = angular.module("Darkswarm", ["ngResource",
'angular-flash.service',
'templates',
'ngSanitize',
'ngAnimate',
'google-maps',
'duScroll',
'backstretch']).config ($httpProvider, $tooltipProvider, $locationProvider, $anchorScrollProvider) ->
]).config ($httpProvider, $tooltipProvider, $locationProvider, $anchorScrollProvider) ->
$httpProvider.defaults.headers.post['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content')
$httpProvider.defaults.headers.put['X-CSRF-Token'] = $('meta[name="csrf-token"]').attr('content')
$httpProvider.defaults.headers['common']['X-Requested-With'] = 'XMLHttpRequest'

View File

@@ -6,7 +6,7 @@ Darkswarm.directive "activeTableHubLink", (CurrentHub, CurrentOrder) ->
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.hub.id and CurrentHub.hub.id isnt scope.hub.id
if CurrentHub.hub?.id and CurrentHub.hub.id isnt scope.hub.id
scope.action = attr.change
else
scope.action = attr.shop

View File

@@ -3,7 +3,7 @@ Darkswarm.directive "ofnEmptiesCart", (CurrentHub, CurrentOrder, Navigation, sto
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.hub.id and CurrentHub.hub.id isnt hub.id
if CurrentHub.hub?.id and CurrentHub.hub.id isnt hub.id
unless CurrentOrder.empty()
elm.bind 'click', (ev)->
ev.preventDefault()

View File

@@ -0,0 +1,7 @@
Darkswarm.directive "hubModal", ($modal)->
restrict: 'E'
replace: true
template: "<a>{{enterprise.name}}</a>"
link: (scope, elem, attrs, ctrl)->
elem.on "click", =>
scope.modalInstance = $modal.open(controller: ctrl, templateUrl: 'hub_modal.html', scope: scope)

View File

@@ -1,6 +0,0 @@
Darkswarm.directive "offcanvas", ->
restrict: "A"
link: (scope, el, attr) ->
el.find(".left-off-canvas-toggle").bind 'click', ->
el.toggleClass 'move-right'

View File

@@ -0,0 +1,7 @@
Darkswarm.directive "producerModal", ($modal)->
restrict: 'E'
replace: true
template: "<a>{{enterprise.name}}</a>"
link: (scope, elem, attrs, ctrl)->
elem.on "click", =>
scope.modalInstance = $modal.open(controller: ctrl, templateUrl: 'producer_modal.html', scope: scope)

View File

@@ -0,0 +1,6 @@
Darkswarm.factory 'Dereferencer', ->
new class Dereferencer
dereference: (array, data)->
if array
for object, i in array
array[i] = data[object.id]

View File

@@ -1,4 +1,4 @@
Darkswarm.factory 'Enterprises', (enterprises, CurrentHub)->
Darkswarm.factory 'Enterprises', (enterprises, CurrentHub, Dereferencer)->
new class Enterprises
enterprises_by_id: {} # id/object pairs for lookup
constructor: ->
@@ -10,12 +10,6 @@ Darkswarm.factory 'Enterprises', (enterprises, CurrentHub)->
dereference: ->
if CurrentHub.hub?.id
CurrentHub.hub = @enterprises_by_id[CurrentHub.hub.id]
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]
Dereferencer.dereference enterprise.hubs, @enterprises_by_id
Dereferencer.dereference enterprise.producers, @enterprises_by_id

View File

@@ -1,4 +1,14 @@
Darkswarm.factory 'Groups', (groups) ->
Darkswarm.factory 'Groups', (groups, Enterprises, Dereferencer) ->
new class Groups
groups: groups
groups_by_id: {}
constructor: ->
@groups = groups
for group in @groups
@groups_by_id[group.id] = group
@dereference()
dereference: ->
for group in @groups
Dereferencer.dereference group.enterprises, Enterprises.enterprises_by_id
for enterprise in Enterprises.enterprises
Dereferencer.dereference enterprise.groups, @groups_by_id

View File

@@ -6,7 +6,7 @@ Darkswarm.factory "MapModal", ($modal, $rootScope)->
scope.enterprise = enterprise
if enterprise.is_distributor
scope.hub = enterprise
$modal.open(templateUrl: "map_modal_hub.html", scope: scope)
$modal.open(templateUrl: "hub_modal.html", scope: scope)
else
scope.producer = enterprise
$modal.open(templateUrl: "map_modal_producer.html", scope: scope)

File diff suppressed because one or more lines are too long

View File

@@ -0,0 +1,4 @@
%ng-include{src: "'partials/enterprise_header.html'"}
%ng-include{src: "'partials/enterprise_details.html'"}
%ng-include{src: "'partials/hub_details.html'"}
%ng-include{src: "'partials/close.html'"}

View File

@@ -1,37 +1,4 @@
.highlight
.highlight-top
%p.right
{{ [enterprise.address.city, enterprise.address.state] | printArray}}
%h3
%i.ofn-i_036-producers
{{ enterprise.name }}
%img.hero-img{"ng-src" => "{{enterprise.promo_image}}"}
.row{bindonce: true}
.small-12.large-8.columns
%div{"ng-if" => "enterprise.long_description.length > 0 || enterprise.logo"}
%h5.modal-header About
.about-container
%img.enterprise-logo{"bo-src" => "enterprise.logo", "bo-if" => "enterprise.logo"}
%p.text-small{"ng-bind-html" => "enterprise.long_description"}
.small-12.large-4.columns
%ng-include{src: "'partials/contact.html'"}
%ng-include{src: "'partials/follow.html'"}
.row.pad-top{bindonce: true, "ng-if" => "enterprise.hubs.length > 0"}
.cta-container.small-12.columns
%h5
%i.ofn-i_029-shopping-basket
Shop for {{enterprise.name}} products at:
%a.button.hub{"ng-repeat" => "hub in enterprise.hubs",
"bo-href" => "hub.path",
"bo-class" => "{primary: hub.active, secondary: !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}}
.button-address {{ hub.address.city }} , {{hub.address.state}}
%i.ofn-i_007-caret-right
%a.close-reveal-modal.outside{"ng-click" => "$close()"}
%i.ofn-i_009-close
%ng-include{src: "'partials/enterprise_header.html'"}
%ng-include{src: "'partials/enterprise_details.html'"}
%ng-include{src: "'partials/hub_actions.html'"}
%ng-include{src: "'partials/close.html'"}

View File

@@ -0,0 +1,2 @@
%a.close-reveal-modal.outside{"ng-click" => "$close()"}
%i.ofn-i_009-close

View File

@@ -5,8 +5,9 @@
{{ enterprise.phone }}
%p{"ng-if" => "enterprise.email"}
%a{"ng-href" => "mailto:{{enterprise.email | stripUrl}}", target: "_blank" }
{{ enterprise.email | stripUrl }}
%a{"ng-href" => "{{enterprise.email | stripUrl}}", target: "_blank", mailto: true}
%span.email
{{ enterprise.email | stripUrl }}
%p{"ng-if" => "enterprise.website"}
%a{"ng-href" => "http://{{enterprise.website | stripUrl}}", target: "_blank" }

View File

@@ -0,0 +1,10 @@
.row{bindonce: true}
.small-12.large-8.columns
%div{"ng-if" => "enterprise.long_description.length > 0 || enterprise.logo"}
%h5.modal-header About
.about-container
%img.enterprise-logo{"bo-src" => "enterprise.logo", "bo-if" => "enterprise.logo"}
%p.text-small{"ng-bind-html" => "enterprise.long_description"}
.small-12.large-4.columns
%ng-include{src: "'partials/contact.html'"}
%ng-include{src: "'partials/follow.html'"}

View File

@@ -0,0 +1,9 @@
.highlight
.highlight-top
%p.right
{{ [enterprise.address.city, enterprise.address.state] | printArray}}
%h3
%i.ofn-i_036-producers{"ng-show" => "!enterprise.is_distributor"}
%i.ofn-i_040-hub{"ng-show" => "enterprise.is_distributor"}
{{ enterprise.name }}
%img.hero-img{"ng-src" => "{{enterprise.promo_image}}"}

View File

@@ -0,0 +1,15 @@
.row.pad-top{bindonce: true, "ng-if" => "enterprise.hubs.length > 0"}
.cta-container.small-12.columns
%h5
%i.ofn-i_029-shopping-basket
Shop for {{enterprise.name}} products at:
%a.button.hub{"ng-repeat" => "hub in enterprise.hubs",
"bo-href" => "hub.path",
"bo-class" => "{primary: hub.active, secondary: !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}}
.button-address {{ hub.address.city }} , {{hub.address.state}}
%i.ofn-i_007-caret-right

View File

@@ -1,23 +1,3 @@
.highlight
.highlight-top
%p.right
{{ [enterprise.address.city, enterprise.address.state] | printArray}}
%h3
%i.ofn-i_040-hub
{{ enterprise.name }}
%img.hero-img{"ng-src" => "{{enterprise.promo_image}}"}
.row{bindonce: true}
.small-12.large-8.columns
%div{"ng-if" => "enterprise.long_description.length > 0 || enterprise.logo"}
%h5.modal-header About
.about-container
%img.enterprise-logo{"bo-src" => "enterprise.logo", "bo-if" => "enterprise.logo"}
%p.text-small{"ng-bind-html" => "enterprise.long_description"}
.small-12.large-4.columns
%ng-include{src: "'partials/contact.html'"}
%ng-include{src: "'partials/follow.html'"}
.row.pad-top{bindonce: true}
.cta-container.small-12.columns
.row
@@ -26,7 +6,6 @@
%i.ofn-i_029-shopping-basket
%span{"active-table-hub-link" => "enterprise", change: "Change hub to", shop: "Shop at"}
.small-12.large-6.columns.right
/ Needs logic to hide if nothing populated:
.right{"bo-if" => "enterprise.pickup || enterprise.delivery"}
Delivery options:
%span{"bo-if" => "enterprise.pickup"}
@@ -45,7 +24,3 @@
{{enterprise.name}}
.button-address {{ enterprise.address.city }} , {{enterprise.address.state}}
%i.ofn-i_007-caret-right
%a.close-reveal-modal.outside{"ng-click" => "$close()"}
%i.ofn-i_009-close

View File

@@ -0,0 +1,3 @@
%ng-include{src: "'partials/enterprise_header.html'"}
%ng-include{src: "'partials/enterprise_details.html'"}
%ng-include{src: "'partials/close.html'"}

View File

@@ -0,0 +1,30 @@
.fade
opacity: 0
-webkit-transition: opacity .15s linear
transition: opacity .15s linear
.fade.in
opacity: 1
.reveal-modal.fade
-webkit-transition: -webkit-transform .3s ease-out
-moz-transition: -moz-transform .3s ease-out
-o-transition: -o-transform .3s ease-out
transition: transform .3s ease-out
-webkit-transform: translate(0, -25%)
-ms-transform: translate(0, -25%)
transform: translate(0, -25%)
.reveal-modal.in
-webkit-transform: translate(0, 0)
-ms-transform: translate(0, 0)
transform: translate(0, 0)
.reveal-modal-bg.fade
filter: alpha(opacity = 0)
opacity: 0
.reveal-modal-bg.in
filter: alpha(opacity = 50)
opacity: .5

View File

@@ -1,4 +1,5 @@
= inject_enterprises
:javascript
angular.module('Darkswarm').value('groups', #{render partial: "json/groups", object: @groups})
@@ -36,10 +37,11 @@
.small-6.columns
%p {{ group.long_description }}
.small-6.columns
%h5 Our hubs & producers
%h5 Our hubs &amp; producers
%ul.small-block-grid-2
%li{"ng-repeat" => "enterprise in group.enterprises"}
%a{"bo-href" => "enterprise.path"} {{ enterprise.name }}
%li{"ng-repeat" => "enterprise in group.enterprises", "scroll-after-load" => true}
%hub-modal{"ng-if" => "enterprise.is_distributor"}
%producer-modal{"ng-if" => "!enterprise.is_distributor", "show-hub-actions" => 'true'}
.row.group_footer
.small-12.columns

View File

@@ -28,9 +28,9 @@
Our producers
%ul.bullet-list
%li{"ng-repeat" => "enterprise in hub.producers"}
= render partial: "modals/producer"
%producer-modal
.row.active_table_row.link{"ng-show" => "open()", "bo-if" => "hub.active"}
.row.active_table_row.link{"ng-show" => "open()"}
.cta-container.columns.small-12
.row
.columns.small-12

View File

@@ -2,7 +2,7 @@ collection @groups
attributes :id, :name, :position, :description, :long_description
child enterprises: :enterprises do
extends 'json/enterprises'
attributes :id
end
node :logo do |group|

View File

@@ -13,8 +13,10 @@ end
node :delivery do |hub|
hub.shipping_methods.where(:require_ship_address => true).present?
end
node :active do |hub|
@active_distributors.include?(hub)
if @active_distributors
node :active do |hub|
@active_distributors.include?(hub)
end
end
node :orders_close_at do |hub|
OrderCycle.first_closing_for(hub).andand.orders_close_at

View File

@@ -5,7 +5,7 @@
%title= content_for?(:title) ? yield(:title) : 'Welcome to Open Food Network'
= favicon_link_tag "favicon.png"
%link{href: "http://fonts.googleapis.com/css?family=Open+Sans:400,700", rel: "stylesheet", type: "text/css"}/
%link{href: "https://fonts.googleapis.com/css?family=Open+Sans:400,700", rel: "stylesheet", type: "text/css"}/
= yield :scripts
%script{src: "//maps.googleapis.com/maps/api/js?sensor=false"}

View File

@@ -23,8 +23,9 @@
{{ enterprise.phone }}
%p{"bo-if" => "enterprise.email"}
%a{"ng-href" => "mailto:{{enterprise.email | stripUrl}}", target: "_blank" }
{{ enterprise.email | stripUrl }}
%a{"ng-href" => "{{enterprise.email | stripUrl}}", target: "_blank", mailto: true }
%span.email
{{ enterprise.email | stripUrl }}
%p{"bo-show" => "enterprise.website"}
%a{"ng-href" => "http://{{enterprise.website}}", target: "_blank" }

View File

@@ -12,7 +12,7 @@
%input.button.primary.right{type: :submit, value: "Add to Cart"}
%div{bindonce: true}
%product{"ng-controller" => "ProductNodeCtrl",
%product.animate-repeat{"ng-controller" => "ProductNodeCtrl",
"ng-repeat" => "product in Product.products | products:query | orderBy:ordering.order | limitTo: limit track by product.id"}
%div
= render partial: "shop/products/summary"

View File

@@ -15,7 +15,7 @@
name: "variants[{{product.master.id}}]",
id: "variants_{{product.master.id}}",
"ng-model" => "product.quantity"}
%small {{ product.master.unit_to_display }}
%small x {{ product.master.unit_to_display }}
-# WITH GROUP BUY
.small-2.columns{"bo-if" => "product.group_buy"}
@@ -36,7 +36,7 @@
max: "{{product.on_demand && 9999 || product.count_on_hand }}",
name: "variant_attributes[{{product.master.id}}][max_quantity]",
"ng-model" => "product.max_quantity"}
{{ product.master.unit_to_display }}
%small x {{ product.master.unit_to_display }}
.small-2.columns.text-right
{{ product.price | currency }}

View File

@@ -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"}
%small {{ variant.unit_to_display }}
%small x {{ 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"}
%small {{ variant.unit_to_display }}
%small x {{ variant.unit_to_display }}
.small-2.columns.text-right.price
{{ variant.price | currency }}

View File

@@ -4,57 +4,57 @@
.panel
.row
.small-12.large-4.columns
/ Will this is the logic - if all the things are blank, don't display
/ {"ng-if" => "current_distributor.address.address1 || current_distributor.address.address2 || current_distributor.address.city || current_distributor.address.state || current_distributor.address.zipcode"}
%div.modal-centered
%h5.modal-header=current_distributor.name
%p
= current_distributor.address.address1
- unless current_distributor.address.address2.blank?
- if current_distributor.address.address1 || current_distributor.address.address2 || current_distributor.address.city || current_distributor.address.state || current_distributor.address.zipcode
%div.modal-centered
%h5.modal-header=current_distributor.name
%p
= current_distributor.address.address1
- unless current_distributor.address.address2.blank?
%br
= current_distributor.address.address2
%br
= current_distributor.address.address2
%br
= current_distributor.address.city
= current_distributor.address.state
= current_distributor.address.zipcode
= current_distributor.address.city
= current_distributor.address.state
= current_distributor.address.zipcode
.small-12.large-4.columns
/ Will this is the logic - if all the things are blank, don't display
/ {"ng-if" => "current_distributor.website || current_distributor.email"}
%div.modal-centered
%h5.modal-header Contact
- unless current_distributor.website.blank?
%p
%a{href: "http://#{current_distributor.website}", target: "_blank" }
= current_distributor.website
- unless current_distributor.email.blank?
%p
%a{href: current_distributor.email.reverse, mailto: true}
%span.email
= current_distributor.email.reverse
- if current_distributor.website || current_distributor.email
%div.modal-centered
%h5.modal-header Contact
- unless current_distributor.website.blank?
%p
%a{href: "http://#{current_distributor.website}", target: "_blank" }
= current_distributor.website
- unless current_distributor.email.blank?
%p
%a{href: current_distributor.email.reverse, mailto: true}
%span.email
= current_distributor.email.reverse
.small-12.large-4.columns
/ Will this is the logic - if all the things are blank, don't display
/ {"ng-if" => "current_distributor.twitter || current_distributor.facebook || current_distributor.linkedin || current_distributor.instagram"}
%div.modal-centered
%h5.modal-header Follow
%div.follow-icons
- unless current_distributor.twitter.blank?
%span
%a{href: "http://twitter.com/#{current_distributor.twitter}", target: "_blank" }
%i.ofn-i_041-twitter
- if current_distributor.twitter.present? || current_distributor.facebook.present? || current_distributor.linkedin.present? || current_distributor.instagram.present?
%div.modal-centered
%h5.modal-header Follow
%div.follow-icons
- unless current_distributor.twitter.blank?
%span
%a{href: "http://twitter.com/#{current_distributor.twitter}", target: "_blank" }
%i.ofn-i_041-twitter
- unless current_distributor.facebook.blank?
%span
%a{href: "http://#{current_distributor.facebook}", target: "_blank" }
%i.ofn-i_044-facebook
- unless current_distributor.facebook.blank?
%span
%a{href: "http://#{current_distributor.facebook}", target: "_blank" }
%i.ofn-i_044-facebook
= current_distributor.facebook
- unless current_distributor.linkedin.blank?
%span
%a{href: "http://#{current_distributor.linkedin}", target: "_blank" }
%i.ofn-i_042-linkedin
- unless current_distributor.linkedin.blank?
%span
%a{href: "http://#{current_distributor.linkedin}", target: "_blank" }
%i.ofn-i_042-linkedin
= current_distributor.linkedin
- unless current_distributor.instagram.blank?
%span
%a{href: "http://instagram.com.#{current_distributor.instagram}", target: "_blank" }
%i.ofn-i_043-instagram
- unless current_distributor.instagram.blank?
%span
%a{href: "http://instagram.com.#{current_distributor.instagram}", target: "_blank" }
%i.ofn-i_043-instagram
= current_distributor.instagram

View File

@@ -1,10 +1,14 @@
.content
.row
.small-12.columns.panel
%h5
=current_distributor.name
is part of:
%ul.bullet-list
- for group in current_distributor.groups
%li
%a{href: main_app.groups_path(anchor: "#/#group#{group.id}")}= group.name
- if current_distributor.groups.length > 0
%h5
=current_distributor.name
is part of:
%ul.bullet-list
- for group in current_distributor.groups
%li
= group.id
%a{href: main_app.groups_path + "/#/#group#{group.id}"}
= group.name

View File

@@ -2,8 +2,7 @@
.row
.small-12.columns.panel
%h5
Our producers:
/ = "#{current_distributor.name}'s producers:"
{{CurrentHub.hub.name}}'s producers:
%ul.bullet-list
%li{"ng-repeat" => "enterprise in CurrentHub.hub.producers"}
= render partial: "modals/producer"

View File

@@ -1,4 +1,5 @@
- @body_id = 'cart'
= inject_enterprises
.darkswarm
- content_for :order_cycle_form do
%strong.avenir

View File

@@ -1,3 +1,5 @@
= inject_enterprises
.darkswarm
- content_for :order_cycle_form do
%strong.avenir

View File

@@ -3,11 +3,7 @@ Openfoodnetwork::Application.routes.draw do
get "/#/login", to: "home#index", as: :spree_login
if Rails.env.production?
get "/map", to: "home#index", as: :map
else
get "/map", to: "map#index", as: :map
end
get "/map", to: "map#index", as: :map
resource :shop, controller: "shop" do
get :products

View File

@@ -1,9 +1,17 @@
require 'spec_helper'
describe GroupsController do
render_views
let(:enterprise) { create(:distributor_enterprise) }
let!(:group) { create(:enterprise_group, enterprises: [enterprise], on_front_page: true) }
it "gets all visible groups" do
EnterpriseGroup.stub_chain :on_front_page, :by_position
EnterpriseGroup.should_receive :on_front_page
get :index
end
it "loads all enterprises for group" do
get :index
response.body.should have_text enterprise.id
end
end

View File

@@ -0,0 +1,21 @@
require 'spec_helper'
feature 'Groups', js: true do
include AuthenticationWorkflow
include UIComponentHelper
let(:enterprise) { create(:distributor_enterprise) }
let!(:group) { create(:enterprise_group, enterprises: [enterprise], on_front_page: true) }
it "renders groups" do
visit groups_path
page.should have_content group.name
end
it "renders enterprise modals for groups" do
visit groups_path
page.should have_content enterprise.name
open_enterprise_modal enterprise
modal_should_be_open_for enterprise
end
end

View File

@@ -8,6 +8,8 @@ feature 'Home', js: true do
let(:d1) { create(:distributor_enterprise) }
let(:d2) { create(:distributor_enterprise) }
let!(:order_cycle) { create(:order_cycle, distributors: [distributor], coordinator: create(:distributor_enterprise)) }
let!(:producer) { create(:supplier_enterprise) }
let!(:er) { create(:enterprise_relationship, parent: distributor, child: producer) }
before do
visit "/"
@@ -30,4 +32,11 @@ feature 'Home', js: true do
follow_active_table_node distributor.name
current_path.should == "/shop"
end
it "should show hub producer modals" do
expand_active_table_node distributor.name
page.should have_content producer.name
open_enterprise_modal producer
modal_should_be_open_for producer
end
end

View File

@@ -196,7 +196,7 @@ feature "As a consumer I want to shop with a distributor", js: true do
context "when no order cycles are available" do
it "tells us orders are closed" do
visit shop_path
page.should have_content "Orders are currently closed for this hub"
page.should have_content "Orders are closed"
end
it "shows the last order cycle" do
oc1 = create(:simple_order_cycle, distributors: [distributor], orders_close_at: 10.days.ago)

View File

@@ -0,0 +1,33 @@
describe "Groups service", ->
Groups = null
Enterprises = null
CurrentHubMock = {}
groups = [{
id: 1
name: "Test Group"
enterprises: [
{id: 1},
{id: 2}
]
}]
enterprises = [
{id: 1, name: "Test 1", groups: [{id: 1}]},
{id: 2, name: "Test 2", groups: [{id: 1}]}
]
beforeEach ->
module 'Darkswarm'
angular.module('Darkswarm').value('groups', groups)
angular.module('Darkswarm').value('enterprises', enterprises)
module ($provide)->
$provide.value "CurrentHub", CurrentHubMock
null
inject (_Groups_, _Enterprises_)->
Groups = _Groups_
Enterprises = _Enterprises_
it "dereferences group enterprises", ->
expect(Groups.groups[0].enterprises[0]).toBe enterprises[0]
it "dereferences enterprise groups", ->
expect(Enterprises.enterprises[0].groups[0]).toBe groups[0]

View File

@@ -38,6 +38,16 @@ module UIComponentHelper
have_selector ".login-modal"
end
def open_enterprise_modal(enterprise)
find("a", text: enterprise.name).click
end
def modal_should_be_open_for(enterprise)
within ".reveal-modal" do
page.should have_content enterprise.name
end
end
def have_reset_password
have_content "An email with instructions on resetting your password has been sent!"
end