Skip to content

Commit 42071a9

Browse files
committed
* upgrade rubocop + upgrade for graphql ruby + ci upgrades
1 parent db3b672 commit 42071a9

7 files changed

Lines changed: 48 additions & 32 deletions

File tree

.rubocop.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ inherit_mode:
22
merge:
33
- Exclude
44

5-
require:
6-
- standard
5+
plugins:
76
- standard-custom
87
- standard-performance
98
- rubocop-performance

.rubocop/rspec.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
require:
1+
plugins:
22
- rubocop-rspec
33

44
# Disable all cops by default,

gemfiles/rubocop.gemfile

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
source "https://rubygems.org" do
2-
gem "standard", "~> 1.28"
1+
source "https://rubygems.org"
32

4-
gem "rubocop-rspec"
5-
end
3+
gem "standard"
4+
gem "rubocop-rspec"

graphql-anycable.gemspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,7 +34,7 @@ Gem::Specification.new do |spec|
3434
spec.add_dependency "redis", ">= 4.2.0"
3535

3636
spec.add_development_dependency "anycable-rails"
37-
spec.add_development_dependency "bundler", "~> 2.0"
37+
spec.add_development_dependency "bundler", ">= 2.0"
3838
spec.add_development_dependency "rack"
3939
spec.add_development_dependency "railties"
4040
spec.add_development_dependency "rake", ">= 12.3.3"

lib/graphql/subscriptions/anycable_subscriptions.rb

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,6 @@
44
require "graphql/subscriptions"
55
require "graphql/anycable/errors"
66

7-
# rubocop: disable Metrics/AbcSize, Metrics/LineLength, Metrics/MethodLength
8-
97
# A subscriptions implementation that sends data as AnyCable broadcastings.
108
#
119
# Since AnyCable is aimed to be compatible with ActionCable, this adapter
@@ -249,4 +247,3 @@ def redis_key(prefix)
249247
end
250248
end
251249
end
252-
# rubocop: enable Metrics/AbcSize, Metrics/LineLength, Metrics/MethodLength

spec/graphql/anycable_spec.rb

Lines changed: 24 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -55,37 +55,42 @@
5555
expect(AnyCable).to have_received(:broadcast).with("graphql-subscriptions:#{fingerprint}", expected_result)
5656
end
5757

58-
context "with multiple subscriptions in one query" do
58+
context "triggering update event" do
5959
let(:query) do
6060
<<~GRAPHQL
6161
subscription SomeSubscription {
62-
productCreated { id title }
6362
productUpdated { id }
6463
}
6564
GRAPHQL
6665
end
6766

68-
context "triggering update event" do
69-
it "broadcasts message only for update event" do
70-
subject
71-
AnycableSchema.subscriptions.trigger(:product_updated, {}, {id: 1, title: "foo"})
72-
expect(AnyCable).to have_received(:broadcast).with("graphql-subscriptions:#{fingerprint}", expected_result)
73-
end
67+
it "broadcasts message only for update event" do
68+
subject
69+
AnycableSchema.subscriptions.trigger(:product_updated, {}, {id: 1, title: "foo"})
70+
expect(AnyCable).to have_received(:broadcast).with("graphql-subscriptions:#{fingerprint}", expected_result)
7471
end
72+
end
7573

76-
context "triggering create event" do
77-
let(:expected_result) do
78-
<<~JSON.strip
79-
{"result":{"data":{"productCreated":{"id":"1","title":"Gravizapa"}}},"more":true}
80-
JSON
81-
end
74+
context "triggering create event" do
75+
let(:query) do
76+
<<~GRAPHQL
77+
subscription SomeSubscription {
78+
productCreated { id title }
79+
}
80+
GRAPHQL
81+
end
8282

83-
it "broadcasts message only for create event" do
84-
subject
85-
AnycableSchema.subscriptions.trigger(:product_created, {}, {id: 1, title: "Gravizapa"})
83+
let(:expected_result) do
84+
<<~JSON.strip
85+
{"result":{"data":{"productCreated":{"id":"1","title":"Gravizapa"}}},"more":true}
86+
JSON
87+
end
8688

87-
expect(AnyCable).to have_received(:broadcast).with("graphql-subscriptions:#{fingerprint}", expected_result)
88-
end
89+
it "broadcasts message only for create event" do
90+
subject
91+
AnycableSchema.subscriptions.trigger(:product_created, {}, {id: 1, title: "Gravizapa"})
92+
93+
expect(AnyCable).to have_received(:broadcast).with("graphql-subscriptions:#{fingerprint}", expected_result)
8994
end
9095
end
9196

spec/graphql/stats_spec.rb

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,12 +5,19 @@
55
let(:query) do
66
<<~GRAPHQL
77
subscription SomeSubscription {
8-
productCreated { id title }
98
productUpdated { id }
109
}
1110
GRAPHQL
1211
end
1312

13+
let(:query2) do
14+
<<~GRAPHQL
15+
subscription SomeSubscription {
16+
productCreated { id title }
17+
}
18+
GRAPHQL
19+
end
20+
1421
let(:channel) do
1522
socket = double("Socket", istate: AnyCable::Socket::State.new({}))
1623
connection = double("Connection", anycable_socket: socket)
@@ -22,12 +29,21 @@
2229
end
2330

2431
before do
25-
AnycableSchema.execute(
32+
res = AnycableSchema.execute(
2633
query: query,
2734
context: {channel: channel, subscription_id: subscription_id},
2835
variables: {},
2936
operation_name: "SomeSubscription"
3037
)
38+
expect(res.to_h.fetch("errors", [])).to be_empty
39+
40+
res2 = AnycableSchema.execute(
41+
query: query2,
42+
context: {channel: channel, subscription_id: subscription_id},
43+
variables: {},
44+
operation_name: "SomeSubscription"
45+
)
46+
expect(res2.to_h.fetch("errors", [])).to be_empty
3147
end
3248

3349
context "when include_subscriptions is false" do

0 commit comments

Comments
 (0)