2015-09-28 04:11:33 -04:00
|
|
|
require 'spec_helper'
|
|
|
|
|
2017-02-10 06:32:37 -05:00
|
|
|
if defined?(Mongoid::Document)
|
|
|
|
require 'generator_spec'
|
|
|
|
require 'generators/mongoid/aasm_generator'
|
2015-09-28 04:11:33 -04:00
|
|
|
|
|
|
|
describe Mongoid::Generators::AASMGenerator, type: :generator do
|
|
|
|
destination File.expand_path("../../../tmp", __FILE__)
|
|
|
|
|
|
|
|
before(:all) do
|
|
|
|
prepare_destination
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates model with aasm block for default column_name" do
|
|
|
|
run_generator %w(user)
|
|
|
|
assert_file "app/models/user.rb", /include AASM\n\n aasm do\n end\n/
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates model with aasm block for custom column_name" do
|
|
|
|
run_generator %w(user state)
|
|
|
|
assert_file "app/models/user.rb", /aasm :column => 'state' do\n end\n/
|
|
|
|
end
|
|
|
|
|
|
|
|
it "creates model with aasm block for namespaced model" do
|
|
|
|
run_generator %w(Admin::User state)
|
|
|
|
assert_file "app/models/admin/user.rb", /aasm :column => 'state' do\n end\n/
|
|
|
|
end
|
|
|
|
|
|
|
|
end
|
2017-02-10 06:32:37 -05:00
|
|
|
|
2015-09-28 04:11:33 -04:00
|
|
|
end
|