Sha256: 6dde12459499461f055d3484464b1746aa6edf7998532ca5f591d52ec5f3f3ad

Contents?: true

Size: 971 Bytes

Versions: 10

Compression:

Stored size: 971 Bytes

Contents

require 'rails_helper'

RSpec.describe OrgDepartment, type: :model do
  before do
    @org = Org.create!(lang_id: 1)
    @department = OrgDepartment.create!(org_id: @org.id)
    @department_position = OrgDepartmentPosition.create!(org_department_id: @department.id)
    @member = OrgMember.create!(org_id: @org.id, entried_on: Time.now)
  end

  describe ".members" do
    context "count 1" do
      before do
        @department_position.add @member
      end

      it "count 1 with 1 position" do
        members = @department.members
        expect(members.count).to eq(1)
        expect(members.first.id).to eq(@member.id)
      end

      it "count 1 with 2 positions" do
        department_position2 = OrgDepartmentPosition.create!(org_department_id: @department.id)
        department_position2.add @member
        members = @department.members
        expect(members.count).to eq(1)
        expect(members.first.id).to eq(@member.id)
      end
    end
  end
end

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
we_bridge_rails_engine_orgs-0.1.16 spec/models/org_department_spec.rb
we_bridge_rails_engine_orgs-0.1.15 spec/models/org_department_spec.rb
we_bridge_rails_engine_orgs-0.1.14 spec/models/org_department_spec.rb
we_bridge_rails_engine_orgs-0.1.13 spec/models/org_department_spec.rb
we_bridge_rails_engine_orgs-0.1.12 spec/models/org_department_spec.rb
we_bridge_rails_engine_orgs-0.1.11 spec/models/org_department_spec.rb
we_bridge_rails_engine_orgs-0.1.10 spec/models/org_department_spec.rb
we_bridge_rails_engine_orgs-0.1.9 spec/models/org_department_spec.rb
we_bridge_rails_engine_orgs-0.1.8 spec/models/org_department_spec.rb
we_bridge_rails_engine_orgs-0.1.7 spec/models/org_department_spec.rb