From 390f201318cbf7a11118adab71882633ba47458e Mon Sep 17 00:00:00 2001 From: Lee Richmond Date: Mon, 27 May 2019 11:50:53 -0400 Subject: [PATCH 1/2] Fix Vandal loading issue --- lib/graphiti/resource/configuration.rb | 5 +++++ spec/remote_resource_spec.rb | 2 +- spec/resource_spec.rb | 2 +- spec/schema_spec.rb | 2 +- 4 files changed, 8 insertions(+), 3 deletions(-) diff --git a/lib/graphiti/resource/configuration.rb b/lib/graphiti/resource/configuration.rb index f8835a60..47225ef8 100644 --- a/lib/graphiti/resource/configuration.rb +++ b/lib/graphiti/resource/configuration.rb @@ -104,6 +104,11 @@ def self.inherited(klass) klass.attribute :id, :integer_id end klass.stat total: [:count] + + if defined?(::Rails) && ::Rails.env.development? + # Avoid adding dupe resources when re-autoloading + Graphiti.resources.reject! { |r| r.name == klass.name } + end Graphiti.resources << klass end end diff --git a/spec/remote_resource_spec.rb b/spec/remote_resource_spec.rb index a3380aa7..5d67bb73 100644 --- a/spec/remote_resource_spec.rb +++ b/spec/remote_resource_spec.rb @@ -208,7 +208,7 @@ def request_headers context "when Rails" do before do - stub_const("Rails", true) + stub_const("Rails", double.as_null_object) end it "forwards Authorization header to the remote endpoint" do diff --git a/spec/resource_spec.rb b/spec/resource_spec.rb index 0d66d9f3..b007e59f 100644 --- a/spec/resource_spec.rb +++ b/spec/resource_spec.rb @@ -71,7 +71,7 @@ before do rails = double \ application: double(config: double(eager_load: eager_load)) - stub_const("Rails", rails) + stub_const("Rails", rails.as_null_object) end context "and eager loading" do diff --git a/spec/schema_spec.rb b/spec/schema_spec.rb index 191657d5..7d0f1dd2 100644 --- a/spec/schema_spec.rb +++ b/spec/schema_spec.rb @@ -738,7 +738,7 @@ def self.name context "when Rails is defined" do let(:rails) do app = double(eager_load!: true, config: double.as_null_object) - double(application: app) + double(application: app).as_null_object end before do From bfa4932194a456166be38f7534cbb544be605003 Mon Sep 17 00:00:00 2001 From: Lee Richmond Date: Mon, 27 May 2019 11:52:20 -0400 Subject: [PATCH 2/2] bump version --- lib/graphiti/version.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/graphiti/version.rb b/lib/graphiti/version.rb index 251c7bee..7f6acede 100644 --- a/lib/graphiti/version.rb +++ b/lib/graphiti/version.rb @@ -1,3 +1,3 @@ module Graphiti - VERSION = "1.2.0" + VERSION = "1.2.1" end