Created
November 16, 2014 17:15
-
-
Save why-el/cd5d834b1f9a8e7e2f0d to your computer and use it in GitHub Desktop.
Rails-money issue 239
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
unless File.exist?('Gemfile') | |
File.write('Gemfile', <<-GEMFILE) | |
source 'https://rubygems.org' | |
gem 'rails', '4.2.0.beta4' | |
gem 'pg' | |
gem 'money-rails' | |
GEMFILE | |
system 'bundle' | |
end | |
require 'bundler' | |
Bundler.setup(:default) | |
require 'rails' | |
require 'active_record' | |
require 'money-rails' | |
MoneyRails::Hooks.init | |
ActiveRecord::Base.establish_connection(adapter: 'postgresql', database: 'ar_test') | |
ActiveRecord::Base.logger = Logger.new(STDOUT) | |
ActiveRecord::Schema.define do | |
create_table :products do |t| | |
t.money :price_cents, currency: { present: false } | |
t.timestamps | |
end | |
end | |
class Product < ActiveRecord::Base | |
monetize :price_cents | |
end | |
class FooApp < Rails::Application | |
config.root = File.dirname(__FILE__) | |
config.session_store :cookie_store, key: 'cookie_store_key' | |
config.secret_token = 'secret_token' | |
config.secret_key_base = 'secret_key_base' | |
config.logger = Logger.new($stdout) | |
Rails.logger = config.logger | |
end | |
require 'minitest/autorun' | |
class FooTest < ActiveSupport::TestCase | |
def test_created_money_columns_successsfully | |
assert p = Product.new({price: 100}) | |
puts p.price | |
end | |
private | |
def app | |
Rails.application | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment