diff options
author | abcang <abcang1015@gmail.com> | 2017-12-09 10:31:37 +0900 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2017-12-09 02:31:37 +0100 |
commit | 99242b92bcc1965b2a72c01216bce7c232322f15 (patch) | |
tree | 708cb3769f5748e753a9d203f26652b1c2ecdff6 /spec/controllers | |
parent | ec3b449baa122cb881556422f1b3d586ad5a9a6c (diff) |
Keep WebPush settings (#5879)
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/api/web/push_subscriptions_controller_spec.rb | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/spec/controllers/api/web/push_subscriptions_controller_spec.rb b/spec/controllers/api/web/push_subscriptions_controller_spec.rb index 7e83b801d..bbf94c5c6 100644 --- a/spec/controllers/api/web/push_subscriptions_controller_spec.rb +++ b/spec/controllers/api/web/push_subscriptions_controller_spec.rb @@ -48,6 +48,23 @@ describe Api::Web::PushSubscriptionsController do expect(push_subscription['key_p256dh']).to eq(create_payload[:subscription][:keys][:p256dh]) expect(push_subscription['key_auth']).to eq(create_payload[:subscription][:keys][:auth]) end + + context 'with initial data' do + it 'saves alert settings' do + sign_in(user) + + stub_request(:post, create_payload[:subscription][:endpoint]).to_return(status: 200) + + post :create, format: :json, params: create_payload.merge(alerts_payload) + + push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:subscription][:endpoint]) + + expect(push_subscription.data['follow']).to eq(alerts_payload[:data][:follow]) + expect(push_subscription.data['favourite']).to eq(alerts_payload[:data][:favourite]) + expect(push_subscription.data['reblog']).to eq(alerts_payload[:data][:reblog]) + expect(push_subscription.data['mention']).to eq(alerts_payload[:data][:mention]) + end + end end describe 'PUT #update' do |