# # options_assignation_test.rb # # Created on 25/09/2007.should == 17:05:24 # require File.join(File.dirname(__FILE__), 'little_rails_app.rb') # "Fake" and active record for resource. class Want def self.class_name "Want" end def self.reflections [] end def self.column_names %w|anything i want| end end require File.join(File.dirname(__FILE__), 'resources_controller.rb') describe "When Users configures options 'by hand'" do it "Should keep all user options" do data= ResourcesController.ardata data.resource.singular.should == "Anything" data.resource.plural.should == "I" data.resource.model.should == Want data.resource.model_name.should == "Want" data.resource.name_prefix.should == "what_i_like_" AutoRest::Labels.defaults.keys.each_with_index do |key, index| data.labels[key].should == "Custom label #{index}" end data.templates.index.should == {:template => :custom1} data.templates.show.should == {:template => :custom2} data.templates.edit.should == {:template => :custom3} data.templates.new.should == {:template => :custom4} data.templates.search.should == {:template => :custom5} data.exclude_methods.should ==[] data.only_methods.should == [:index, :edit] data.methods.should == Set.new([:index, :edit]) data.exclude_links.should == [:update, :back, :new, :create] data.only_links.should ==[] data.links.should == Set.new([:index, :search, :show, :destroy, :edit]) data.ferret.enabled.should be_true data.ferret.options.should == {:what_ever => :i_want, :search_limit => 123} data.will_paginate.enabled.should be_true data.will_paginate.options[:what_ever].should == :i_like data.parent_resources.should == Set.new([]) data.parent_ids.should == Set.new([:a, :b, :c]) data.foreing_models.should == {:some_id => :some_model} data.index_finder.should == {:ar => :options} data.exclude_fields.for_index.should == [:attribute1] data.exclude_fields.for_new.should == [:etc] data.exclude_fields.for_edit.should be_nil data.exclude_fields.for_show.should == [:i] data.fields.for_index.should == [[:attribute2, "Attribute2"], [:etc, "Etc"]] data.fields.for_new.should == [[:attribute1, "Attribute1"], [:attribute2, "Attribute2"]] data.fields.for_edit.should == [[:anything, "Anything"], [:i, "I"], [:want, "Want"]] data.fields.for_show.should == [[:anything, "Anything"], [:want, "Want"]] data.hidden_fields.should == Set.new([1, 2, 3]) data.breadcrumbs.prefix_controller.should == "HELLO" data.breadcrumbs.prefix_label.should == "BYE" data.breadcrumbs.plural.should == "1" data.breadcrumbs.singular.should == "2" data.breadcrumbs.label_new.should == "3" data.breadcrumbs.separator.should == "4" end end