You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

71 lines
1.6 KiB

  1. # frozen_string_literal: true
  2. require 'rails_helper'
  3. RSpec.describe Admin::TagsController, type: :controller do
  4. render_views
  5. before do
  6. sign_in Fabricate(:user, admin: true)
  7. end
  8. describe 'GET #index' do
  9. before do
  10. account_tag_stat = Fabricate(:tag).account_tag_stat
  11. account_tag_stat.update(hidden: hidden, accounts_count: 1)
  12. get :index, params: { hidden: hidden }
  13. end
  14. context 'with hidden tags' do
  15. let(:hidden) { true }
  16. it 'returns status 200' do
  17. expect(response).to have_http_status(200)
  18. end
  19. end
  20. context 'without hidden tags' do
  21. let(:hidden) { false }
  22. it 'returns status 200' do
  23. expect(response).to have_http_status(200)
  24. end
  25. end
  26. end
  27. describe 'POST #hide' do
  28. let(:tag) { Fabricate(:tag) }
  29. before do
  30. tag.account_tag_stat.update(hidden: false)
  31. post :hide, params: { id: tag.id }
  32. end
  33. it 'hides tag' do
  34. tag.reload
  35. expect(tag).to be_hidden
  36. end
  37. it 'redirects to admin_tags_path' do
  38. expect(response).to redirect_to(admin_tags_path(controller.instance_variable_get(:@filter_params)))
  39. end
  40. end
  41. describe 'POST #unhide' do
  42. let(:tag) { Fabricate(:tag) }
  43. before do
  44. tag.account_tag_stat.update(hidden: true)
  45. post :unhide, params: { id: tag.id }
  46. end
  47. it 'unhides tag' do
  48. tag.reload
  49. expect(tag).not_to be_hidden
  50. end
  51. it 'redirects to admin_tags_path' do
  52. expect(response).to redirect_to(admin_tags_path(controller.instance_variable_get(:@filter_params)))
  53. end
  54. end
  55. end