about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/api/web/push_subscriptions_controller_spec.rb26
-rw-r--r--spec/views/about/_contact.html.haml_spec.rb7
-rw-r--r--spec/views/about/_links.html.haml_spec.rb38
-rw-r--r--spec/workers/pubsubhubbub/confirmation_worker_spec.rb2
-rw-r--r--spec/workers/pubsubhubbub/delivery_worker_spec.rb1
5 files changed, 10 insertions, 64 deletions
diff --git a/spec/controllers/api/web/push_subscriptions_controller_spec.rb b/spec/controllers/api/web/push_subscriptions_controller_spec.rb
index 871176a07..7e83b801d 100644
--- a/spec/controllers/api/web/push_subscriptions_controller_spec.rb
+++ b/spec/controllers/api/web/push_subscriptions_controller_spec.rb
@@ -9,7 +9,7 @@ describe Api::Web::PushSubscriptionsController do
 
   let(:create_payload) do
     {
-      data: {
+      subscription: {
         endpoint: 'https://fcm.googleapis.com/fcm/send/fiuH06a27qE:APA91bHnSiGcLwdaxdyqVXNDR9w1NlztsHb6lyt5WDKOC_Z_Q8BlFxQoR8tWFSXUIDdkyw0EdvxTu63iqamSaqVSevW5LfoFwojws8XYDXv_NRRLH6vo2CdgiN4jgHv5VLt2A8ah6lUX',
         keys: {
           p256dh: 'BEm_a0bdPDhf0SOsrnB2-ategf1hHoCnpXgQsFj5JCkcoMrMt2WHoPfEYOYPzOIs9mZE8ZUaD7VA5vouy0kEkr8=',
@@ -36,25 +36,17 @@ describe Api::Web::PushSubscriptionsController do
     it 'saves push subscriptions' do
       sign_in(user)
 
-      stub_request(:post, create_payload[:data][:endpoint]).to_return(status: 200)
+      stub_request(:post, create_payload[:subscription][:endpoint]).to_return(status: 200)
 
       post :create, format: :json, params: create_payload
 
       user.reload
 
-      push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:data][:endpoint])
-
-      expect(push_subscription['endpoint']).to eq(create_payload[:data][:endpoint])
-      expect(push_subscription['key_p256dh']).to eq(create_payload[:data][:keys][:p256dh])
-      expect(push_subscription['key_auth']).to eq(create_payload[:data][:keys][:auth])
-    end
+      push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:subscription][:endpoint])
 
-    it 'sends welcome notification' do
-      sign_in(user)
-
-      stub_request(:post, create_payload[:data][:endpoint]).to_return(status: 200)
-
-      post :create, format: :json, params: create_payload
+      expect(push_subscription['endpoint']).to eq(create_payload[:subscription][:endpoint])
+      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
   end
 
@@ -62,15 +54,15 @@ describe Api::Web::PushSubscriptionsController do
     it 'changes alert settings' do
       sign_in(user)
 
-      stub_request(:post, create_payload[:data][:endpoint]).to_return(status: 200)
+      stub_request(:post, create_payload[:subscription][:endpoint]).to_return(status: 200)
 
       post :create, format: :json, params: create_payload
 
-      alerts_payload[:id] = Web::PushSubscription.find_by(endpoint: create_payload[:data][:endpoint]).id
+      alerts_payload[:id] = Web::PushSubscription.find_by(endpoint: create_payload[:subscription][:endpoint]).id
 
       put :update, format: :json, params: alerts_payload
 
-      push_subscription = Web::PushSubscription.find_by(endpoint: create_payload[:data][:endpoint])
+      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])
diff --git a/spec/views/about/_contact.html.haml_spec.rb b/spec/views/about/_contact.html.haml_spec.rb
index d2e7a4598..25ba15794 100644
--- a/spec/views/about/_contact.html.haml_spec.rb
+++ b/spec/views/about/_contact.html.haml_spec.rb
@@ -31,12 +31,5 @@ describe 'about/_contact.html.haml' do
 
       expect(rendered).to have_content('admin@example.com')
     end
-
-    it 'does not show info when email is missing' do
-      contact = double(site_contact_email: nil, contact_account: nil)
-      render 'about/contact', contact: contact
-
-      expect(rendered).not_to have_content(I18n.t('about.business_email'))
-    end
   end
 end
diff --git a/spec/views/about/_links.html.haml_spec.rb b/spec/views/about/_links.html.haml_spec.rb
deleted file mode 100644
index 2d7f7467a..000000000
--- a/spec/views/about/_links.html.haml_spec.rb
+++ /dev/null
@@ -1,38 +0,0 @@
-# frozen_string_literal: true
-
-require 'rails_helper'
-
-describe 'about/_links.html.haml' do
-  context 'when signed in' do
-    before do
-      allow(view).to receive(:user_signed_in?).and_return(true)
-    end
-
-    it 'does not show sign in link' do
-      render 'about/links', instance: InstancePresenter.new
-
-      expect(rendered).to have_content(I18n.t('about.get_started'))
-      expect(rendered).not_to have_content(I18n.t('auth.login'))
-    end
-  end
-
-  context 'when signed out' do
-    before do
-      allow(view).to receive(:user_signed_in?).and_return(false)
-    end
-
-    it 'shows get started link when registrations are allowed' do
-      render 'about/links', instance: double(open_registrations: true)
-
-      expect(rendered).to have_content(I18n.t('about.get_started'))
-      expect(rendered).to have_content(I18n.t('auth.login'))
-    end
-
-    it 'hides get started link when registrations are closed' do
-      render 'about/links', instance: double(open_registrations: false)
-
-      expect(rendered).not_to have_content(I18n.t('about.get_started'))
-      expect(rendered).to have_content(I18n.t('auth.login'))
-    end
-  end
-end
diff --git a/spec/workers/pubsubhubbub/confirmation_worker_spec.rb b/spec/workers/pubsubhubbub/confirmation_worker_spec.rb
index 8f66b4520..1eecdd2b5 100644
--- a/spec/workers/pubsubhubbub/confirmation_worker_spec.rb
+++ b/spec/workers/pubsubhubbub/confirmation_worker_spec.rb
@@ -83,6 +83,6 @@ describe Pubsubhubbub::ConfirmationWorker do
   end
 
   def http_headers
-    { 'Connection' => 'close', 'Host' => 'example.com', 'User-Agent' => 'http.rb/2.2.2 (Mastodon/1.4.7; +https://cb6e6126.ngrok.io/)' }
+    { 'Connection' => 'close', 'Host' => 'example.com' }
   end
 end
diff --git a/spec/workers/pubsubhubbub/delivery_worker_spec.rb b/spec/workers/pubsubhubbub/delivery_worker_spec.rb
index b72001568..c0e0d5186 100644
--- a/spec/workers/pubsubhubbub/delivery_worker_spec.rb
+++ b/spec/workers/pubsubhubbub/delivery_worker_spec.rb
@@ -59,7 +59,6 @@ describe Pubsubhubbub::DeliveryWorker do
         'Content-Type' => 'application/atom+xml',
         'Host' => 'example.com',
         'Link' => "<https://#{Rails.configuration.x.local_domain}/api/push>; rel=\"hub\", <https://#{Rails.configuration.x.local_domain}/users/#{subscription.account.username}.atom>; rel=\"self\"",
-        'User-Agent' => 'http.rb/2.2.2 (Mastodon/1.4.7; +https://cb6e6126.ngrok.io/)',
       }.tap do |basic|
         known_digest = OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new('sha1'), subscription.secret.to_s, payload)
         basic.merge('X-Hub-Signature' => "sha1=#{known_digest}") if subscription.secret?