Sha256: 0f9278e55601f1b7d1d79af95cc4cc2371085f717809f1e98a04bfe7ef8b42d1

Contents?: true

Size: 1.02 KB

Versions: 2

Compression:

Stored size: 1.02 KB

Contents

require 'spec_helper'

describe Camaraderie do
  describe 'Custom model classes' do
    before do
      Camaraderie.configure do |config|
        config.organization_class = 'Company'
        config.user_class = 'Employee'
        config.membership_types = %w(admin member)
      end

      spawn_organization_model 'Company'
      spawn_user_model 'Employee'
      spawn_membership_model

      run_migration do
        create_table(:employees, force: true)
        create_table(:companies, force: true)
      end
    end

    let(:user) { Employee.create }
    let(:organization) { Company.create }

    before do
      # FIXME Why doesn't this work?
      # It bypasses `class_name: 'Employee'` and tries to use 'User'
      #
      # organization.admins.create(user: user)

      # We'll have to use this for now
      Membership.create(membership_type: 'admin', user: user, organization: organization)
    end

    it { expect(user).to be_admin_of(organization) }
    it { expect(organization.admin_users).to include(user) }
  end
end

Version data entries

2 entries across 2 versions & 1 rubygems

Version Path
camaraderie-0.2.1 spec/camaraderie_spec.rb
camaraderie-0.2 spec/camaraderie_spec.rb