diff options
author | ThibG <thib@sitedethib.com> | 2019-12-19 16:07:21 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2019-12-19 16:07:21 +0100 |
commit | f064cd4fb8057af04f0f1db6a98fc45935811e25 (patch) | |
tree | 33375e965ba16e3491f3bc3cd733ff2331a48220 /spec/controllers | |
parent | 66ab1f83b0d342341181e0c88da83c966391fc0c (diff) | |
parent | dace054c0680b3ac6e0da31f3ffa501cd8840fbf (diff) |
Merge pull request #1255 from ThibG/glitch-soc/merge-upstream
Merge upstream changes
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 |