about summary refs log tree commit diff
path: root/spec/controllers
diff options
context:
space:
mode:
authorClaire <claire.github-309c@sitedethib.com>2022-11-14 08:35:55 +0100
committerClaire <claire.github-309c@sitedethib.com>2022-11-14 08:35:55 +0100
commit32c70d2f09e27c474b7e20ef3e3b34f5a7f50121 (patch)
tree117e952f835329eadc0095e809427f7af5be9631 /spec/controllers
parent81b1d32d5b618daa4003b8de8292ae4dd3e656f6 (diff)
parentb59ce0a60ff4f90bb16a8c3338ad37218af052b8 (diff)
Merge branch 'main' into glitch-soc/merge-upstream
Conflicts:
- `app/views/admin/announcements/edit.html.haml`:
  Upstream change too close to theming-related glitch-soc change.
  Ported upstream changes.
- `app/views/admin/announcements/new.html.haml`
  Upstream change too close to theming-related glitch-soc change.
  Ported upstream changes.
Diffstat (limited to 'spec/controllers')
-rw-r--r--spec/controllers/api/v1/admin/domain_allows_controller_spec.rb44
-rw-r--r--spec/controllers/api/v2/filters/keywords_controller_spec.rb (renamed from spec/controllers/api/v1/filters/keywords_controller_spec.rb)2
-rw-r--r--spec/controllers/api/v2/filters/statuses_controller_spec.rb (renamed from spec/controllers/api/v1/filters/statuses_controller_spec.rb)2
3 files changed, 30 insertions, 18 deletions
diff --git a/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb b/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb
index 26a391a60..8100363f6 100644
--- a/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb
+++ b/spec/controllers/api/v1/admin/domain_allows_controller_spec.rb
@@ -94,25 +94,37 @@ RSpec.describe Api::V1::Admin::DomainAllowsController, type: :controller do
   describe 'POST #create' do
     let!(:domain_allow) { Fabricate(:domain_allow, domain: 'example.com') }
 
-    before do
-      post :create, params: { domain: 'foo.bar.com' }
-    end
-
-    it_behaves_like 'forbidden for wrong scope', 'write:statuses'
-    it_behaves_like 'forbidden for wrong role', ''
-    it_behaves_like 'forbidden for wrong role', 'Moderator'
-
-    it 'returns http success' do
-      expect(response).to have_http_status(200)
+    context do
+      before do
+        post :create, params: { domain: 'foo.bar.com' }
+      end
+
+      it_behaves_like 'forbidden for wrong scope', 'write:statuses'
+      it_behaves_like 'forbidden for wrong role', ''
+      it_behaves_like 'forbidden for wrong role', 'Moderator'
+
+      it 'returns http success' do
+        expect(response).to have_http_status(200)
+      end
+
+      it 'returns expected domain name' do
+        json = body_as_json
+        expect(json[:domain]).to eq 'foo.bar.com'
+      end
+
+      it 'creates a domain block' do
+        expect(DomainAllow.find_by(domain: 'foo.bar.com')).to_not be_nil
+      end
     end
 
-    it 'returns expected domain name' do
-      json = body_as_json
-      expect(json[:domain]).to eq 'foo.bar.com'
-    end
+    context 'with invalid domain name' do
+      before do
+        post :create, params: { domain: 'foo bar' }
+      end
 
-    it 'creates a domain block' do
-      expect(DomainAllow.find_by(domain: 'foo.bar.com')).to_not be_nil
+      it 'returns http unprocessable entity' do
+        expect(response).to have_http_status(422)
+      end
     end
   end
 end
diff --git a/spec/controllers/api/v1/filters/keywords_controller_spec.rb b/spec/controllers/api/v2/filters/keywords_controller_spec.rb
index aecb4e41c..1201a4ca2 100644
--- a/spec/controllers/api/v1/filters/keywords_controller_spec.rb
+++ b/spec/controllers/api/v2/filters/keywords_controller_spec.rb
@@ -1,6 +1,6 @@
 require 'rails_helper'
 
-RSpec.describe Api::V1::Filters::KeywordsController, type: :controller do
+RSpec.describe Api::V2::Filters::KeywordsController, type: :controller do
   render_views
 
   let(:user)         { Fabricate(:user) }
diff --git a/spec/controllers/api/v1/filters/statuses_controller_spec.rb b/spec/controllers/api/v2/filters/statuses_controller_spec.rb
index 3b2399dd8..9740c1eb3 100644
--- a/spec/controllers/api/v1/filters/statuses_controller_spec.rb
+++ b/spec/controllers/api/v2/filters/statuses_controller_spec.rb
@@ -1,6 +1,6 @@
 require 'rails_helper'
 
-RSpec.describe Api::V1::Filters::StatusesController, type: :controller do
+RSpec.describe Api::V2::Filters::StatusesController, type: :controller do
   render_views
 
   let(:user)         { Fabricate(:user) }