Sha256: fe18e7842d8d720bcf40ccd326cb5c992c650a7602e3bc71c29a827f8b8ad779

Contents?: true

Size: 1.11 KB

Versions: 1

Compression:

Stored size: 1.11 KB

Contents

require File.expand_path('test_helper', File.dirname(__FILE__))

class Widget
  extend ActiveModel::Naming
end

class WidgetsController < InheritedResources::Base
end

class StrongParametersTest < ActionController::TestCase
  def setup
    @controller = WidgetsController.new
    @controller.stubs(:widget_url).returns("/")
    @controller.stubs(:permitted_params).returns(:widget => {:permitted => 'param'})
  end

  def test_permitted_params_from_new
    Widget.expects(:new).with(:permitted => 'param')
    get :new, :widget => { :permitted => 'param', :prohibited => 'param' }
  end

  def test_permitted_params_from_create
    Widget.expects(:new).with(:permitted => 'param').returns(mock(:save => true))
    post :create, :widget => { :permitted => 'param', :prohibited => 'param' }
  end

  def test_permitted_params_from_update
    mock_widget = mock
    mock_widget.stubs(:class).returns(Widget)
    mock_widget.expects(:update_attributes).with(:permitted => 'param')
    Widget.expects(:find).with('42').returns(mock_widget)
    put :update, :id => '42', :widget => {:permitted => 'param', :prohibited => 'param'}
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
inherited_resources-1.4.0 test/strong_parameters_test.rb