diff --git a/.ruby-version b/.ruby-version new file mode 100644 index 00000000..7d2ed7c7 --- /dev/null +++ b/.ruby-version @@ -0,0 +1 @@ +2.1.4 diff --git a/Gemfile b/Gemfile index 796d8e09..c076af90 100644 --- a/Gemfile +++ b/Gemfile @@ -10,3 +10,6 @@ when /3/ else gem 'mongoid', version end + + +gem 'money-rails' diff --git a/spec/mongoid-history/money-rails.rb b/spec/mongoid-history/money-rails.rb new file mode 100644 index 00000000..d7c3e474 --- /dev/null +++ b/spec/mongoid-history/money-rails.rb @@ -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 \ No newline at end of file diff --git a/spec/support/money_rails.rb b/spec/support/money_rails.rb new file mode 100644 index 00000000..b43daf75 --- /dev/null +++ b/spec/support/money_rails.rb @@ -0,0 +1,5 @@ +require 'money-rails/test_helpers' + +RSpec.configure do |config| + config.include MoneyRails::TestHelpers +end