Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Metadata assumes it de-serializes to Symbol keys #436

Closed
xxx opened this issue Aug 13, 2018 · 3 comments
Closed

Metadata assumes it de-serializes to Symbol keys #436

xxx opened this issue Aug 13, 2018 · 3 comments

Comments

@xxx
Copy link

xxx commented Aug 13, 2018

I'm moving to use JSON as the serializer for our events, since JSON is far more universal outside of the Ruby world, but Metadata#[]= assumes keys will be Symbols, and raises an ArgumentError if not. This isn't the case with events that are dumped to and loaded from JSON. Here are a couple specs that demonstrate this:

      let(:yaml_store) do
        RailsEventStore::Client.new(
          dispatcher: RailsEventStore::ActiveJobDispatcher.new(
            proxy_strategy: RailsEventStore::AsyncProxyStrategy::AfterCommit.new
          )
        )
      end

      let(:json_store) do
        RailsEventStore::Client.new(
          mapper: RubyEventStore::Mappers::Default.new(
            serializer: JSON
          ),
          dispatcher: RailsEventStore::ActiveJobDispatcher.new(
            proxy_strategy: RailsEventStore::AsyncProxyStrategy::AfterCommit.new
          )
        )
      end

      let(:event) { RailsEventStore::Event.new(data: {}, metadata: {}) }

      # fails, but should pass
      it 'publishes JSON-serialized events without error' do
        event_store = json_store
        event_store.publish event
        expect(event_store).to have_published(an_event(RailsEventStore::Event))
      end

      # passes as expected
      it 'publishes YAML-serialized events without error' do
        event_store = yaml_store
        event_store.publish event
        expect(event_store).to have_published(an_event(RailsEventStore::Event))
      end
@mostlyobvious
Copy link
Member

Related: #367

@xxx
Copy link
Author

xxx commented Aug 13, 2018

ah, duplicate. I couldn't find it for wahtever reason. Let's close this one.

@xxx xxx closed this as completed Aug 13, 2018
@mostlyobvious
Copy link
Member

No problem, I had this one in memory :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants