Skip to content

Instantly share code, notes, and snippets.

View mattfitzgerald's full-sized avatar

Matt Fitzgerald mattfitzgerald

View GitHub Profile
module AnimalFunctions
def eat
puts "The animal is eating"
end
end
class Cow
include AnimalFunctions
# been deleting a lot of this...
<% content_for(:head) do %>
<%= javascript_include_merged('databrowser') %>
<%= stylesheet_link_merged('databrowser') %>
<% end %>
# There are a bunch of (awkward) methods like this in view helpers
# (awkward as they require the object to passed in).
# I'm copying these to the models where they belong and marking the originals deprecated.
# This sound ok?
module PaymentsHelper
def account_name(payment)
"#{Account.find_with_deleted(payment.account_id).name}"
end
<%if @report.report_type and @rows%>
<table id="admin-report" width="100%" cellpadding="0" cellspacing="0" border="0" class="table table-striped table-bordered">
<thead>
<tr>
<%@columns.each do |c|%>
<th><%=c[:display]%></th>
<%end%>
</tr>
</thead>
<tbody>
<th>Pricing</th>
<td><%= label_tag :setup_cost%> <%=t 'payments.currency_label', :locale => @locale %> <%=t 'number.currency.unit', :locale => @locale %></td>
<td><%= text_field_tag :setup_cost, @setup_cost %> <b>(excluding <%=t 'payments.tax', :locale => @locale %>)</b></td>
def item_class
item_class = [Signup, SmsCredit, Subscription, Reactivation, Refund, SmsRefund, Adhoc].find{|type| item == type.item_name}
raise "unknown purchase item '#{item}'" if item_class.nil?
item_class
end
def description
item_description = item_type ? item_type.description : ''
self.read_attribute(:description) || item_description || default_description(quantity, item)
end
# sort on position, *force* preservation original order if two have same position
return fields_with_positions.each_with_index.sort{|(a,a_idx),(b,b_idx)|
pos_comp = a[:position]<=>b[:position]
pos_comp.zero? ? (a_idx<=>b_idx) : pos_comp
}.map{|a| a[0] }
> git fetch origin
> git checkout -b feature origin/feature
> git rebase origin/master
AccountsController
responding to POST register
with valid user and account params
should not shit me
Finished in 0.77759 seconds
1 example, 0 failures
#So I have this in the acct creation controller
@account.users.first.payment_methods << @payment_method
#When this is hit by a spec I get this error
Mock "PaymentMethod_1003" received unexpected message :[]= with ("user_id", 507)
#Should I be attempting to stub it out with something like this: