|
55 | 55 | expect(AnyCable).to have_received(:broadcast).with("graphql-subscriptions:#{fingerprint}", expected_result) |
56 | 56 | end |
57 | 57 |
|
58 | | - context "with multiple subscriptions in one query" do |
| 58 | + context "triggering update event" do |
59 | 59 | let(:query) do |
60 | 60 | <<~GRAPHQL |
61 | 61 | subscription SomeSubscription { |
62 | | - productCreated { id title } |
63 | 62 | productUpdated { id } |
64 | 63 | } |
65 | 64 | GRAPHQL |
66 | 65 | end |
67 | 66 |
|
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) |
74 | 71 | end |
| 72 | + end |
75 | 73 |
|
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 |
82 | 82 |
|
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 |
86 | 88 |
|
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) |
89 | 94 | end |
90 | 95 | end |
91 | 96 |
|
|
0 commit comments