spec/generators/resource_generator_spec.rb in adminpanel-1.2.12 vs spec/generators/resource_generator_spec.rb in adminpanel-2.0.0

- old
+ new

@@ -1,10 +1,10 @@ require 'spec_helper' require 'generators/adminpanel/resource/resource_generator' describe Adminpanel::Generators::ResourceGenerator do - destination File.expand_path("../../dummy/tmp", __FILE__) + destination File.expand_path('../../dummy/tmp', __FILE__) before do prepare_destination Rails::Generators.options[:rails][:orm] = :active_record end @@ -44,21 +44,38 @@ contain(/t.text :description/) ) end end - it 'should generate posts controller' do - file('app/controllers/adminpanel/posts_controller.rb').should exist + context 'the controller' do + it 'should generate posts controller' do + file('app/controllers/adminpanel/posts_controller.rb').should exist + end + + it 'should have the params whitelisted' do + file('app/controllers/adminpanel/posts_controller.rb').should( + contain(/params.require(:post).permit/) && + contain(/:name/) && + contain(/:description/) && + contain(/:number/) && + contain(/:flag/) && + contain(/:quantity/) && + contain(/:date/) && + contain(/{:postfiles_attributes => \[:id, :file, :_destroy\]}/) + ) + end + end it 'should generate post model' do file('app/models/adminpanel/post.rb').should exist end context 'the model' do it 'should generate the model with correct values' do file('app/models/adminpanel/post.rb').should( + contain(/include Adminpanel::Base/) && contain(/mount_images :postfiles/) && contain(/'photos' => \{/) && contain(/'type' => 'adminpanel_file_field'/) ) end