-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
17 changed files
with
67 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -45,3 +45,5 @@ | |
end | ||
end | ||
end | ||
|
||
RSpec::Matchers.define_negated_matcher(:not_change, :change) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,5 @@ | ||
# frozen_string_literal: true | ||
|
||
module Eventsimple | ||
VERSION = '1.2.0' | ||
VERSION = '1.2.1' | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,8 +12,6 @@ def apply(user) | |
|
||
user.created_at ||= created_at | ||
user.updated_at = created_at | ||
|
||
user | ||
end | ||
end | ||
end | ||
|
21 changes: 21 additions & 0 deletions
21
spec/dummy/app/components/user_component/events/override_timestamp.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
# frozen_string_literal: true | ||
|
||
module UserComponent | ||
module Events | ||
class OverrideTimestamp < UserEvent | ||
attribute :data, Eventsimple::DataType.new(self) | ||
|
||
class Message < Eventsimple::Message | ||
attribute :canonical_id, DryTypes::Strict::String | ||
attribute :created_at, DryTypes::JSON::Time | ||
attribute :updated_at, DryTypes::JSON::Time | ||
end | ||
|
||
def apply(user) | ||
user.canonical_id = data.canonical_id | ||
user.created_at = data.created_at | ||
user.updated_at = data.updated_at | ||
end | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -19,7 +19,6 @@ def apply(user) | |
user.canonical_id = data.canonical_id | ||
user.username = 'test' | ||
user.email = '[email protected]' | ||
user | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -21,7 +21,6 @@ def apply(user) | |
user.canonical_id = data.canonical_id | ||
user.username = 'test' | ||
user.email = '[email protected]' | ||
user | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -15,7 +15,6 @@ def can_apply?(user) | |
|
||
def apply(user) | ||
user.email = data.email | ||
user | ||
end | ||
end | ||
end | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
29 changes: 29 additions & 0 deletions
29
spec/dummy/spec/components/user_component/events/override_timestamp_spec.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
# frozen_string_literal: true | ||
|
||
RSpec.describe UserComponent::Events::OverrideTimestamp do | ||
describe '#create' do | ||
subject(:create_event) { event.save } | ||
|
||
let(:canonical_id) { SecureRandom.uuid } | ||
|
||
let(:user) { User.new } | ||
let(:event) do | ||
described_class.new( | ||
user: user, | ||
data: { | ||
canonical_id: canonical_id, | ||
created_at: Time.new(2023, 1, 1), | ||
updated_at: Time.new(2023, 1, 1), | ||
}, | ||
) | ||
end | ||
|
||
it 'updates the user properties' do | ||
create_event | ||
|
||
expect(user.canonical_id).to eq(event.data.canonical_id) | ||
expect(user.created_at).to eq(event.data.created_at) | ||
expect(user.updated_at).to eq(event.data.updated_at) | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters