This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
= simple_form_for @machine_visit_form do |f| | |
= f.error_notification | |
= f.input :refill_id, as: :hidden | |
= f.input :refill_date, as: :date | |
= f.input :refill_counter, as: :decimal, input_html: {value: number_with_precision(f.object.refill_counter, precision: 2) } | |
= f.fields_for :refill_line_items do |ff| | |
.well | |
= "#{ff.object.product_name}" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class UserTest < ActiveSupport::TestCase | |
test 'full_name returns contatenated first and last name' do | |
user = build(:user, first_name: 'foo', last_name: 'bar') | |
assert_equal 'foo bar', user.full_name | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'test_helper' | |
class AccountTest < ActiveSupport::TestCase | |
test 'presence on create' do | |
account = Account.create | |
refute account.valid? | |
end | |
test 'inclusion :subtype' do | |
# invalid |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
$stack, $draws = [], {} | |
def method_missing *args | |
return if args[0][/^to_/] | |
$stack << args.map { |a| a or $stack.pop } | |
$draws[$stack.pop(2)[0][0]] = args[1] if args[0] == :< | |
end | |
class Array | |
def +@ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class UserProject < ActiveRecord::Base | |
belongs_to :user | |
belongs_to :project | |
belongs_to :creator, :class_name => "User" | |
# add whatever else you want here, this is your join model | |
end | |
class User < ActiveRecord::Base | |
has_many :user_projects | |
has_many :projects, :through => :user_projects |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
## | |
# test/spec/mini 3 | |
# http://gist.github.com/25455 | |
# [email protected] | |
# file:lib/test/spec/mini.rb | |
# | |
def context(*args, &block) | |
return super unless (name = args.first) && block | |
require 'minitest/unit' | |
klass = Class.new(MiniTest::Unit::TestCase) do |