Skip to content

Instantly share code, notes, and snippets.

@myf9000
Created September 20, 2016 07:47
Show Gist options
  • Save myf9000/b15f713e9f47ca632663bddcf6a698a1 to your computer and use it in GitHub Desktop.
Save myf9000/b15f713e9f47ca632663bddcf6a698a1 to your computer and use it in GitHub Desktop.
require "spec_helper"
describe Actions::HR::Groups::AssignMembersGroup, sidekiq: false do
let!(:tag_first) { create(:tag) }
let!(:tag_second) { create(:tag) }
let!(:organization) { create(:organization) }
let!(:action_maker) { create(:employee, organization: organization) }
let!(:group) { create(:group, organization: organization) }
let!(:employee_first) { create(:employee, organization: organization) }
let!(:employee_second) { create(:employee, organization: organization) }
subject { described_class.new(group: group, action_maker: action_maker).call }
before do
group.personas = []
employee_first.role.tags << tag_first
employee_first.role.tags << tag_second
employee_second.role.tags << tag_first
end
context "when group has not tags" do
it "has all of employees" do
expect(subject.users.count).to eq 3
end
end
context "when group has tags" do
before do
group.personas.new
group.personas.first.tags << tag_first
group.personas.first.tags << tag_second
end
it "has employee with matching tags" do
# Because action_maker always is assigned after AssignMembersGroup service
expect(subject.users.count).to eq 1
expect(subject.users.first).to eq employee_first
end
it "has not employee with one of two matching tags" do
expect(subject.users.first).not_to eq employee_second
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment