Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Money rails type lost #122

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .ruby-version
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
2.1.4
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,3 +10,6 @@ when /3/
else
gem 'mongoid', version
end


gem 'money-rails'
31 changes: 31 additions & 0 deletions spec/mongoid-history/money-rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
require 'spec_helper'
require 'money-rails'


class MyModel
include Mongoid::Document
include Mongoid::Timestamps
include Mongoid::History::Trackable

field :name, type: String
field :date, type: Date
field :amount, type: Money

track_history track_create: true
end

describe "Model with MoneyRails field" do
before(:example) do
@my=MyModel.create(name: "A", date: Date.today, amount: 200.to_money)
end

it "should have a valid amount field with class Money" do
@my.date.class.should eq(Date)
@my.amount.class.should eq(Money)
end

it "should have a history entry with a valid amount field with class Money " do
@my.history_tracks.last[:modified][:date].class.should eq (Time)
@my.history_tracks.last[:modified][:amount].class.should eq(Money)
end
end
5 changes: 5 additions & 0 deletions spec/support/money_rails.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
require 'money-rails/test_helpers'

RSpec.configure do |config|
config.include MoneyRails::TestHelpers
end