discourse/plugins/automation/spec/triggers/user_first_logged_in_spec.rb

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

31 lines
851 B
Ruby
Raw Normal View History

# frozen_string_literal: true
describe DiscourseAutomation::Triggers::USER_FIRST_LOGGED_IN do
before { SiteSetting.discourse_automation_enabled = true }
fab!(:user)
let(:topic) { post.topic }
fab!(:automation) do
Fabricate(:automation, trigger: DiscourseAutomation::Triggers::USER_FIRST_LOGGED_IN)
end
context "when user logs in for first time" do
it "triggers the automation" do
contexts = capture_contexts { user.logged_in }
expect(contexts[0]["kind"]).to eq(DiscourseAutomation::Triggers::USER_FIRST_LOGGED_IN)
expect(contexts[0]["user"]).to eq(user)
end
end
context "when user logs in multiple times" do
it "doesnt trigger the automation" do
user.update_last_seen!(2.days.ago)
contexts = capture_contexts { user.logged_in }
expect(contexts).to eq([])
end
end
end