docbrown/spec/routing/devices_routes_spec.rb
Fernando Valverde cf3bde4259
Add mobile push notifications to Forem (#12419)
* First commit with iOS PN working

* RPush cleanup worker + unique jobs config

* Remove rpush tables from schema.rb

* PR feedback

* Feature flag and test for route

* Tests and feature flag PushNotification ::Send

* Update app/controllers/devices_controller.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update spec/routing/devices_routes_spec.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* Update spec/services/push_notifications/send_spec.rb

Co-authored-by: Michael Kohl <citizen428@dev.to>

* PR feedback

* Set Rpush driver and url

* More PR feedback

* Apply suggestions from code review

Co-authored-by: Jamie Gaskins <jgaskins@gmail.com>

* PR feedback from Rhymes

* Don’t double render

* Sure

Co-authored-by: Josh Puetz <hi@joshpuetz.com>
Co-authored-by: Josh Puetz <josh@dev.to>
Co-authored-by: Michael Kohl <citizen428@dev.to>
Co-authored-by: Jamie Gaskins <jgaskins@gmail.com>
2021-03-12 14:08:18 -06:00

42 lines
1.2 KiB
Ruby

require "rails_helper"
RSpec.describe "User devices routes", type: :routing do
it "renders the user devices routes if the mobile_notifications feature flag is enabled", :aggregate_failures do
allow(FeatureFlag).to receive(:enabled?).twice.with(:mobile_notifications).and_return(true)
expect(post: devices_path).to route_to(
controller: "devices",
action: "create",
format: :json,
locale: nil,
)
expect(delete: "#{devices_path}/1").to route_to(
controller: "devices",
action: "destroy",
id: "1",
format: :json,
locale: nil,
)
end
it "does not render the user devices routes if the mobile_notifications feature flag is disabled",
:aggregate_failures do
allow(FeatureFlag).to receive(:enabled?).at_least(:twice).with(:mobile_notifications).and_return(false)
expect(post: devices_path).not_to route_to(
controller: "devices",
action: "create",
format: :json,
locale: nil,
)
expect(delete: "#{devices_path}/1").not_to route_to(
controller: "devices",
action: "destroy",
id: "1",
format: :json,
locale: nil,
)
end
end