Sha256: fe4c8e1fa3f4082f1b8ffaa39bd37e7e2b2d6763291ed18db5bd84fd831b4620

Contents?: true

Size: 898 Bytes

Versions: 2

Compression:

Stored size: 898 Bytes

Contents

require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')

describe OnlyController do
  include RSpec::Rails::ControllerExampleGroup
  
  it "should limit those attribute to ONLY those actions" do
    post :create, :foo => "hi"
    response.code.should == "200"
  end
  
  it "should disallow unknown attributes from those actions" do
    begin
      post :create, :bar => "hi"
      raise "should fail"
    rescue ParamAccessible::Error => e
      e.inaccessible_params.should == %w(bar)
    end
  end
  
  it "should obey nested attributes" do
    post :update, :bar => {:baz => 'hi'}
    response.code.should == "200"
  end
  
  it "should catch invalid nested attributes for those actions" do
    begin
      post :update, :bar => {:foo => 'hi'}
      raise "should fail"
    rescue ParamAccessible::Error => e
      e.inaccessible_params.should == %w(bar[foo])
    end
  end
  
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
param_accessible-0.0.2 spec/lib/only_spec.rb
param_accessible-0.0.1 spec/lib/only_spec.rb