Skip to content

Commit 390f201

Browse files
author
Lee Richmond
committed
Fix Vandal loading issue
1 parent c33e1d2 commit 390f201

File tree

4 files changed

+8
-3
lines changed

4 files changed

+8
-3
lines changed

lib/graphiti/resource/configuration.rb

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -104,6 +104,11 @@ def self.inherited(klass)
104104
klass.attribute :id, :integer_id
105105
end
106106
klass.stat total: [:count]
107+
108+
if defined?(::Rails) && ::Rails.env.development?
109+
# Avoid adding dupe resources when re-autoloading
110+
Graphiti.resources.reject! { |r| r.name == klass.name }
111+
end
107112
Graphiti.resources << klass
108113
end
109114
end

spec/remote_resource_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -208,7 +208,7 @@ def request_headers
208208

209209
context "when Rails" do
210210
before do
211-
stub_const("Rails", true)
211+
stub_const("Rails", double.as_null_object)
212212
end
213213

214214
it "forwards Authorization header to the remote endpoint" do

spec/resource_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,7 @@
7171
before do
7272
rails = double \
7373
application: double(config: double(eager_load: eager_load))
74-
stub_const("Rails", rails)
74+
stub_const("Rails", rails.as_null_object)
7575
end
7676

7777
context "and eager loading" do

spec/schema_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -738,7 +738,7 @@ def self.name
738738
context "when Rails is defined" do
739739
let(:rails) do
740740
app = double(eager_load!: true, config: double.as_null_object)
741-
double(application: app)
741+
double(application: app).as_null_object
742742
end
743743

744744
before do

0 commit comments

Comments
 (0)