Skip to content

Instantly share code, notes, and snippets.

View rounders's full-sized avatar

Francois Harbec rounders

View GitHub Profile
@rounders
rounders / gist:1625808
Created January 17, 2012 09:16
problem with build_source
context "#build_source" do
let(:payment_method) { Factory(:bogus_payment_method) }
it "should build the payment's source" do
params = { :amount => 100, :payment_method_id => payment_method.id,
:source_attributes => {:year=>"2012", :month =>"1", :number => '1234567890123',:verification_value => '123'}}
payment = Spree::Payment.new(params)
payment.should be_valid
payment.source.should_not be_nil
<message xmlns="urn:ULGNEWCART"><request requestID="addToCart" userID="STS" cartID="Q301-740" description="Coupon (U14925568)" qty="1" cardCode="1022" siteType="CELLARS" priceEachEX="-20.00" cartType="shopping" taxEach="0.00" lineNumber="" prodID="VOUCHER"/></message>
@rounders
rounders / request.xml
Created October 6, 2011 01:07
pushing a spree adjustment to clear
<message xmlns="urn:ULGNEWCART">
<request prodID="" requestID="addToCart" description="Shipping" userID="STS" cartID="Q301-716" qty="1" cardCode="1022" siteType="CELLARS" priceEachEX="10.00" cartType="shopping" taxEach="0.00" lineNumber=""/>
</message>
newdoorventures $ DEBUG=true ey deploy
Token xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Request GET https://cloud.engineyard.com/api/v2/apps
EY::API::RequestFailed 408 Request Timeout <html>
<head>
<meta http-equiv="Content-type" content="text/html; charset=utf-8" />
<title>Request timed out</title>
<link rel="stylesheet" href="http://assets.engineyard.com/stylesheets/master.css" type="text/css" media="screen" charset="utf-8" />
<style type="text/css">
@rounders
rounders / gist:1227779
Created September 19, 2011 22:26
irbrc file
#making .irbrc posted at http://www.tech-angels.fr/post/963080350/improve-irb-and-fix-it-on-mac-os-x
#work with rails3
require 'rubygems'
#rails3: be sure to include wirble and hirb in your Gemfile
require 'wirble'
require 'hirb'
Wirble.init
Wirble.colorize
# hirb (active record output format in table)
@rounders
rounders / gist:1159978
Created August 21, 2011 01:46 — forked from parndt/gist:1011435
How to cache pages and clear them in Refinery CMS
# put in config/application.rb
config.to_prepare do
::PagesController.module_eval do
caches_page :show, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
caches_page :home, :unless => proc {|c| c.user_signed_in? || c.flash.any? }
end
::Page.module_eval do
after_save :clear_static_caching!
after_destroy :clear_static_caching!
def site_taxes
zones = Zone.match(self.shipment.address)
tax_rates = zones.map { |zone| zone.tax_rates}.flatten.uniq
calculated_taxes = {}
tax_rates.each do |tax_rate|
calculated_taxes[tax_rate.calculator.description] ||= 0
calculated_taxes[tax_rate.calculator.description] += tax_rate.calculate_tax(self)
end
calculated_taxes.delete_if { |k, v| v == 0 }
end
@rounders
rounders / gist:954043
Created May 3, 2011 19:34
problems with cucumber
### output from running cucumber ###
Using the default profile...
Feature: Manage Projects
In order to manage my projects
As an authenticated user
I want to create and manage projects
Scenario: Projects List # features/manage_projects.feature:7
Given I am logged in as user bob@test.com # features/step_definitions/project_steps.rb:1
And I have 5 to 10 projects # features/step_definitions/project_steps.rb:10
$(function() {
$( ".sortable" ).sortable({
handle: '.handle',
cursor: 'crosshair',
update: function(){
$.ajax({
type: 'post',
data: $('.sortable').sortable('serialize'),
url: '/projects/<%= @project.id %>/sort_tasks'});
}
# add to site_extension.rb
Checkout.class_eval do
state_machine do
before_transition :to => 'confirm' do |checkout, transition|
!checkout.payments.first.nil? && !checkout.payments.first.source_id.nil?
end
end
end
# override update method in CheckoutsController