Sha256: 8776bc91f710f46c71c44c78f4b31592dba6a6ae0927301f7776129b072c148b

Contents?: true

Size: 1.12 KB

Versions: 24

Compression:

Stored size: 1.12 KB

Contents

require 'support/spec_helper'

require "rad/_support/callbacks"
require "rad/_support/filters"

describe "Filters" do
  module ARemote
    inherit Rad::Filters
  end
  
  class FiltersBasic
    inherit ARemote
          
    before :set_user
    
    def action
      'result'
    end

    attr_reader :user
    def set_user
      @user = 'some user'
    end
  end
  
  class FilterInheritance < FiltersBasic
    before :set_model
    
    attr_reader :model
    def set_model
      @model = 'some model'
    end      
  end
  
  class FilterOverrideAction < FiltersBasic
    def action
      'overriden result'
    end
  end
  
  it 'basic' do
    r = FiltersBasic.new
    r.run_callbacks(:action){r.send :action}.should == 'result'
    r.user.should == 'some user'
  end
  
  it 'inheritance' do
    r = FilterInheritance.new
    r.run_callbacks(:action){r.send :action}.should == 'result'
    r.user.should == 'some user'
    r.model.should == 'some model'
  end
  
  it "overriding action" do
    r = FilterOverrideAction.new
    r.run_callbacks(:action){r.send :action}.should == 'overriden result'
    r.user.should == 'some user'
  end
  
end

Version data entries

24 entries across 24 versions & 1 rubygems

Version Path
rad_core-0.2.6 spec/support/filters_spec.rb
rad_core-0.2.5 spec/support/filters_spec.rb
rad_core-0.2.4 spec/support/filters_spec.rb
rad_core-0.2.3 spec/support/filters_spec.rb
rad_core-0.2.2 spec/support/filters_spec.rb
rad_core-0.2.1 spec/support/filters_spec.rb
rad_core-0.2.0 spec/support/filters_spec.rb
rad_core-0.0.30 spec/support/filters_spec.rb
rad_core-0.0.29 spec/support/filters_spec.rb
rad_core-0.0.28 spec/support/filters_spec.rb
rad_core-0.0.27 spec/support/filters_spec.rb
rad_core-0.0.26 spec/support/filters_spec.rb
rad_core-0.0.25 spec/support/filters_spec.rb
rad_core-0.0.24 spec/support/filters_spec.rb
rad_core-0.0.23 spec/support/filters_spec.rb
rad_core-0.0.22 spec/support/filters_spec.rb
rad_core-0.0.21 spec/support/filters_spec.rb
rad_core-0.0.20 spec/support/filters_spec.rb
rad_core-0.0.19 spec/support/filters_spec.rb
rad_core-0.0.18 spec/support/filters_spec.rb