Sha256: 497b6725ef551d5d65dfac88842525e706933528fd1ee115710b2c6c15a7a392
Contents?: true
Size: 1.47 KB
Versions: 3
Compression:
Stored size: 1.47 KB
Contents
# To change this template, choose Tools | Templates # and open the template in the editor. require File.expand_path(File.dirname(__FILE__) + '/../spec_helper') class MyController < ApplicationController include Lolita::Controllers::InternalHelpers include Lolita::Hooks add_hook :before_build_resource,:after_build_resource add_hook :before_index before_index :modify def index @@temp=1 self.run_before_index end private def modify @@temp=3 end end describe MyController do before(:each) do @controller.request.env["lolita.mapping"]=Lolita.mappings[:post] end it "should call hook in #index" do @controller.index @controller.class.class_variable_get(:"@@temp").should == 3 end it "should get resource name" do @controller.resource_name.should == :post end it "should get resource class" do @controller.resource_class.should == Post end it "should build resource" do @controller.send(:build_resource) @controller.resource.class.should == Post end it "should set resource" do new_post=Post.new @controller.send(:resource=,new_post) @controller.resource.should == new_post @controller.send(:resource=,nil) @controller.resource.should be_nil end it "should convert rails date_select and datetime_select values" do resource=Post.new sample_date = Date.civil(2011,1,1) attributes={:published_at => {}} @controller.send(:resource_with_attributes,resource,attributes) end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
lolita-3.1.4 | spec/controllers/internal_helpers_spec.rb |
lolita-3.1.3 | spec/controllers/internal_helpers_spec.rb |
lolita-3.1.2 | spec/controllers/internal_helpers_spec.rb |