about summary refs log tree commit diff
path: root/spec/controllers/settings
diff options
context:
space:
mode:
authorThibaut Girka <thib@sitedethib.com>2019-12-19 13:52:54 +0100
committerThibaut Girka <thib@sitedethib.com>2019-12-19 13:52:54 +0100
commitab5ff638f2968e3f434e504c7caab370bf71c9c0 (patch)
tree172f2c2fc8192688b960dd2bd42ea126ad9245fb /spec/controllers/settings
parent66ab1f83b0d342341181e0c88da83c966391fc0c (diff)
parent902c6bed5aab12c2e97af3452f122247777226af (diff)
Merge branch 'master' into glitch-soc/master
Conflicts:
- `config/locales/en.yml`
  No real conflict, upstream added a translatable string “too close” to
  one specific to glitch-soc
- `lib/mastodon/statuses_cli.rb`
  Fixes made upstream, while changed in glitch-soc to keep bookmarked statuses
- `package.json`
  No real conflict, additional dependency in glitch-soc
Diffstat (limited to 'spec/controllers/settings')
-rw-r--r--spec/controllers/settings/featured_tags_controller_spec.rb43
1 files changed, 43 insertions, 0 deletions
diff --git a/spec/controllers/settings/featured_tags_controller_spec.rb b/spec/controllers/settings/featured_tags_controller_spec.rb
new file mode 100644
index 000000000..33b87f9f6
--- /dev/null
+++ b/spec/controllers/settings/featured_tags_controller_spec.rb
@@ -0,0 +1,43 @@
+require 'rails_helper'
+
+describe Settings::FeaturedTagsController do
+  render_views
+
+  shared_examples 'authenticate user' do
+    it 'redirects to sign_in page' do
+      is_expected.to redirect_to new_user_session_path
+    end
+  end
+
+  describe 'POST #create' do
+    context 'when user is not sign in' do
+      subject { post :create }
+
+      it_behaves_like 'authenticate user'
+    end
+
+    context 'when user is sign in' do
+      subject { post :create, params: { featured_tag: params } }
+
+      let(:user) { Fabricate(:user, password: '12345678') }
+
+      before { sign_in user, scope: :user }
+
+      context 'when parameter is valid' do
+        let(:params) { { name: 'test' } }
+
+        it 'creates featured tag' do
+          expect { subject }.to change { user.account.featured_tags.count }.by(1)
+        end
+      end
+
+      context 'when parameter is invalid' do
+        let(:params) { { name: 'test, #foo !bleh' } }
+
+        it 'renders new' do
+          expect(subject).to render_template :index
+        end
+      end
+    end
+  end
+end