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

Upgrade to rom 6.0 #73

Open
wants to merge 6 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions .env
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
POSTGRES_USER="rom"
POSTGRES_PASSWORD="password"
POSTGRES_DATABASE="rom-factory"
POSTGRES_HOST_AUTH_METHOD="trust"
10 changes: 2 additions & 8 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -10,17 +10,11 @@ gem "faker", "~> 2.8"

gem "rspec", "~> 3.0"

git "https://github.com/rom-rb/rom.git", branch: "release-5.3" do
gem "rom-core"
gem "rom-changeset"
gem "rom-repository"
gem "rom"
end

group :test do
gem "rom", github: 'rom-rb/rom', branch: "main"
gem "rom-sql", github: "rom-rb/rom-sql", branch: "main"
gem "pry", "~> 0.12.0", "<= 0.13"
gem "pry-byebug", "~> 3.8", platforms: :ruby
gem "rom-sql", github: "rom-rb/rom-sql", branch: "release-3.6"

gem "jdbc-postgres", platforms: :jruby
gem "pg", "~> 0.21", platforms: :ruby
Expand Down
8 changes: 8 additions & 0 deletions docker-compose.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
version: "3"

services:
postgres:
image: postgres:latest
ports:
- "5432:5432"
env_file: .env
2 changes: 1 addition & 1 deletion lib/rom/factory/version.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@

module ROM
module Factory
VERSION = "0.11.0"
VERSION = "1.0.0.alpha1"
end
end
2 changes: 1 addition & 1 deletion rom-factory.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -31,5 +31,5 @@ Gem::Specification.new do |spec|
spec.add_runtime_dependency "dry-core", "~> 1.0"
spec.add_runtime_dependency "dry-struct", "~> 1.6"
spec.add_runtime_dependency "faker", ">= 2.0", "< 3.0"
spec.add_runtime_dependency "rom-core", "~> 5.3"
spec.add_runtime_dependency "rom", "~> 6.0.0.alpha"
end
32 changes: 18 additions & 14 deletions spec/integration/rom/factory_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -163,18 +163,18 @@
end

conf.relation(:basic_users) do
schema(infer: true) do
associations do
has_one :basic_account
end
schema(infer: true)

associations do
has_one :basic_account
end
end

conf.relation(:basic_accounts) do
schema(infer: true) do
associations do
belongs_to :basic_user
end
schema(infer: true)

associations do
belongs_to :basic_user
end
end
end
Expand Down Expand Up @@ -230,6 +230,8 @@
end

it "still allows building the parent struct" do
pending "FIXME"

basic_user = factories.structs[:basic_user]

expect(basic_user.basic_account).to respond_to(:id)
Expand Down Expand Up @@ -588,6 +590,8 @@ class Admin < ROM::Struct
let(:admin) { factories[:admin] }

it "sets up a new builder based on another with correct struct_namespace" do
pending "FIXME"

expect(jane.first_name).to eql("Jane")
expect(jane.email).to eql("[email protected]")
expect(jane).to be_kind_of(Test::Entities::User)
Expand Down Expand Up @@ -743,13 +747,13 @@ class Admin < ROM::Struct

context "custom non integer sequence primary_key" do
let(:rom) do
ROM.container(:sql, conn) do |conf|
conf.default.create_table(:custom_primary_keys) do
ROM.setup(:sql, conn) do |setup, config|
setup.default.create_table(:custom_primary_keys) do
column :custom_id, String
column :name, String
end

conf.relation(:custom_primary_keys) do
setup.relation(:custom_primary_keys) do
schema(infer: true) do
attribute :custom_id, ROM::SQL::Types::String.meta(primary_key: true)
end
Expand Down Expand Up @@ -1188,10 +1192,10 @@ class User < ROM::Struct
attribute :title, ROM::SQL::Types::String.meta(
read: ROM::SQL::Types::String.constructor(&:upcase)
)
end

associations do
belongs_to :user
end
associations do
belongs_to :user
end
end
end
Expand Down
8 changes: 4 additions & 4 deletions spec/shared/database.rb
Original file line number Diff line number Diff line change
@@ -1,18 +1,18 @@
# frozen_string_literal: true

require "rom-core"
require "rom/setup"

RSpec.shared_context "database" do
let(:conf) do
ROM::Configuration.new(:sql, DB_URI)
ROM::Setup.new(:sql, DB_URI)
end

let(:rom) do
ROM.container(conf)
ROM.setup(conf)
end

let(:conn) do
conf.gateways[:default].connection
conf.registry.gateways[:default].connection
end

let(:relations) do
Expand Down
50 changes: 25 additions & 25 deletions spec/shared/relations.rb
Original file line number Diff line number Diff line change
Expand Up @@ -39,48 +39,48 @@
end

conf.relation(:tasks) do
schema(infer: true) do
associations do
belongs_to :user
end
schema(infer: true)

associations do
belongs_to :user
end
end

conf.relation(:users) do
schema(infer: true) do
associations do
has_many :tasks
has_one :user_addresses
has_one :address, through: :user_addresses
end
schema(infer: true)

associations do
has_many :tasks
has_one :user_addresses
has_one :address, through: :user_addresses
end
end

conf.relation(:addresses) do
schema(infer: true) do
associations do
has_one :user_addresses
has_one :user, through: :user_addresses
end
schema(infer: true)

associations do
has_one :user_addresses
has_one :user, through: :user_addresses
end
end

conf.relation(:user_addresses) do
schema(infer: true) do
associations do
belongs_to :user
belongs_to :address
end
schema(infer: true)

associations do
belongs_to :user
belongs_to :address
end
end

conf.relation(:admins) do
conf.relation(:admins, dataset: :users) do
dataset { where(type: "Admin") }

schema(:users, as: :admins, infer: true) do
associations do
has_many :tasks
end
schema(:users, infer: true)

associations do
has_many :tasks
end
end

Expand Down
2 changes: 2 additions & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,9 @@
require "pry"
end

require "rom/compat"
require "rom-factory"

require "rspec"

Dir[root.join("support/*.rb").to_s].sort.each do |f|
Expand Down
66 changes: 33 additions & 33 deletions spec/unit/rom/factory/builder_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -72,10 +72,10 @@
end

conf.relation(:tasks) do
schema(infer: true) do
associations do
belongs_to :user
end
schema(infer: true)

associations do
belongs_to :user
end
end

Expand Down Expand Up @@ -155,27 +155,27 @@
end

conf.relation(:users) do
schema(infer: true) do
associations do
has_many :users, through: :users_tasks
end
schema(infer: true)

associations do
has_many :users, through: :users_tasks
end
end

conf.relation(:tasks) do
schema(infer: true) do
associations do
has_many :users, through: :users_tasks
end
schema(infer: true)

associations do
has_many :users, through: :users_tasks
end
end

conf.relation(:users_tasks) do
schema(infer: true) do
associations do
belongs_to :user
belongs_to :task
end
schema(infer: true)

associations do
belongs_to :user
belongs_to :task
end
end

Expand Down Expand Up @@ -227,18 +227,18 @@
end

conf.relation(:tasks) do
schema(infer: true) do
associations do
belongs_to :user
end
schema(infer: true)

associations do
belongs_to :user
end
end

conf.relation(:users) do
schema(infer: true) do
associations do
has_many :tasks
end
schema(infer: true)

associations do
has_many :tasks
end
end

Expand Down Expand Up @@ -293,18 +293,18 @@
end

conf.relation(:tasks) do
schema(infer: true) do
associations do
belongs_to :user
end
schema(infer: true)

associations do
belongs_to :user
end
end

conf.relation(:users) do
schema(infer: true) do
associations do
has_one :task
end
schema(infer: true)

associations do
has_one :task
end
end

Expand Down