diff options
author | ThibG <thib@sitedethib.com> | 2019-12-17 13:31:56 +0100 |
---|---|---|
committer | Eugen Rochko <eugen@zeonfederated.com> | 2019-12-17 13:31:56 +0100 |
commit | da2143b3089ec16fca449b97acbfb65acfe92197 (patch) | |
tree | efce61c5a3092442d477bc555fe1f63becbc52d6 /spec/controllers | |
parent | 3830c0b74168070cdd410d311ba85a3b323bca9f (diff) |
Fixes featured hashtag setting page erroring out instead of rejecting invalid tags (#12436)
* Revert "Fix ignoring whole status because of one invalid hashtag (#11621)" This reverts commit dff46b260b2f7d765d254c84a4b89105c7de5e97. * Fix statuses being rejected because of invalid hashtag names * Add spec for invalid hashtag names in statuses * Add test for featured tags controller
Diffstat (limited to 'spec/controllers')
-rw-r--r-- | spec/controllers/settings/featured_tags_controller_spec.rb | 43 |
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 |