Skip to content

Instantly share code, notes, and snippets.

View Lordnibbler's full-sized avatar

Ben Radler Lordnibbler

View GitHub Profile
def is_page?(page)
if params
params["id"] == page && params["controller"] == "high_voltage/pages"
else
false
end
end
"shipments": [
{
"id": 1053930574,
"tracking": null,
"number": "H36015558751",
"cost": "0.0",
"shipped_at": null,
"state": "pending",
"order_id": "R644681243",
"stock_location_name": "California Fulfillment Center",
# This migration comes from spree (originally 20130802022321)
class MigrateTaxCategoriesToLineItems < ActiveRecord::Migration
def change
Spree::LineItem.includes(:variant => { :product => :tax_category }).find_in_batches do |line_items|
line_items.each do |line_item|
next if line_item.variant.nil?
next if line_item.variant.product.nil?
next if line_item.product.nil?
line_item.update_column(:tax_category_id, line_item.product.tax_category.id)
end
RSpec::Matchers.define :have_meta do |name, expected|
match do |actual|
has_css?("meta[name='#{name}'][content='#{expected}']")
end
failure_message_for_should do |actual|
actual = first("meta[name='#{name}']")
if actual
"expected that meta #{name} would have content='#{expected}' but was '#{actual[:content]}'"
else
require 'spec_helper'
describe "Locations", js: true do
describe "Dealer locator search returns relevant locations" do
it "should return test location" do
location = FactoryGirl.create(:location)
visit "/store/dealer-locator"
fill_in "search", with: "Castro Valley, CA"
click_on "Search"
child :shipments => :shipments do
extends "spree/api/shipments/show"
child :shipping_method => :shipping_method do
attributes :name, :zone_id, :shipping_category_id
end
end
class ConvertLoginInstructionFromHtmlToMarkdownInBrands < ActiveRecord::Migration
def self.up
Brand.find_each do |brand|
brand.login_instruction = ReverseMarkdown.parse(brand.login_instruction)
brand.save
end
end
def self.down
renderer = Redcarpet::Render::HTML.new(:filter_html => true)
# we need to protect against multiple includes of the Rails environment (trust me)
require './config/environment' if !defined?(Rails) || !Rails.initialized?
require 'sprockets'
require 'sprockets-helpers'
require "sprockets-sass"
require "sass"
unless Rails.env.production?
map '/assets' do
sprockets = Sprockets::Environment.new
<ul class="btn-toolbar pull-right nav">
<div class="btn-group" id="balls1">
<li class="dropdown" id="balls">
<a class="btn" id="more-actions">
More Actions
<b class="icon-ol arrow-down small dark pull-right"></b>
</a>
<ul class="dropdown-menu">
<li><a href="/users/upload">Import Users</a></li>
<li><a href="#" id="bulk-operations">Bulk Operations</a></li>
Failures:
1) Spree::Product product instance #duplicate duplicates product
Failure/Error: clone = product.duplicate
NoMethodError:
undefined method `[]' for nil:NilClass
# /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/spree-e265e97fce6f/core/lib/spree/core/permalinks.rb:58:in `block (2 levels) in save_permalink'
# /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/rails-b768647aa89b/activerecord/lib/active_record/relation/delegation.rb:6:in `map'
# /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/rails-b768647aa89b/activerecord/lib/active_record/relation/delegation.rb:6:in `map'
# /usr/local/var/rbenv/versions/2.0.0-p247/lib/ruby/gems/2.0.0/bundler/gems/spree-e265e97fce6f/core/lib/spree/core/permalinks.rb:58:in `block in save_permalink'