mirror of
https://github.com/openfoodfoundation/openfoodnetwork
synced 2026-02-27 01:43:22 +00:00
Merge branch 'laura_and_will' into new_cart
Conflicts: app/views/shop/products/_form.html.haml app/views/shop/products/_master.html.haml app/views/shop/products/_variants.html.haml
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -5,6 +5,7 @@
|
||||
*.swp
|
||||
.sass-cache
|
||||
db/*.sqlite3
|
||||
db/*.csv
|
||||
log/*.log
|
||||
log/*.log.lck
|
||||
log/*.log.*
|
||||
|
||||
2
Gemfile
2
Gemfile
@@ -1,7 +1,7 @@
|
||||
source 'https://rubygems.org'
|
||||
ruby "1.9.3"
|
||||
|
||||
gem 'rails', '3.2.17'
|
||||
gem 'rails', '3.2.19'
|
||||
|
||||
gem 'pg'
|
||||
gem 'spree', :github => 'openfoodfoundation/spree', :branch => '1-3-stable'
|
||||
|
||||
50
Gemfile.lock
50
Gemfile.lock
@@ -104,12 +104,12 @@ GIT
|
||||
GEM
|
||||
remote: https://rubygems.org/
|
||||
specs:
|
||||
actionmailer (3.2.17)
|
||||
actionpack (= 3.2.17)
|
||||
actionmailer (3.2.19)
|
||||
actionpack (= 3.2.19)
|
||||
mail (~> 2.5.4)
|
||||
actionpack (3.2.17)
|
||||
activemodel (= 3.2.17)
|
||||
activesupport (= 3.2.17)
|
||||
actionpack (3.2.19)
|
||||
activemodel (= 3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
builder (~> 3.0.0)
|
||||
erubis (~> 2.7.0)
|
||||
journey (~> 1.0.4)
|
||||
@@ -131,18 +131,18 @@ GEM
|
||||
json (~> 1.7)
|
||||
money (< 7.0.0)
|
||||
nokogiri (~> 1.4)
|
||||
activemodel (3.2.17)
|
||||
activesupport (= 3.2.17)
|
||||
activemodel (3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
builder (~> 3.0.0)
|
||||
activerecord (3.2.17)
|
||||
activemodel (= 3.2.17)
|
||||
activesupport (= 3.2.17)
|
||||
activerecord (3.2.19)
|
||||
activemodel (= 3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
arel (~> 3.0.2)
|
||||
tzinfo (~> 0.3.29)
|
||||
activeresource (3.2.17)
|
||||
activemodel (= 3.2.17)
|
||||
activesupport (= 3.2.17)
|
||||
activesupport (3.2.17)
|
||||
activeresource (3.2.19)
|
||||
activemodel (= 3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
activesupport (3.2.19)
|
||||
i18n (~> 0.6, >= 0.6.4)
|
||||
multi_json (~> 1.0)
|
||||
acts_as_list (0.1.4)
|
||||
@@ -370,17 +370,17 @@ GEM
|
||||
rack
|
||||
rack-test (0.6.2)
|
||||
rack (>= 1.0)
|
||||
rails (3.2.17)
|
||||
actionmailer (= 3.2.17)
|
||||
actionpack (= 3.2.17)
|
||||
activerecord (= 3.2.17)
|
||||
activeresource (= 3.2.17)
|
||||
activesupport (= 3.2.17)
|
||||
rails (3.2.19)
|
||||
actionmailer (= 3.2.19)
|
||||
actionpack (= 3.2.19)
|
||||
activerecord (= 3.2.19)
|
||||
activeresource (= 3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
bundler (~> 1.0)
|
||||
railties (= 3.2.17)
|
||||
railties (3.2.17)
|
||||
actionpack (= 3.2.17)
|
||||
activesupport (= 3.2.17)
|
||||
railties (= 3.2.19)
|
||||
railties (3.2.19)
|
||||
actionpack (= 3.2.19)
|
||||
activesupport (= 3.2.19)
|
||||
rack-ssl (~> 1.3.2)
|
||||
rake (>= 0.8.7)
|
||||
rdoc (~> 3.4)
|
||||
@@ -540,7 +540,7 @@ DEPENDENCIES
|
||||
rabl
|
||||
rack-livereload
|
||||
rack-ssl
|
||||
rails (= 3.2.17)
|
||||
rails (= 3.2.19)
|
||||
representative_view
|
||||
rspec-rails
|
||||
sass (~> 3.2)
|
||||
|
||||
10
app/assets/images/flag.svg
Normal file
10
app/assets/images/flag.svg
Normal file
@@ -0,0 +1,10 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<!-- Generator: Adobe Illustrator 17.1.0, SVG Export Plug-In . SVG Version: 6.00 Build 0) -->
|
||||
<!DOCTYPE svg PUBLIC "-//W3C//DTD SVG 1.0//EN" "http://www.w3.org/TR/2001/REC-SVG-20010904/DTD/svg10.dtd">
|
||||
<svg version="1.0" id="Layer_1" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink" x="0px" y="0px"
|
||||
viewBox="15 13 34 38.4" enable-background="new 15 13 34 38.4" xml:space="preserve">
|
||||
<g>
|
||||
<polygon fill="#FFFFFF" points="15.5,13.5 48.5,13.5 48.5,50.7 31.6,45.5 15.5,50.7 "/>
|
||||
<path fill="#999999" d="M48,14v36l-16.4-5L16,50V14H48 M49,13h-1H16h-1v1v36v1.4l1.3-0.4l15.3-5l16.1,5l1.3,0.4V50V14V13L49,13z"/>
|
||||
</g>
|
||||
</svg>
|
||||
|
After Width: | Height: | Size: 696 B |
Binary file not shown.
|
Before Width: | Height: | Size: 13 KiB After Width: | Height: | Size: 10 KiB |
BIN
app/assets/images/gray_jean_light.png
Normal file
BIN
app/assets/images/gray_jean_light.png
Normal file
Binary file not shown.
|
After Width: | Height: | Size: 8.2 KiB |
@@ -0,0 +1,30 @@
|
||||
$(document).ready ->
|
||||
if $("#variant_autocomplete_template").length > 0
|
||||
window.variantTemplate = Handlebars.compile($("#variant_autocomplete_template").text())
|
||||
|
||||
formatVariantResult = (variant) ->
|
||||
if variant["images"][0] != undefined && variant["images"][0].image != undefined
|
||||
variant.image = variant.images[0].image.mini_url
|
||||
variantTemplate variant: variant
|
||||
|
||||
$.fn.variantAutocomplete = ->
|
||||
if Spree.routes
|
||||
@parent().children(".options_placeholder").attr "id", @parent().data("index")
|
||||
@select2
|
||||
placeholder: "Select a variant"
|
||||
minimumInputLength: 3
|
||||
ajax:
|
||||
url: Spree.routes.variants_search
|
||||
datatype: "json"
|
||||
data: (term, page) ->
|
||||
q: term
|
||||
distributor_id: $("#order_distributor_id").val()
|
||||
order_cycle_id: $("#order_order_cycle_id").val()
|
||||
|
||||
results: (data, page) ->
|
||||
results: data
|
||||
|
||||
formatResult: formatVariantResult
|
||||
formatSelection: (variant) ->
|
||||
$(@element).parent().children(".options_placeholder").html variant.options_text
|
||||
variant.name
|
||||
@@ -1,4 +1,4 @@
|
||||
Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http)->
|
||||
Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http, $window)->
|
||||
# Handles syncing of current cart/order state to server
|
||||
new class Cart
|
||||
dirty: false
|
||||
@@ -10,12 +10,34 @@ Darkswarm.factory 'Cart', (CurrentOrder, Variants, $timeout, $http)->
|
||||
Variants.register line_item.variant
|
||||
|
||||
orderChanged: =>
|
||||
@dirty = true
|
||||
@unsaved()
|
||||
$window.onBeforeUnload
|
||||
if @promise
|
||||
$timeout.cancel(@promise)
|
||||
@promise = $timeout @update, 1000
|
||||
|
||||
update: =>
|
||||
console.log "updating the order"
|
||||
console.log @data()
|
||||
$http.post('/orders/populate', @data()).success (data, status)=>
|
||||
@saved()
|
||||
.error (response, status)=>
|
||||
console.log "What do we do on error?"
|
||||
|
||||
data: =>
|
||||
variants = {}
|
||||
for li in @line_items_present()
|
||||
variants[li.variant.id] = li.quantity
|
||||
{variants: variants}
|
||||
|
||||
|
||||
saved: =>
|
||||
@dirty = false
|
||||
#$window.onBeforeUnload = null
|
||||
|
||||
unsaved: =>
|
||||
@dirty = true
|
||||
window.onBeforeUnload = ->
|
||||
"Your order hasn't been saved yet! Are you sure you want to leave this page?"
|
||||
|
||||
line_items_present: =>
|
||||
@line_items.filter (li)->
|
||||
|
||||
@@ -1,78 +0,0 @@
|
||||
$(document).ready ->
|
||||
setup_background()
|
||||
setup_offcanvas_panel()
|
||||
setup_login_handlers()
|
||||
setup_suburbs_autocomplete()
|
||||
|
||||
setup_background = ->
|
||||
if $("#image-url-container").length > 0
|
||||
$('body').css('background-color', 'black', 'important');
|
||||
$.backstretch($("#image-url-container").attr("data-url"));
|
||||
|
||||
|
||||
setup_offcanvas_panel = ->
|
||||
events = 'click.fndtn'
|
||||
$("#sidebarLoginButton").on events, (e) ->
|
||||
e.preventDefault()
|
||||
if $("#sign-up-content").is(':visible') && $("body").hasClass("active")
|
||||
$("#login-content").show()
|
||||
$("#sign-up-content").hide()
|
||||
else if $("body").hasClass("active")
|
||||
$("body").toggleClass "active"
|
||||
$("#login-content").hide(400)
|
||||
$("#sign-up-content").hide(400)
|
||||
else
|
||||
$("body").toggleClass "active"
|
||||
$("#login-content").show()
|
||||
$("#sign-up-content").hide()
|
||||
|
||||
$("#sidebarSignUpButton").on events, (e) ->
|
||||
e.preventDefault()
|
||||
if $("#login-content").is(':visible') && $("body").hasClass("active")
|
||||
$("#login-content").hide()
|
||||
$("#sign-up-content").show()
|
||||
else if $("body").hasClass("active")
|
||||
$("body").toggleClass "active"
|
||||
$("#login-content").hide(400)
|
||||
$("#sign-up-content").hide(400)
|
||||
else
|
||||
$("body").toggleClass "active"
|
||||
$("#login-content").hide()
|
||||
$("#sign-up-content").show()
|
||||
|
||||
|
||||
setup_login_handlers = ->
|
||||
$("#new_spree_user").on "ajax:error", (event, xhr, status) ->
|
||||
$("#login-error-alert").show()
|
||||
|
||||
$("#new_spree_user").on "ajax:success", (event, xhr, status) ->
|
||||
$("#login-error-alert").hide()
|
||||
$("#login-name").html("<a href='#'>#{xhr['email']}</a>")
|
||||
|
||||
$("#login-link").hide()
|
||||
$("#sign-up-link").hide()
|
||||
|
||||
$("#login-name").show()
|
||||
$("#sign-out-link").show()
|
||||
|
||||
$("#sidebarLoginButton").trigger("click")
|
||||
|
||||
setup_suburbs_autocomplete = ->
|
||||
spinner = new Spinner({length: 10, width: 10, color: '#000'})
|
||||
|
||||
$("#suburb_search").autocomplete
|
||||
source: $('#suburb_search').data('autocomplete-source')
|
||||
minLength: 3
|
||||
delay: 500
|
||||
search: (event, ui) ->
|
||||
$("#suburb_search").after($(spinner.spin().el).css("left", "93%").css("margin-top": "35px"))
|
||||
response: (event, ui) ->
|
||||
spinner.stop()
|
||||
select: (event, ui) ->
|
||||
$("#suburb_id").val(ui.item.id)
|
||||
messages:
|
||||
noResults: ""
|
||||
results: ->
|
||||
|
||||
$("#suburb_search").change ->
|
||||
$("#suburb_id").val('')
|
||||
@@ -95,48 +95,215 @@
|
||||
|
||||
|
||||
product:hover, product:focus, product:active
|
||||
border-color: $clr-brick
|
||||
@include box-shadow(0 0 3px 0 $clr-brick-bright)
|
||||
// border-color: $clr-brick
|
||||
// @include box-shadow(0 0 3px 0 $clr-brick-bright)
|
||||
|
||||
.row.variants
|
||||
border-top: 1px solid $clr-brick-light
|
||||
background: $clr-brick-ultra-light
|
||||
// border-top: 1px solid $clr-brick-light
|
||||
// background: $clr-brick-ultra-light
|
||||
|
||||
product
|
||||
border: 1px solid #989898
|
||||
display: block
|
||||
margin-bottom: 1em !important
|
||||
border-bottom: 1px solid #e5e5e5
|
||||
border-top: 1px solid #e5e5e5
|
||||
padding-bottom: 1px
|
||||
margin-bottom: 20px !important
|
||||
position: relative
|
||||
display: block
|
||||
color: #444
|
||||
|
||||
.product-thumb
|
||||
position: absolute
|
||||
top: 3px
|
||||
left: 0px
|
||||
width: 7rem
|
||||
height: 7rem
|
||||
outline: 1px solid black
|
||||
float: left
|
||||
display: block
|
||||
z-index: 999999
|
||||
background-color: black
|
||||
overflow: hidden
|
||||
|
||||
@media all and (max-width: 768px)
|
||||
width: 4rem
|
||||
height: 4rem
|
||||
|
||||
// Variant name
|
||||
.variant-name, .summary-header
|
||||
text-transform: capitalize
|
||||
padding-left: 7.9375rem
|
||||
|
||||
@media all and (max-width: 768px)
|
||||
padding-left: 4.9375rem
|
||||
|
||||
.variant-name
|
||||
@media all and (max-width: 480px)
|
||||
padding-left: 0.9375rem
|
||||
font-weight: bold
|
||||
.table-cell
|
||||
height: 24px
|
||||
|
||||
// Variant unit
|
||||
.variant-unit
|
||||
padding-left: 0rem
|
||||
padding-right: 0rem
|
||||
color: #888
|
||||
font-size: 0.875rem
|
||||
overflow: hidden
|
||||
|
||||
@media all and (max-width: 768px)
|
||||
font-size: 0.75rem
|
||||
|
||||
// Variant price
|
||||
.variant-price
|
||||
padding-left: 0.25rem
|
||||
padding-right: 0rem
|
||||
|
||||
// Total price
|
||||
.total-price
|
||||
padding-left: 0rem
|
||||
|
||||
.taxon-flag
|
||||
background: transparent url("/assets/flag.svg") top center no-repeat
|
||||
background-size: 34px 38px
|
||||
min-height: 40px
|
||||
margin-top: -1.1rem
|
||||
padding-top: 0.25rem
|
||||
z-index: 999999
|
||||
|
||||
@media all and (max-width: 768px)
|
||||
margin-top: -0.85rem
|
||||
|
||||
render-svg
|
||||
svg
|
||||
width: 24px
|
||||
height: 24px
|
||||
path
|
||||
fill: #999
|
||||
|
||||
input
|
||||
@include csstrans
|
||||
margin: 0
|
||||
width: 8em
|
||||
width: 10rem
|
||||
display: inline
|
||||
@include box-shadow(none)
|
||||
border-color: #b3b3b3
|
||||
text-align: right
|
||||
|
||||
@media all and (max-width: 768px)
|
||||
width: 8rem
|
||||
|
||||
@media all and (max-width: 640px)
|
||||
font-size: 0.75rem
|
||||
padding-left: 0.25rem
|
||||
padding-right: 0.25rem
|
||||
|
||||
@media all and (max-width: 480px)
|
||||
float: left !important
|
||||
width: 5.8rem
|
||||
|
||||
&:hover
|
||||
@include box-shadow(none)
|
||||
border-color: #888
|
||||
background-color: #fafafa
|
||||
|
||||
&:active, &:focus, &.active
|
||||
@include box-shadow(none)
|
||||
background-color: #f9f4b9
|
||||
border-color: #666
|
||||
|
||||
// BULK
|
||||
span.bulk-input-container
|
||||
float: right
|
||||
|
||||
@media all and (max-width: 480px)
|
||||
float: left !important
|
||||
|
||||
.bulk-input
|
||||
float: left
|
||||
|
||||
input.bulk
|
||||
width: 5rem
|
||||
|
||||
@media all and (max-width: 768px)
|
||||
width: 4rem
|
||||
|
||||
@media all and (max-width: 480px)
|
||||
width: 2.9rem
|
||||
|
||||
input.bulk.first
|
||||
border-right: 0
|
||||
|
||||
input.bulk.second
|
||||
border-left: 0
|
||||
|
||||
.bulk-buy
|
||||
font-size: 0.875rem
|
||||
@media all and (max-width: 768px)
|
||||
font-size: 0.75rem
|
||||
|
||||
.bulk-buy, .bulk-buy i
|
||||
color: #888
|
||||
|
||||
|
||||
.inline
|
||||
display: inline
|
||||
|
||||
|
||||
// ICONS
|
||||
i
|
||||
font-size: 0.75em
|
||||
padding-right: 0.9375rem
|
||||
|
||||
i.ofn-i_056-bulk, i.ofn-i_036-producers
|
||||
font-size: 1rem
|
||||
padding-right: 0rem
|
||||
|
||||
i.ofn-i_036-producers
|
||||
padding-left: 0.5rem
|
||||
|
||||
.columns
|
||||
padding-top: 1em
|
||||
padding-bottom: 1em
|
||||
line-height: 1em
|
||||
padding-top: 0em
|
||||
padding-bottom: 0em
|
||||
display: table
|
||||
line-height: 1.1
|
||||
// outline: 1px solid red
|
||||
|
||||
@media all and (max-width: 640px)
|
||||
font-size: 0.75rem
|
||||
|
||||
.table-cell
|
||||
display: table-cell
|
||||
vertical-align: middle
|
||||
height: 37px
|
||||
|
||||
.row.summary, .row.variants
|
||||
margin-left: 0
|
||||
margin-right: 0
|
||||
background: #f7f7f7
|
||||
border-top: 1px solid #dfdfdf
|
||||
|
||||
.row.summary
|
||||
background: #fff
|
||||
line-height: 1
|
||||
|
||||
.summary-header
|
||||
font-size: 1.15rem
|
||||
// ROW VARIANTS
|
||||
.row.variants
|
||||
background: url("/assets/gray_jean.png") top left repeat
|
||||
|
||||
&, & *
|
||||
@include avenir
|
||||
color: $clr-brick
|
||||
&:nth-of-type(even)
|
||||
background: url("/assets/gray_jean_light.png") top left repeat
|
||||
|
||||
// ROW SUMMARY
|
||||
.row.summary
|
||||
.columns
|
||||
padding-top: 1em
|
||||
padding-bottom: 1em
|
||||
line-height: 1
|
||||
|
||||
@media all and (max-width: 768px)
|
||||
padding-top: 0.65rem
|
||||
padding-bottom: 0.65rem
|
||||
|
||||
h3
|
||||
font-size: 1.5rem
|
||||
margin: 0
|
||||
|
||||
.summary-price
|
||||
&, & *
|
||||
@include avenir
|
||||
|
||||
|
||||
|
||||
|
||||
@@ -69,24 +69,4 @@ class EnterprisesController < BaseController
|
||||
|
||||
redirect_to main_app.shop_path
|
||||
end
|
||||
|
||||
# essentially the new 'show' action that renders non-spree view
|
||||
# will need to be renamed into show once the old one is removed
|
||||
def shop_front
|
||||
options = {:enterprise_id => params[:id]}
|
||||
options.merge(params.reject { |k,v| k == :id })
|
||||
|
||||
@enterprise = Enterprise.find params[:id]
|
||||
|
||||
@searcher = Spree::Config.searcher_class.new(options)
|
||||
@products = @searcher.retrieve_products
|
||||
render :layout => "landing_page"
|
||||
end
|
||||
|
||||
def search
|
||||
@suburb = Suburb.find(params[:suburb_id]) if params[:suburb_id].present?
|
||||
@enterprises = Enterprise.find_near(@suburb)
|
||||
@enterprises_json = @enterprises.to_gmaps4rails
|
||||
render :layout => "landing_page"
|
||||
end
|
||||
end
|
||||
|
||||
@@ -1,6 +1,22 @@
|
||||
Spree::Admin::VariantsController.class_eval do
|
||||
helper 'spree/products'
|
||||
|
||||
def search
|
||||
search_params = { :product_name_cont => params[:q], :sku_cont => params[:q] }
|
||||
|
||||
@variants = Spree::Variant.ransack(search_params.merge(:m => 'or')).result
|
||||
|
||||
if params[:distributor_id].present?
|
||||
distributor = Enterprise.find params[:distributor_id]
|
||||
@variants = @variants.in_distributor(distributor)
|
||||
end
|
||||
|
||||
if params[:order_cycle_id].present?
|
||||
order_cycle = OrderCycle.find params[:order_cycle_id]
|
||||
@variants = @variants.in_order_cycle(order_cycle)
|
||||
end
|
||||
end
|
||||
|
||||
def destroy
|
||||
@variant = Spree::Variant.find(params[:id])
|
||||
@variant.delete # This line changed, as well as removal of following conditional
|
||||
|
||||
@@ -1,5 +0,0 @@
|
||||
class SuburbsController < ActionController::Base
|
||||
def index
|
||||
@suburbs = Suburb.matching(params[:term]).order(:name).limit(8)
|
||||
end
|
||||
end
|
||||
@@ -1,11 +0,0 @@
|
||||
module TempLandingPageHelper
|
||||
def temp_landing_page_distributor_link_class(distributor)
|
||||
cart = current_order(true)
|
||||
@active_distributors ||= Enterprise.distributors_with_active_order_cycles
|
||||
|
||||
klass = "shop-distributor"
|
||||
klass += " empties-cart" unless cart.line_items.empty? || cart.distributor == distributor
|
||||
klass += @active_distributors.include?(distributor) ? ' active' : ' inactive'
|
||||
klass
|
||||
end
|
||||
end
|
||||
@@ -22,8 +22,23 @@ class Enterprise < ActiveRecord::Base
|
||||
accepts_nested_attributes_for :address
|
||||
accepts_nested_attributes_for :producer_properties, allow_destroy: true, reject_if: lambda { |pp| pp[:property_name].blank? }
|
||||
|
||||
has_attached_file :logo, :styles => { :medium => "300x300>", small: "180x180>", :thumb => "100x100>" }
|
||||
has_attached_file :promo_image, :styles => { :large => "1200x260#", :thumb => "100x100>" }
|
||||
has_attached_file :logo,
|
||||
styles: { medium: "300x300>", small: "180x180>", thumb: "100x100>" },
|
||||
url: '/images/enterprises/logos/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprises/logos/:id/:style/:basename.:extension'
|
||||
|
||||
has_attached_file :promo_image,
|
||||
styles: { large: "1200x260#", thumb: "100x100>" },
|
||||
url: '/images/enterprises/promo_images/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprises/promo_images/:id/:style/:basename.:extension'
|
||||
|
||||
validates_attachment_content_type :logo, :content_type => /\Aimage\/.*\Z/
|
||||
validates_attachment_content_type :promo_image, :content_type => /\Aimage\/.*\Z/
|
||||
|
||||
include Spree::Core::S3Support
|
||||
supports_s3 :logo
|
||||
supports_s3 :promo_image
|
||||
|
||||
|
||||
validates_presence_of :name
|
||||
validates_presence_of :address
|
||||
|
||||
@@ -7,14 +7,24 @@ class EnterpriseGroup < ActiveRecord::Base
|
||||
validates :description, presence: true
|
||||
|
||||
attr_accessible :name, :description, :long_description, :on_front_page, :enterprise_ids
|
||||
attr_accessible :logo, :promo_image
|
||||
|
||||
attr_accessible :promo_image
|
||||
has_attached_file :promo_image, styles: {large: "1200x260#"}
|
||||
has_attached_file :logo,
|
||||
styles: {medium: "100x100"},
|
||||
url: '/images/enterprise_groups/logos/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprise_groups/logos/:id/:style/:basename.:extension'
|
||||
|
||||
has_attached_file :promo_image,
|
||||
styles: {large: "1200x260#"},
|
||||
url: '/images/enterprise_groups/promo_images/:id/:style/:basename.:extension',
|
||||
path: 'public/images/enterprise_groups/promo_images/:id/:style/:basename.:extension'
|
||||
|
||||
validates_attachment_content_type :logo, :content_type => /\Aimage\/.*\Z/
|
||||
validates_attachment_content_type :promo_image, :content_type => /\Aimage\/.*\Z/
|
||||
|
||||
attr_accessible :logo
|
||||
has_attached_file :logo, styles: {medium: "100x100"}
|
||||
validates_attachment_content_type :logo, :content_type => /\Aimage\/.*\Z/
|
||||
include Spree::Core::S3Support
|
||||
supports_s3 :logo
|
||||
supports_s3 :promo_image
|
||||
|
||||
scope :by_position, order('position ASC')
|
||||
scope :on_front_page, where(on_front_page: true)
|
||||
|
||||
@@ -1,11 +0,0 @@
|
||||
class LandingPageImage < ActiveRecord::Base
|
||||
attr_accessible :photo
|
||||
has_attached_file :photo, styles: { max_common_res: ["1920x1080#", :jpg] },
|
||||
:convert_options => { max_common_res: "-quality 25" }
|
||||
|
||||
validates_attachment_presence :photo
|
||||
|
||||
def self.random
|
||||
offset(rand(LandingPageImage.count)).first
|
||||
end
|
||||
end
|
||||
@@ -1,4 +1,8 @@
|
||||
Spree::Taxon.class_eval do
|
||||
self.attachment_definitions[:icon][:path] = 'public/images/spree/taxons/:id/:style/:basename.:extension'
|
||||
self.attachment_definitions[:icon][:url] = '/images/spree/taxons/:id/:style/:basename.:extension'
|
||||
|
||||
|
||||
# Indicate which filters should be used for this taxon
|
||||
def applicable_filters
|
||||
fs = []
|
||||
|
||||
@@ -18,8 +18,25 @@ Spree::Variant.class_eval do
|
||||
before_validation :update_weight_from_unit_value
|
||||
after_save :update_units
|
||||
|
||||
scope :with_order_cycles_inner, joins(exchanges: :order_cycle)
|
||||
scope :with_order_cycles_outer, joins('LEFT OUTER JOIN exchange_variants AS o_exchange_variants ON (o_exchange_variants.variant_id = spree_variants.id)').
|
||||
joins('LEFT OUTER JOIN exchanges AS o_exchanges ON (o_exchanges.id = o_exchange_variants.exchange_id)').
|
||||
joins('LEFT OUTER JOIN order_cycles AS o_order_cycles ON (o_order_cycles.id = o_exchanges.order_cycle_id)')
|
||||
|
||||
scope :not_deleted, where(deleted_at: nil)
|
||||
scope :in_stock, where('spree_variants.count_on_hand > 0 OR spree_variants.on_demand=?', true)
|
||||
scope :in_distributor, lambda { |distributor|
|
||||
with_order_cycles_outer.
|
||||
where('o_exchanges.incoming = ? AND o_exchanges.receiver_id = ?', false, distributor).
|
||||
select('DISTINCT spree_variants.*')
|
||||
}
|
||||
|
||||
scope :in_order_cycle, lambda { |order_cycle|
|
||||
with_order_cycles_inner.
|
||||
merge(Exchange.outgoing).
|
||||
where('order_cycles.id = ?', order_cycle).
|
||||
select('DISTINCT spree_variants.*')
|
||||
}
|
||||
|
||||
|
||||
def price_with_fees(distributor, order_cycle)
|
||||
|
||||
@@ -8,10 +8,12 @@
|
||||
%p
|
||||
%b Distributor:
|
||||
= f.object.distributor.andand.name || "None"
|
||||
= f.hidden_field :distributor_id
|
||||
.omega.six.columns
|
||||
%p
|
||||
%b Order cycle:
|
||||
= f.object.order_cycle.andand.name || "None"
|
||||
= f.hidden_field :order_cycle_id
|
||||
|
||||
- else
|
||||
.alpha.six.columns
|
||||
|
||||
@@ -1,23 +0,0 @@
|
||||
- if @enterprises.any?
|
||||
.row.full-width
|
||||
.large-4.columns
|
||||
- if @suburb.present?
|
||||
.row.search-result.with-separator
|
||||
.large-12.columns
|
||||
You have searched at:
|
||||
%strong
|
||||
%div= "#{@suburb.name}, #{@suburb.state_name}"
|
||||
- @enterprises.each do |enterprise|
|
||||
.row.search-result.with-separator
|
||||
.large-12.columns
|
||||
= link_to enterprise.name, shop_front_enterprise_path(enterprise.id)
|
||||
%span.secondary-info= "#{enterprise.city}, #{enterprise.state_name}"
|
||||
.large-8.columns
|
||||
= gmaps4rails(@enterprises_json)
|
||||
|
||||
- else
|
||||
.row.search-result
|
||||
.large-12.large-centered.columns
|
||||
.centered
|
||||
= "Nothing foud that matches your search criteria"
|
||||
= link_to "Try again...", new_landing_page_path
|
||||
@@ -1,27 +0,0 @@
|
||||
%span#image-url-container.hide{ "data-url" => "#{LandingPageImage.random.photo.url(:max_common_res)}" }
|
||||
|
||||
.row
|
||||
.large-10.large-centered.columns
|
||||
#postcode_select_box
|
||||
.row
|
||||
.large-12.columns
|
||||
#logo-container= image_tag "ofn_logo.png"
|
||||
.row
|
||||
= form_tag search_enterprises_path do
|
||||
.large-10.columns
|
||||
= text_field_tag :suburb_search, "",
|
||||
data: { autocomplete_source: suburbs_path }, class: "right", placeholder: "Enter your suburb or postcode...",
|
||||
html: { method: :post }
|
||||
= hidden_field_tag :suburb_id
|
||||
.large-2.columns
|
||||
= submit_tag "Search", class: "button-huge"
|
||||
.row
|
||||
.large-12.large-centered.columns
|
||||
= link_to about_us_path do
|
||||
%strong
|
||||
%i What is open food network?
|
||||
.row.show-for-small
|
||||
.large-12.large-centered.columns#home-page-nav
|
||||
%ul
|
||||
%li= link_to "DISTRIBUTORS", "#", :data => { "reveal-id" => "become-distributor" }
|
||||
%li= link_to "FARMERS", "#", :data => { "reveal-id" => "become-farmer" }
|
||||
@@ -1,66 +0,0 @@
|
||||
!!!
|
||||
%html
|
||||
%head
|
||||
%meta{charset: 'utf-8'}/
|
||||
%meta{name: 'viewport', content: "width=device-width,initial-scale=1.0"}/
|
||||
|
||||
%title Welcome to Open Food Network
|
||||
= favicon_link_tag "favicon.png"
|
||||
= stylesheet_link_tag "search/all"
|
||||
= javascript_include_tag "search/all"
|
||||
= javascript_include_tag "store/shop_front"
|
||||
= render "layouts/bugherd_script"
|
||||
|
||||
= csrf_meta_tags
|
||||
%body
|
||||
%nav.top-bar
|
||||
%section.top-bar-section
|
||||
%ul.left
|
||||
%li= link_to image_tag("ofn_logo_small.png"), new_landing_page_path
|
||||
%li.divider
|
||||
- if spree_current_user.nil?
|
||||
%li#login-link= link_to "Login", "#sidebar", id: "sidebarLoginButton", class: "sidebar-button"
|
||||
%li#login-name.hide
|
||||
%li.divider
|
||||
%li#sign-up-link= link_to "Sign Up", "#sidebar", id: "sidebarSignUpButton", class: "sidebar-button"
|
||||
%li#sign-out-link.hide= link_to "Sign Out", "/logout"
|
||||
- else
|
||||
%li#login-link.hide= link_to "Login", "#sidebar", id: "sidebarLoginButton", class: "sidebar-button"
|
||||
%li#login-name= link_to "#{spree_current_user.email}", "#"
|
||||
%li.divider
|
||||
%li#sign-up-link.hide= link_to "Sign Up", "#"
|
||||
%li#sign-out-link= link_to "Sign Out", "/logout"
|
||||
|
||||
%section{ role: "main" }
|
||||
.row.landing-page-row.with-bottom-border
|
||||
.large-12.columns.centered
|
||||
= image_tag "ofn_logo_black.png"
|
||||
.row.landing-page-row.with-bottom-border.with-pin-bg
|
||||
.large-12.columns.centered
|
||||
%h3 WHERE WOULD YOU LIKE TO SHOP?
|
||||
%p.secondary Select your hub from the list below
|
||||
- if Rails.env.development? || Rails.env.staging?
|
||||
.large-12.columns.centered
|
||||
#environment= Rails.env.capitalize
|
||||
|
||||
- @groups.in_groups_of(4, false) do |row|
|
||||
.row.landing-page-row.hub_group{:class => (row.last == @groups.last ? "with-bottom-border" : "")}
|
||||
- row.each do |group|
|
||||
.large-3.columns
|
||||
.group-header
|
||||
%h5= group.name.upcase
|
||||
- group.enterprises.is_distributor.by_name.each do |distributor|
|
||||
.row.distributor-link-row
|
||||
.large-12.columns
|
||||
= render partial: "shared/distributor", object: distributor
|
||||
|
||||
= render partial: "shared/footer"
|
||||
|
||||
|
||||
|
||||
%section#sidebar{ role: "complementary" }
|
||||
.login-panel
|
||||
#login-content.hide
|
||||
= render "home/login"
|
||||
#sign-up-content.hide
|
||||
= render "home/signup"
|
||||
@@ -1,52 +0,0 @@
|
||||
!!!
|
||||
%html
|
||||
%head
|
||||
%meta{charset: 'utf-8'}/
|
||||
%meta{name: 'viewport', content: "width=device-width,initial-scale=1.0"}/
|
||||
|
||||
%title= content_for?(:title) ? yield(:title) : 'Welcome to Open Food Network'
|
||||
= favicon_link_tag "favicon.png"
|
||||
= stylesheet_link_tag "search/all"
|
||||
= javascript_include_tag "search/all"
|
||||
= render "layouts/bugherd_script"
|
||||
|
||||
= csrf_meta_tags
|
||||
%body.off-canvas
|
||||
= render "layouts/become_distributor"
|
||||
= render "layouts/become_farmer"
|
||||
|
||||
%nav.top-bar
|
||||
%section.top-bar-section
|
||||
%ul.left
|
||||
%li= link_to image_tag("ofn_logo_small.png"), new_landing_page_path
|
||||
%li.divider
|
||||
- if spree_current_user.nil?
|
||||
%li#login-link= link_to "Login", "#sidebar", id: "sidebarLoginButton", class: "sidebar-button"
|
||||
%li#login-name.hide
|
||||
%li.divider
|
||||
%li#sign-up-link= link_to "Sign Up", "#sidebar", id: "sidebarSignUpButton", class: "sidebar-button"
|
||||
%li#sign-out-link.hide= link_to "Sign Out", "/logout"
|
||||
- else
|
||||
%li#login-link.hide= link_to "Login", "#sidebar", id: "sidebarLoginButton", class: "sidebar-button"
|
||||
%li#login-name= link_to "#{spree_current_user.email}", "#"
|
||||
%li.divider
|
||||
%li#sign-up-link.hide= link_to "Sign Up", "#"
|
||||
%li#sign-out-link= link_to "Sign Out", "/logout"
|
||||
|
||||
%ul.right
|
||||
%li= link_to "Distributors", "#", :data => { "reveal-id" => "become-distributor" }
|
||||
%li.divider
|
||||
%li= link_to "Farmers", "#", :data => { "reveal-id" => "become-farmer" }
|
||||
|
||||
%section{ role: "main" }
|
||||
= yield
|
||||
|
||||
%section#sidebar{ role: "complementary" }
|
||||
.login-panel
|
||||
#login-content.hide
|
||||
= render "home/login"
|
||||
#sign-up-content.hide
|
||||
= render "home/signup"
|
||||
|
||||
= yield :scripts
|
||||
|
||||
@@ -13,15 +13,20 @@
|
||||
= render partial: "shop/products/filters"
|
||||
|
||||
.small-12.medium-4.large-4.columns
|
||||
%input.button.primary.right{type: :submit, value: "Add to Cart"}
|
||||
%input.button.primary.right{type: :submit, value: "Checkout now"}
|
||||
|
||||
%div.pad-top{bindonce: true}
|
||||
%product.animate-repeat{"ng-controller" => "ProductNodeCtrl",
|
||||
"ng-repeat" => "product in filteredProducts = (Products.products | products:query | taxons:activeTaxons | orderBy:ordering.order) track by product.id "}
|
||||
%div
|
||||
= render partial: "shop/products/summary"
|
||||
%div{"bo-if" => "product.hasVariants"}
|
||||
= render partial: "shop/products/variants"
|
||||
.product-thumb
|
||||
%a{"ng-click" => "triggerProductModal()"}
|
||||
%img{"bo-src" => "product.master.images[0].small_url", "ng-click" => "triggerProductModal()"}
|
||||
|
||||
= render partial: "shop/products/summary"
|
||||
|
||||
%span{"bo-if" => "product.hasVariants"}
|
||||
= render partial: "shop/products/variants"
|
||||
|
||||
.variants.row{"bo-if" => "!product.hasVariants"}
|
||||
= render partial: "shop/products/master"
|
||||
|
||||
@@ -39,5 +44,5 @@
|
||||
Try another search?
|
||||
.row
|
||||
.small-12.columns
|
||||
%input.button.primary.right.add_to_cart{type: :submit, value: "Add to Cart"}
|
||||
%input.button.primary.right.add_to_cart{type: :submit, value: "Checkout now"}
|
||||
|
||||
|
||||
@@ -1,12 +1,13 @@
|
||||
.small-1.columns
|
||||
%i.ofn-i_056-bulk{"bo-if" => "product.group_buy"}
|
||||
|
||||
|
||||
.small-4.columns
|
||||
{{ product.master.name_to_display }}
|
||||
.small-12.medium-4.large-4.columns.variant-name
|
||||
.table-cell
|
||||
.inline {{ product.master.name_to_display }}
|
||||
.bulk-buy.inline{"bo-if" => "product.group_buy"}
|
||||
%i.ofn-i_056-bulk><
|
||||
%em><
|
||||
\ Bulk
|
||||
|
||||
-# WITHOUT GROUP BUY
|
||||
.small-5.columns{"bo-if" => "!product.group_buy"}
|
||||
.small-4.medium-3.large-3.columns.text-right{"bo-if" => "!product.group_buy"}
|
||||
%input{type: :number,
|
||||
min: 0,
|
||||
placeholder: "0",
|
||||
@@ -15,29 +16,39 @@
|
||||
name: "variants[{{product.master.id}}]",
|
||||
"ng-model" => "product.master.line_item.quantity",
|
||||
id: "variants_{{product.master.id}}"}
|
||||
%small x {{ product.master.unit_to_display }}
|
||||
|
||||
-# WITH GROUP BUY
|
||||
.small-2.columns{"bo-if" => "product.group_buy"}
|
||||
%input{type: :number,
|
||||
min: 0,
|
||||
placeholder: "min",
|
||||
"ofn-disable-scroll" => true,
|
||||
max: "{{product.on_demand && 9999 || product.count_on_hand }}",
|
||||
name: "variants[{{product.master.id}}]",
|
||||
"ng-model" => "product.master.line_item.quantity",
|
||||
id: "variants_{{product.master.id}}"}
|
||||
.small-4.medium-3.large-3.columns.text-right{"bo-if" => "product.group_buy"}
|
||||
%span.bulk-input-container
|
||||
%span.bulk-input
|
||||
%input.bulk.first{type: :number,
|
||||
min: 0,
|
||||
"ng-model" => "product.master.line_item.quantity",
|
||||
placeholder: "min",
|
||||
"ofn-disable-scroll" => true,
|
||||
max: "{{product.on_demand && 9999 || product.count_on_hand }}",
|
||||
name: "variants[{{product.master.id}}]",
|
||||
id: "variants_{{product.master.id}}"}
|
||||
|
||||
.small-3.columns{"bo-if" => "product.group_buy"}
|
||||
%input{type: :number,
|
||||
min: 0,
|
||||
placeholder: "max",
|
||||
"ofn-disable-scroll" => true,
|
||||
max: "{{product.on_demand && 9999 || product.count_on_hand }}",
|
||||
"ng-model" => "product.master.line_item.max_quantity",
|
||||
name: "variant_attributes[{{product.master.id}}][max_quantity]"}
|
||||
%small x {{ product.master.unit_to_display }}
|
||||
%span.bulk-input{"bo-if" => "product.group_buy"}
|
||||
%input.bulk.second{type: :number,
|
||||
min: 0,
|
||||
"ng-model" => "product.master.line_item.max_quantity",
|
||||
placeholder: "max",
|
||||
"ofn-disable-scroll" => true,
|
||||
max: "{{product.on_demand && 9999 || product.count_on_hand }}",
|
||||
name: "variant_attributes[{{product.master.id}}][max_quantity]"}
|
||||
|
||||
.small-2.columns.text-right
|
||||
{{ product.master.price | currency }} x {{ product.master.line_item.quantity }} =
|
||||
{{ product.master.getPrice() | currency }}
|
||||
.small-2.medium-1.large-1.columns.variant-unit
|
||||
.table-cell
|
||||
%em {{ product.master.unit_to_display }}
|
||||
|
||||
.small-3.medium-2.large-2.columns.variant-price
|
||||
.table-cell
|
||||
%i.ofn-i_009-close
|
||||
{{ product.price | currency }}
|
||||
|
||||
.small-3.medium-2.large-2.columns.total-price.text-right
|
||||
.table-cell
|
||||
%strong
|
||||
{{ product.master.getPrice() | currency }}
|
||||
|
||||
@@ -1,16 +1,13 @@
|
||||
.row.summary
|
||||
.small-1.columns
|
||||
%img{"bo-src" => "product.master.images[0].small_url", "ng-click" => "triggerProductModal()"}
|
||||
.small-10.large-11.columns.summary-header
|
||||
%h3 {{ product.name }}
|
||||
|
||||
.small-4.columns.summary-header
|
||||
%render-svg{path: "{{product.primary_taxon.icon}}"}
|
||||
%a{"ng-click" => "triggerProductModal()"}{{ product.name }}
|
||||
%em from
|
||||
%span
|
||||
%producer-modal
|
||||
%i.ofn-i_036-producers
|
||||
{{ enterprise.name }}
|
||||
|
||||
.small-5.columns
|
||||
%i.ofn-i_036-producers
|
||||
%producer-modal {{ enterprise.name }}
|
||||
|
||||
.small-2.columns.summary-price.text-right.price
|
||||
%span{"ng-if" => "product.hasVariants"}
|
||||
%em from
|
||||
{{ product.price | currency }}
|
||||
.small-2.large-1.columns.text-center
|
||||
.taxon-flag
|
||||
%render-svg{path: "{{product.primary_taxon.icon}}"}
|
||||
@@ -1,46 +1,57 @@
|
||||
.row.variants{bindonce: true,
|
||||
"ng-repeat" => "variant in product.variants track by variant.id"}
|
||||
|
||||
.small-1.columns
|
||||
%i.ofn-i_056-bulk{"bo-if" => "product.group_buy"}
|
||||
|
||||
|
||||
.small-4.columns
|
||||
{{ variant.name_to_display }}
|
||||
.small-12.medium-4.large-4.columns.variant-name
|
||||
.table-cell
|
||||
.inline {{ variant.name_to_display }}
|
||||
.bulk-buy.inline{"bo-if" => "product.group_buy"}
|
||||
%i.ofn-i_056-bulk><
|
||||
%em><
|
||||
\ Bulk
|
||||
|
||||
-# WITHOUT GROUP BUY
|
||||
.small-5.columns{"bo-if" => "!product.group_buy"}
|
||||
.small-4.medium-3.large-3.columns.text-right{"bo-if" => "!product.group_buy"}
|
||||
%input{type: :number,
|
||||
value: nil,
|
||||
min: 0,
|
||||
placeholder: "0",
|
||||
"ofn-disable-scroll" => true,
|
||||
max: "{{variant.on_demand && 9999 || variant.count_on_hand }}",
|
||||
"ng-model" => "variant.line_item.quantity",
|
||||
max: "{{variant.on_demand && 9999 || variant.count_on_hand }}",
|
||||
name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"}
|
||||
%small x {{ variant.unit_to_display }}
|
||||
|
||||
|
||||
-# WITH GROUP BUY
|
||||
.small-2.columns{"bo-if" => "product.group_buy"}
|
||||
%input{type: :number,
|
||||
value: nil,
|
||||
min: 0,
|
||||
placeholder: "min",
|
||||
"ofn-disable-scroll" => true,
|
||||
"ng-model" => "variant.line_item.quantity",
|
||||
max: "{{variant.on_demand && 9999 || variant.count_on_hand }}",
|
||||
name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"}
|
||||
.small-4.medium-3.large-3.columns.text-right{"bo-if" => "product.group_buy"}
|
||||
%span.bulk-input-container
|
||||
%span.bulk-input
|
||||
%input.bulk.first{type: :number,
|
||||
value: nil,
|
||||
min: 0,
|
||||
"ng-model" => "variant.line_item.quantity",
|
||||
placeholder: "min",
|
||||
"ofn-disable-scroll" => true,
|
||||
max: "{{variant.on_demand && 9999 || variant.count_on_hand }}",
|
||||
name: "variants[{{variant.id}}]", id: "variants_{{variant.id}}"}
|
||||
%span.bulk-input{"bo-if" => "product.group_buy"}
|
||||
%input.bulk.second{type: :number,
|
||||
min: 0,
|
||||
"ng-model" => "variant.line_item.max_quantity",
|
||||
placeholder: "max",
|
||||
"ofn-disable-scroll" => true,
|
||||
max: "{{variant.on_demand && 9999 || variant.count_on_hand }}",
|
||||
name: "variant_attributes[{{variant.id}}][max_quantity]"}
|
||||
|
||||
.small-3.columns{"bo-if" => "product.group_buy"}
|
||||
%input{type: :number,
|
||||
min: 0,
|
||||
placeholder: "max",
|
||||
"ofn-disable-scroll" => true,
|
||||
"ng-model" => "variant.line_item.max_quantity",
|
||||
max: "{{variant.on_demand && 9999 || variant.count_on_hand }}",
|
||||
name: "variant_attributes[{{variant.id}}][max_quantity]"}
|
||||
%small x {{ variant.unit_to_display }}
|
||||
.small-2.medium-1.large-1.columns.variant-unit
|
||||
.table-cell
|
||||
%em {{ variant.unit_to_display }}
|
||||
|
||||
.small-2.columns.text-right.price
|
||||
{{ variant.price | currency }} x {{ variant.line_item.quantity }} =
|
||||
{{ variant.getPrice() | currency }}
|
||||
.small-3.medium-2.large-2.columns.variant-price
|
||||
.table-cell
|
||||
%i.ofn-i_009-close
|
||||
{{ variant.price | currency }}
|
||||
|
||||
.small-3.medium-2.large-2.columns.total-price.text-right
|
||||
.table-cell
|
||||
%strong
|
||||
{{ variant.getPrice() | currency }}
|
||||
|
||||
@@ -1,3 +0,0 @@
|
||||
collection @suburbs
|
||||
attributes :id
|
||||
node(:label) { |suburb| "#{suburb.name} (#{suburb.state_name}), #{suburb.postcode}" }
|
||||
@@ -1,5 +0,0 @@
|
||||
Bugsnag.configure do |config|
|
||||
config.api_key = "937a200f492fad600b4cc29dddda5f71"
|
||||
config.notify_release_stages = %w(production staging)
|
||||
config.use_ssl = true
|
||||
end
|
||||
@@ -1,6 +1,6 @@
|
||||
DB2Fog.config = {
|
||||
:aws_access_key_id => Spree::Config[:s3_access_key],
|
||||
:aws_secret_access_key => Spree::Config[:s3_secret],
|
||||
:directory => Spree::Config[:s3_bucket],
|
||||
:directory => "db-backup_#{Spree::Config[:s3_bucket]}",
|
||||
:provider => 'AWS'
|
||||
}
|
||||
|
||||
@@ -31,8 +31,6 @@ Openfoodnetwork::Application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
resources :suburbs
|
||||
|
||||
namespace :admin do
|
||||
resources :order_cycles do
|
||||
post :bulk_update, :on => :collection, :as => :bulk_update
|
||||
@@ -70,7 +68,6 @@ Openfoodnetwork::Application.routes.draw do
|
||||
end
|
||||
end
|
||||
|
||||
get "new_landing_page", :controller => 'home', :action => "new_landing_page"
|
||||
get "about_us", :controller => 'home', :action => "about_us"
|
||||
|
||||
namespace :open_food_network do
|
||||
|
||||
@@ -10,3 +10,11 @@ job_type :run_file, "cd :path; :environment_variable=:environment bundle exec sc
|
||||
every 1.day, at: '12:05am' do
|
||||
run_file "lib/open_food_network/integrity_checker.rb"
|
||||
end
|
||||
|
||||
every 1.day, at: '2:45am' do
|
||||
rake 'db2fog:clean'
|
||||
end
|
||||
|
||||
every 4.hours do
|
||||
rake 'db2fog:backup'
|
||||
end
|
||||
|
||||
@@ -0,0 +1,9 @@
|
||||
class ChangeSuburbPostcodeToString < ActiveRecord::Migration
|
||||
def up
|
||||
change_column :suburbs, :postcode, :string
|
||||
end
|
||||
|
||||
def down
|
||||
change_column :suburbs, :postcode, 'integer USING (postcode::integer)'
|
||||
end
|
||||
end
|
||||
16
db/migrate/20140716051214_drop_landing_page_images.rb
Normal file
16
db/migrate/20140716051214_drop_landing_page_images.rb
Normal file
@@ -0,0 +1,16 @@
|
||||
class DropLandingPageImages < ActiveRecord::Migration
|
||||
def up
|
||||
drop_table :landing_page_images
|
||||
end
|
||||
|
||||
def down
|
||||
create_table :landing_page_images do |t|
|
||||
t.string :photo_file_name
|
||||
t.string :photo_content_type
|
||||
t.integer :photo_file_size
|
||||
t.datetime :photo_updated_at
|
||||
|
||||
t.timestamps
|
||||
end
|
||||
end
|
||||
end
|
||||
13
db/schema.rb
13
db/schema.rb
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20140702053145) do
|
||||
ActiveRecord::Schema.define(:version => 20140716051214) do
|
||||
|
||||
create_table "adjustment_metadata", :force => true do |t|
|
||||
t.integer "adjustment_id"
|
||||
@@ -296,15 +296,6 @@ ActiveRecord::Schema.define(:version => 20140702053145) do
|
||||
add_index "exchanges", ["receiver_id"], :name => "index_exchanges_on_receiver_id"
|
||||
add_index "exchanges", ["sender_id"], :name => "index_exchanges_on_sender_id"
|
||||
|
||||
create_table "landing_page_images", :force => true do |t|
|
||||
t.datetime "created_at", :null => false
|
||||
t.datetime "updated_at", :null => false
|
||||
t.string "photo_file_name"
|
||||
t.string "photo_content_type"
|
||||
t.integer "photo_file_size"
|
||||
t.datetime "photo_updated_at"
|
||||
end
|
||||
|
||||
create_table "order_cycles", :force => true do |t|
|
||||
t.string "name"
|
||||
t.datetime "orders_open_at"
|
||||
@@ -1002,7 +993,7 @@ ActiveRecord::Schema.define(:version => 20140702053145) do
|
||||
|
||||
create_table "suburbs", :force => true do |t|
|
||||
t.string "name"
|
||||
t.integer "postcode"
|
||||
t.string "postcode"
|
||||
t.float "latitude"
|
||||
t.float "longitude"
|
||||
t.integer "state_id"
|
||||
|
||||
@@ -27,13 +27,6 @@ unless Spree::State.find_by_name 'Victoria'
|
||||
end
|
||||
end
|
||||
|
||||
# -- Landing page images
|
||||
unless LandingPageImage.find_by_photo_file_name("potatoes.jpg")
|
||||
LandingPageImage.create photo: File.open(File.join(Rails.root, "lib", "seed_data", "carrots.jpg"))
|
||||
LandingPageImage.create photo: File.open(File.join(Rails.root, "lib", "seed_data", "tomatoes.jpg"))
|
||||
LandingPageImage.create photo: File.open(File.join(Rails.root, "lib", "seed_data", "potatoes.jpg"))
|
||||
end
|
||||
|
||||
# -- Seeding suburbs
|
||||
# -- Suburbs
|
||||
require_relative './suburb_seeds'
|
||||
SuburbSeeder.seed_suburbs unless Suburb.find_by_name("Dayton")
|
||||
|
||||
33756
db/suburb_seeds.rb
33756
db/suburb_seeds.rb
File diff suppressed because it is too large
Load Diff
32
lib/tasks/enterprises.rake
Normal file
32
lib/tasks/enterprises.rake
Normal file
@@ -0,0 +1,32 @@
|
||||
require 'csv'
|
||||
|
||||
namespace :openfoodnetwork do
|
||||
namespace :dev do
|
||||
desc 'export enterprises to CSV'
|
||||
task :export_enterprises => :environment do
|
||||
CSV.open('db/enterprises.csv', 'wb') do |csv|
|
||||
csv << enterprise_header
|
||||
enterprises.each do |enterprise|
|
||||
csv << enterprise_row(enterprise)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
|
||||
def enterprises
|
||||
Enterprise.by_name
|
||||
end
|
||||
|
||||
def enterprise_header
|
||||
['name', 'description', 'long_description', 'is_primary_producer', 'is_distributor', 'contact', 'phone', 'email', 'website', 'twitter', 'abn', 'acn', 'pickup_times', 'next_collection_at', 'distributor_info', 'visible', 'facebook', 'instagram', 'linkedin', 'address1', 'address2', 'city', 'zipcode', 'state', 'country']
|
||||
end
|
||||
|
||||
def enterprise_row(enterprise)
|
||||
[enterprise.name, enterprise.description, enterprise.long_description, enterprise.is_primary_producer, enterprise.is_distributor, enterprise.contact, enterprise.phone, enterprise.email, enterprise.website, enterprise.twitter, enterprise.abn, enterprise.acn, enterprise.pickup_times, enterprise.next_collection_at, enterprise.distributor_info, enterprise.visible, enterprise.facebook, enterprise.instagram, enterprise.linkedin, enterprise.address.address1, enterprise.address.address2, enterprise.address.city, enterprise.address.zipcode, enterprise.address.state_name, enterprise.address.country.andand.name]
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
||||
@@ -6,9 +6,9 @@ namespace :openfoodnetwork do
|
||||
desc 'export users to CSV'
|
||||
task export_users: :environment do
|
||||
CSV.open('db/users.csv', 'wb') do |csv|
|
||||
csv << header
|
||||
csv << user_header
|
||||
users.each do |user|
|
||||
csv << row(user)
|
||||
csv << user_row(user)
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -34,7 +34,7 @@ namespace :openfoodnetwork do
|
||||
end
|
||||
|
||||
|
||||
def header
|
||||
def user_header
|
||||
["encrypted_password", "password_salt", "email", "remember_token", "persistence_token", "reset_password_token", "perishable_token", "sign_in_count", "failed_attempts", "last_request_at", "current_sign_in_at", "last_sign_in_at", "current_sign_in_ip", "last_sign_in_ip", "login", "created_at", "updated_at", "authentication_token", "unlock_token", "locked_at", "remember_created_at", "reset_password_sent_at",
|
||||
|
||||
"role_name",
|
||||
@@ -45,7 +45,7 @@ namespace :openfoodnetwork do
|
||||
end
|
||||
|
||||
|
||||
def row(user)
|
||||
def user_row(user)
|
||||
sa = user.orders.last.andand.ship_address
|
||||
ba = user.orders.last.andand.bill_address
|
||||
|
||||
|
||||
4
script/disable_s3.rb
Normal file
4
script/disable_s3.rb
Normal file
@@ -0,0 +1,4 @@
|
||||
#!/usr/bin/env ruby
|
||||
|
||||
Spree::Config.use_s3 = false
|
||||
|
||||
@@ -4,6 +4,32 @@
|
||||
|
||||
set -e
|
||||
|
||||
if hash zeus 2>/dev/null && [ -e .zeus.sock ]; then
|
||||
RAILS_RUN='zeus r'
|
||||
else
|
||||
RAILS_RUN='rails runner'
|
||||
fi
|
||||
|
||||
|
||||
# -- Mirror database
|
||||
echo "Mirroring database..."
|
||||
echo "drop database open_food_network_dev" | psql -h localhost -U ofn open_food_network_test
|
||||
echo "create database open_food_network_dev" | psql -h localhost -U ofn open_food_network_test
|
||||
ssh $1 "pg_dump -h localhost -U openfoodweb openfoodweb_production |gzip" |gunzip |psql -h localhost -U ofn open_food_network_dev
|
||||
|
||||
|
||||
# -- Disable S3
|
||||
echo "Disabling S3 in development..."
|
||||
$RAILS_RUN script/disable_s3.rb
|
||||
|
||||
|
||||
# -- Mirror images
|
||||
if hash aws 2>/dev/null; then
|
||||
echo "Mirroring images..."
|
||||
BUCKET=`echo $1 | sed s/-/_/ | sed "s/\\([0-9]\\)/_\1/" | sed s/prod/production/`
|
||||
aws s3 sync s3://$BUCKET/public public/
|
||||
|
||||
else
|
||||
echo "Please install the AWS CLI tools so that I can copy the images from $1 for you."
|
||||
echo "eg. sudo easy_install awscli"
|
||||
fi
|
||||
|
||||
@@ -2,14 +2,8 @@ require 'spec_helper'
|
||||
|
||||
describe Spree::Admin::ProductsController do
|
||||
context "Creating a new product" do
|
||||
let(:user) do
|
||||
user = create(:user)
|
||||
user.spree_roles << Spree::Role.find_or_create_by_name!('admin')
|
||||
user
|
||||
end
|
||||
|
||||
before do
|
||||
controller.stub spree_current_user: user
|
||||
login_as_admin
|
||||
end
|
||||
|
||||
it "redirects to bulk_edit when the user hits 'create'" do
|
||||
@@ -52,4 +46,4 @@ describe Spree::Admin::ProductsController do
|
||||
response.should redirect_to "/admin/products/new"
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
@@ -56,16 +56,7 @@ describe Spree::Admin::ReportsController do
|
||||
|
||||
# As a Distributor Enterprise user for d1
|
||||
context "Distributor Enterprise User" do
|
||||
let(:user) do
|
||||
user = create(:user)
|
||||
user.spree_roles = []
|
||||
d1.enterprise_roles.build(user: user).save
|
||||
user
|
||||
end
|
||||
|
||||
before :each do
|
||||
controller.stub :spree_current_user => user
|
||||
end
|
||||
before { login_as_enterprise_user [d1] }
|
||||
|
||||
describe 'Orders and Distributors' do
|
||||
it "only shows orders that I have access to" do
|
||||
@@ -117,16 +108,7 @@ describe Spree::Admin::ReportsController do
|
||||
|
||||
# As a Supplier Enterprise user for s1
|
||||
context "Supplier" do
|
||||
let(:user) do
|
||||
user = create(:user)
|
||||
user.spree_roles = []
|
||||
s1.enterprise_roles.build(user: user).save
|
||||
user
|
||||
end
|
||||
|
||||
before :each do
|
||||
controller.stub :spree_current_user => user
|
||||
end
|
||||
before { login_as_enterprise_user [s1] }
|
||||
|
||||
describe 'Bulk Coop' do
|
||||
it "only shows product line items that I am supplying" do
|
||||
@@ -157,14 +139,7 @@ describe Spree::Admin::ReportsController do
|
||||
end
|
||||
|
||||
context "Products & Inventory" do
|
||||
let(:user) do
|
||||
user = create(:user)
|
||||
user.spree_roles << Spree::Role.find_or_create_by_name!('admin')
|
||||
user
|
||||
end
|
||||
before do
|
||||
controller.stub spree_current_user: user
|
||||
end
|
||||
before { login_as_admin }
|
||||
|
||||
it "should build distributors for the current user" do
|
||||
spree_get :products_and_inventory
|
||||
@@ -188,24 +163,17 @@ describe Spree::Admin::ReportsController do
|
||||
|
||||
it "creates a ProductAndInventoryReport" do
|
||||
OpenFoodNetwork::ProductsAndInventoryReport.should_receive(:new)
|
||||
.with(user, {"test"=>"foo", "controller"=>"spree/admin/reports", "action"=>"products_and_inventory"})
|
||||
.and_return(report = double(:report))
|
||||
.with(@admin_user, {"test" => "foo", "controller" => "spree/admin/reports", "action" => "products_and_inventory"})
|
||||
.and_return(report = double(:report))
|
||||
report.stub(:header).and_return []
|
||||
report.stub(:table).and_return []
|
||||
spree_get :products_and_inventory, :test => "foo"
|
||||
spree_get :products_and_inventory, test: "foo"
|
||||
assigns(:report).should == report
|
||||
end
|
||||
end
|
||||
|
||||
context "My Customers" do
|
||||
let(:user) do
|
||||
user = create(:user)
|
||||
user.spree_roles << Spree::Role.find_or_create_by_name!('admin')
|
||||
user
|
||||
end
|
||||
before do
|
||||
controller.stub spree_current_user: user
|
||||
end
|
||||
before { login_as_admin }
|
||||
|
||||
it "should have report types for customers" do
|
||||
Spree::Admin::ReportsController::REPORT_TYPES[:customers].should == [
|
||||
@@ -236,13 +204,12 @@ describe Spree::Admin::ReportsController do
|
||||
|
||||
it "creates a CustomersReport" do
|
||||
OpenFoodNetwork::CustomersReport.should_receive(:new)
|
||||
.with(user, {"test"=>"foo", "controller"=>"spree/admin/reports", "action"=>"customers"})
|
||||
.and_return(report = double(:report))
|
||||
.with(@admin_user, {"test" => "foo", "controller" => "spree/admin/reports", "action" => "customers"})
|
||||
.and_return(report = double(:report))
|
||||
report.stub(:header).and_return []
|
||||
report.stub(:table).and_return []
|
||||
spree_get :customers, :test => "foo"
|
||||
spree_get :customers, test: "foo"
|
||||
assigns(:report).should == report
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
31
spec/controllers/spree/admin/variants_controller_spec.rb
Normal file
31
spec/controllers/spree/admin/variants_controller_spec.rb
Normal file
@@ -0,0 +1,31 @@
|
||||
require 'spec_helper'
|
||||
|
||||
module Spree
|
||||
module Admin
|
||||
describe VariantsController do
|
||||
before { login_as_admin }
|
||||
|
||||
describe "search action" do
|
||||
let!(:p1) { create(:simple_product, name: 'Product 1') }
|
||||
let!(:p2) { create(:simple_product, name: 'Product 2') }
|
||||
let!(:d) { create(:distributor_enterprise) }
|
||||
let!(:oc) { create(:simple_order_cycle, distributors: [d], variants: [p1.master]) }
|
||||
|
||||
it "filters by distributor" do
|
||||
spree_get :search, q: 'Prod', distributor_id: d.id.to_s
|
||||
assigns(:variants).should == [p1.master]
|
||||
end
|
||||
|
||||
it "filters by order cycle" do
|
||||
spree_get :search, q: 'Prod', order_cycle_id: oc.id.to_s
|
||||
assigns(:variants).should == [p1.master]
|
||||
end
|
||||
|
||||
it "does not filter when no distributor or order cycle is specified" do
|
||||
spree_get :search, q: 'Prod'
|
||||
assigns(:variants).sort.should == [p1.master, p2.master].sort
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -140,9 +140,10 @@ FactoryGirl.define do
|
||||
after(:create) { |c| c.set_preference(:per_kg, 0.5); c.save! }
|
||||
end
|
||||
|
||||
factory :order_with_totals_and_distributor, :parent => :order do #possibly called :order_with_line_items in newer Spree
|
||||
# Ensure order has a distributor set
|
||||
factory :order_with_totals_and_distribution, :parent => :order do #possibly called :order_with_line_items in newer Spree
|
||||
distributor { create(:distributor_enterprise) }
|
||||
order_cycle { create(:simple_order_cycle) }
|
||||
|
||||
after(:create) do |order|
|
||||
p = create(:simple_product, :distributors => [order.distributor])
|
||||
FactoryGirl.create(:line_item, :order => order, :product => p)
|
||||
|
||||
@@ -9,7 +9,11 @@ feature %q{
|
||||
|
||||
background do
|
||||
@user = create(:user)
|
||||
@order = create(:order_with_totals_and_distributor, :user => @user, :state => 'complete', :payment_state => 'balance_due')
|
||||
@product = create(:simple_product)
|
||||
@distributor = create(:distributor_enterprise)
|
||||
@order_cycle = create(:simple_order_cycle, distributors: [@distributor], variants: [@product.master])
|
||||
|
||||
@order = create(:order_with_totals_and_distribution, user: @user, distributor: @distributor, order_cycle: @order_cycle, state: 'complete', payment_state: 'balance_due')
|
||||
|
||||
# ensure order has a payment to capture
|
||||
@order.finalize!
|
||||
@@ -43,7 +47,32 @@ feature %q{
|
||||
o.order_cycle.should == order_cycle
|
||||
end
|
||||
|
||||
scenario "can add a product to an existing order", js: true do
|
||||
login_to_admin_section
|
||||
visit '/admin/orders'
|
||||
page.find('td.actions a.icon-edit').click
|
||||
|
||||
targetted_select2_search @product.name, from: ".variant_autocomplete", dropdown_css: ".select2-search"
|
||||
|
||||
click_icon :plus
|
||||
|
||||
page.should have_selector 'td', text: @product.name
|
||||
@order.line_items(true).map(&:product).should include @product
|
||||
end
|
||||
|
||||
scenario "can't add products to an order outside the order's hub and order cycle", js: true do
|
||||
product = create(:simple_product)
|
||||
|
||||
login_to_admin_section
|
||||
visit '/admin/orders'
|
||||
page.find('td.actions a.icon-edit').click
|
||||
|
||||
page.should_not have_select2_option product.name, from: ".variant_autocomplete", dropdown_css: ".select2-search"
|
||||
end
|
||||
|
||||
scenario "can't change distributor or order cycle once order has been finalized" do
|
||||
@order.update_attributes order_cycle_id: nil
|
||||
|
||||
login_to_admin_section
|
||||
visit '/admin/orders'
|
||||
page.find('td.actions a.icon-edit').click
|
||||
@@ -52,7 +81,7 @@ feature %q{
|
||||
page.should have_no_select 'order_order_cycle_id'
|
||||
|
||||
page.should have_selector 'p', text: "Distributor: #{@order.distributor.name}"
|
||||
page.should have_selector 'p', text: 'Order cycle: None'
|
||||
page.should have_selector 'p', text: "Order cycle: None"
|
||||
end
|
||||
|
||||
scenario "capture multiple payments from the orders index page" do
|
||||
|
||||
@@ -1,35 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
feature %q{
|
||||
As a consumer
|
||||
I want to see the landing page
|
||||
So I can login or search
|
||||
}, js: true do
|
||||
|
||||
background do
|
||||
LandingPageImage.create photo: File.open(File.join(Rails.root, "lib", "seed_data", "tomatoes.jpg"))
|
||||
visit new_landing_page_path
|
||||
end
|
||||
|
||||
scenario "viewing the landing page" do
|
||||
page.should have_selector "#suburb_search"
|
||||
end
|
||||
|
||||
# PENDING - we're not using this anymore
|
||||
pending "suburb search" do
|
||||
before(:each) do
|
||||
state_id_vic = Spree::State.where(abbr: "Vic").first.id
|
||||
Suburb.create(name: "Camberwell", postcode: 3124, latitude: -37.824818, longitude: 145.057957, state_id: state_id_vic)
|
||||
end
|
||||
|
||||
it "should auto complete suburbs" do
|
||||
suburb_search_field_id = "suburb_search"
|
||||
fill_in suburb_search_field_id, :with => "Cambe"
|
||||
page.execute_script %Q{ $('##{suburb_search_field_id}').trigger("focus") }
|
||||
page.execute_script %Q{ $('##{suburb_search_field_id}').trigger("keydown") }
|
||||
sleep 1
|
||||
page.should have_content("Camberwell")
|
||||
page.should have_content("3124")
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -1,5 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe TempLandingPageHelper do
|
||||
|
||||
end
|
||||
@@ -1,6 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe LandingPageImage do
|
||||
it { should have_attached_file(:photo) }
|
||||
it { should validate_attachment_presence(:photo) }
|
||||
end
|
||||
@@ -28,6 +28,45 @@ module Spree
|
||||
Variant.where(is_master: false).in_stock.sort.should == [@v_in_stock, @v_on_demand].sort
|
||||
end
|
||||
end
|
||||
|
||||
describe "finding variants in a distributor" do
|
||||
let!(:d1) { create(:distributor_enterprise) }
|
||||
let!(:d2) { create(:distributor_enterprise) }
|
||||
let!(:p1) { create(:simple_product) }
|
||||
let!(:p2) { create(:simple_product) }
|
||||
let!(:oc1) { create(:simple_order_cycle, distributors: [d1], variants: [p1.master]) }
|
||||
let!(:oc2) { create(:simple_order_cycle, distributors: [d2], variants: [p2.master]) }
|
||||
|
||||
it "shows variants in an order cycle distribution" do
|
||||
Variant.in_distributor(d1).should == [p1.master]
|
||||
end
|
||||
|
||||
it "doesn't show duplicates" do
|
||||
oc_dup = create(:simple_order_cycle, distributors: [d1], variants: [p1.master])
|
||||
Variant.in_distributor(d1).should == [p1.master]
|
||||
end
|
||||
end
|
||||
|
||||
describe "finding variants in an order cycle" do
|
||||
let!(:d1) { create(:distributor_enterprise) }
|
||||
let!(:d2) { create(:distributor_enterprise) }
|
||||
let!(:p1) { create(:product) }
|
||||
let!(:p2) { create(:product) }
|
||||
let!(:oc1) { create(:simple_order_cycle, distributors: [d1], variants: [p1.master]) }
|
||||
let!(:oc2) { create(:simple_order_cycle, distributors: [d2], variants: [p2.master]) }
|
||||
|
||||
it "shows variants in an order cycle" do
|
||||
Variant.in_order_cycle(oc1).should == [p1.master]
|
||||
end
|
||||
|
||||
it "doesn't show duplicates" do
|
||||
ex = create(:exchange, order_cycle: oc1, sender: oc1.coordinator, receiver: d2)
|
||||
ex.variants << p1.master
|
||||
|
||||
Variant.in_order_cycle(oc1).should == [p1.master]
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
describe "calculating the price with enterprise fees" do
|
||||
|
||||
@@ -92,6 +92,7 @@ RSpec.configure do |config|
|
||||
config.include Devise::TestHelpers, :type => :controller
|
||||
config.extend Spree::Api::TestingSupport::Setup, :type => :controller
|
||||
config.include Spree::Api::TestingSupport::Helpers, :type => :controller
|
||||
config.include OpenFoodNetwork::ControllerHelper, :type => :controller
|
||||
config.include OpenFoodNetwork::FeatureToggleHelper
|
||||
config.include OpenFoodNetwork::EnterpriseGroupsHelper
|
||||
config.include OpenFoodNetwork::DistributionHelper
|
||||
|
||||
26
spec/support/controller_helper.rb
Normal file
26
spec/support/controller_helper.rb
Normal file
@@ -0,0 +1,26 @@
|
||||
module OpenFoodNetwork
|
||||
module ControllerHelper
|
||||
def login_as_admin
|
||||
@admin_user ||= begin
|
||||
user = create(:user)
|
||||
user.spree_roles << Spree::Role.find_or_create_by_name!('admin')
|
||||
user
|
||||
end
|
||||
|
||||
controller.stub spree_current_user: @admin_user
|
||||
end
|
||||
|
||||
def login_as_enterprise_user(enterprises)
|
||||
@enterprise_user ||= begin
|
||||
user = create(:user)
|
||||
user.spree_roles = []
|
||||
enterprises.each do |enterprise|
|
||||
enterprise.enterprise_roles.create!(user: user)
|
||||
end
|
||||
user
|
||||
end
|
||||
|
||||
controller.stub spree_current_user: @enterprise_user
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -129,6 +129,15 @@ module WebHelper
|
||||
targetted_select2(value, options)
|
||||
end
|
||||
|
||||
def have_select2_option(value, options)
|
||||
container = options[:dropdown_css] || ".select2-with-searchbox"
|
||||
page.execute_script %Q{$('#{options[:from]}').select2('open')}
|
||||
page.execute_script "$('#{container} input.select2-input').val('#{value}').trigger('keyup-change');"
|
||||
sleep 1
|
||||
have_selector "div.select2-result-label", text: value
|
||||
end
|
||||
|
||||
|
||||
private
|
||||
def wait_for_ajax
|
||||
wait_until { page.evaluate_script("$.active") == 0 }
|
||||
|
||||
@@ -1,22 +0,0 @@
|
||||
require 'spec_helper'
|
||||
|
||||
describe 'suburbs/index.json.rabl' do
|
||||
before(:each) do
|
||||
Suburb.any_instance.stub(:state_name).and_return("Victoria")
|
||||
@suburb1 = Suburb.create(name: "Camberwell", postcode: 3124, latitude: -37.824818, longitude: 145.057957)
|
||||
@suburb2 = Suburb.create(name: "Hawthorn", postcode: 3122, latitude: -37.824830, longitude: 145.057950)
|
||||
@rendered = Rabl.render([@suburb1, @suburb2], 'suburbs/index', view_path: 'app/views')
|
||||
end
|
||||
|
||||
it "should have an array of suburbs" do
|
||||
@rendered.should have_json_type(Array).at_path('')
|
||||
end
|
||||
|
||||
it "should have 2 suburbs" do
|
||||
@rendered.should have_json_size(2).at_path('')
|
||||
end
|
||||
|
||||
it "should include suburb ids and labels" do
|
||||
@rendered.should include_json("{\"id\": #{@suburb1.id}, \"label\": \"#{@suburb1.name} (#{@suburb1.state_name}), #{@suburb1.postcode}\"}")
|
||||
end
|
||||
end
|
||||
Reference in New Issue
Block a user