about summary refs log tree commit diff
path: root/spec
diff options
context:
space:
mode:
Diffstat (limited to 'spec')
-rw-r--r--spec/controllers/settings/follower_domains_controller_spec.rb34
-rw-r--r--spec/controllers/settings/preferences_controller_spec.rb6
-rw-r--r--spec/rails_helper.rb2
3 files changed, 38 insertions, 4 deletions
diff --git a/spec/controllers/settings/follower_domains_controller_spec.rb b/spec/controllers/settings/follower_domains_controller_spec.rb
new file mode 100644
index 000000000..1afdb9757
--- /dev/null
+++ b/spec/controllers/settings/follower_domains_controller_spec.rb
@@ -0,0 +1,34 @@
+require 'rails_helper'
+
+describe Settings::FollowerDomainsController do
+  let(:user) { Fabricate(:user) }
+
+  before do
+    sign_in user, scope: :user
+  end
+
+  describe 'GET #show' do
+    it 'returns http success' do
+      get :show
+      expect(response).to have_http_status(:success)
+    end
+  end
+
+  describe 'PATCH #update' do
+    let(:poopfeast) { Fabricate(:account, username: 'poopfeast', domain: 'example.com', salmon_url: 'http://example.com/salmon') }
+
+    before do
+      stub_request(:post, 'http://example.com/salmon').to_return(status: 200)
+      poopfeast.follow!(user.account)
+      patch :update, params: { select: ['example.com'] }
+    end
+
+    it 'redirects back to followers page' do
+      expect(response).to redirect_to(settings_follower_domains_path)
+    end
+
+    it 'soft-blocks followers from selected domains' do
+      expect(poopfeast.following?(user.account)).to be false
+    end
+  end
+end
diff --git a/spec/controllers/settings/preferences_controller_spec.rb b/spec/controllers/settings/preferences_controller_spec.rb
index cdf595d4d..0d3dc059a 100644
--- a/spec/controllers/settings/preferences_controller_spec.rb
+++ b/spec/controllers/settings/preferences_controller_spec.rb
@@ -2,6 +2,7 @@ require 'rails_helper'
 
 describe Settings::PreferencesController do
   let(:user) { Fabricate(:user) }
+
   before do
     sign_in user, scope: :user
   end
@@ -9,13 +10,12 @@ describe Settings::PreferencesController do
   describe 'GET #show' do
     it 'returns http success' do
       get :show
-
       expect(response).to have_http_status(:success)
     end
   end
 
   describe 'PUT #update' do
-    it 'udpates the user record' do
+    it 'updates the user record' do
       put :update, params: { user: { locale: 'en' } }
 
       expect(response).to redirect_to(settings_preferences_path)
@@ -31,7 +31,7 @@ describe Settings::PreferencesController do
         user: {
           setting_boost_modal: '1',
           notification_emails: { follow: '1' },
-          interactions: { must_be_follower: '0' }
+          interactions: { must_be_follower: '0' },
         }
       }
 
diff --git a/spec/rails_helper.rb b/spec/rails_helper.rb
index 60d45ddc0..4ddc6d032 100644
--- a/spec/rails_helper.rb
+++ b/spec/rails_helper.rb
@@ -12,7 +12,7 @@ require 'capybara/rspec'
 Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
 
 ActiveRecord::Migration.maintain_test_schema!
-WebMock.disable_net_connect!(allow: 'localhost:7575')
+WebMock.disable_net_connect!
 Sidekiq::Testing.inline!
 
 RSpec.configure do |config|