Sha256: 03529b1fb1ca625d3ac25b7b5e3774d716d82d1e703d95be9665602ade542f5f

Contents?: true

Size: 1.55 KB

Versions: 12

Compression:

Stored size: 1.55 KB

Contents

require File.join(File.dirname(__FILE__), '../../test_helper.rb')

class RecordBaseModelTest < Test::Unit::TestCase
  include TestHelper
  
  class AppleModel < Xeroizer::Record::BaseModel
    set_api_controller_name 'AppleController'
    set_permissions :read, :write
  end
  
  class PearModel < Xeroizer::Record::BaseModel
    set_api_controller_name 'PearController'
    set_permissions :read
  end
  
  class OrangeModel < Xeroizer::Record::BaseModel
    set_permissions :read, :write, :update
  end
  
  def setup
    @client = Xeroizer::PublicApplication.new(CONSUMER_KEY, CONSUMER_SECRET)
    @apple_model = AppleModel.new(@client, 'Apple')
    @pear_model = PearModel.new(@client, 'Pear')
    @orange_model = OrangeModel.new(@client, 'Orange')
  end
  
  context "RecordModel.api_controller_name" do
    
    should "api_controller_name should default to pluralized model name" do
      assert_equal('Oranges', @orange_model.api_controller_name)
    end
    
    should "set_api_controller_name should set the base controller name used by Xero" do
     assert_equal('AppleController', @apple_model.api_controller_name)
     assert_equal('PearController', @pear_model.api_controller_name)
    end
    
  end
  
  context "model permssions" do
    
    should "save permissions correctly" do
      assert_equal(%w(read write), @apple_model.class.permissions.keys.map(&:to_s).sort)
      assert_equal(%w(read), @pear_model.class.permissions.keys.map(&:to_s).sort)
      assert_equal(%w(read update write), @orange_model.class.permissions.keys.map(&:to_s).sort)
    end
    
  end

end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
xeroizer-0.3.5 test/unit/record/base_model_test.rb
xeroizer-0.3.4 test/unit/record/base_model_test.rb
xeroizer-0.3.3 test/unit/record/base_model_test.rb
xeroizer-0.3.2 test/unit/record/base_model_test.rb
xeroizer-0.3.1 test/unit/record/base_model_test.rb
xeroizer-0.3.0 test/unit/record/base_model_test.rb
xeroizer-0.2.2 test/unit/record/base_model_test.rb
xeroizer-0.2.1 test/unit/record/base_model_test.rb
xeroizer-0.2.0 test/unit/record/base_model_test.rb
xeroizer-0.1.3 test/unit/record/base_model_test.rb
xeroizer-0.1.2 test/unit/record/base_model_test.rb
xeroizer-0.1.0 test/unit/record/base_model_test.rb