Sha256: 9dc20ee09d1d30dbe00fc6e14f06d6a913e281a9fe2b92cb90f9994bfd0fb4c8

Contents?: true

Size: 663 Bytes

Versions: 1

Compression:

Stored size: 663 Bytes

Contents

require "spec_helper"

require "sequel_mapper"
require "support/graph_fixture"

RSpec.describe "Ordered associations" do
  include SequelMapper::GraphFixture

  context "of type `has_many`" do
    subject(:graph) {
      SequelMapper::Graph.new(
        top_level_namespace: :users,
        datastore: datastore,
        relation_mappings: relation_mappings,
      )
    }

    let(:user) {
      graph.where(id: "user/1").first
    }

    it "enumerates the objects in order specified in the config" do
      user.toots.to_a

      expect(user.toots.map(&:id).to_a)
        .to eq(user.toots.to_a.sort_by { |t| t.tooted_at }.map(&:id).reverse)
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
sequel_mapper-0.0.1 spec/ordered_association_spec.rb