imports_controller_spec.rb 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. require 'rails_helper'
  2. RSpec.describe Settings::ImportsController, type: :controller do
  3. render_views
  4. before do
  5. sign_in Fabricate(:user), scope: :user
  6. end
  7. describe "GET #show" do
  8. it "returns http success" do
  9. get :show
  10. expect(response).to have_http_status(200)
  11. end
  12. end
  13. describe 'POST #create' do
  14. it 'redirects to settings path with successful following import' do
  15. service = double(call: nil)
  16. allow(ResolveAccountService).to receive(:new).and_return(service)
  17. post :create, params: {
  18. import: {
  19. type: 'following',
  20. data: fixture_file_upload('files/imports.txt')
  21. }
  22. }
  23. expect(response).to redirect_to(settings_import_path)
  24. end
  25. it 'redirects to settings path with successful blocking import' do
  26. service = double(call: nil)
  27. allow(ResolveAccountService).to receive(:new).and_return(service)
  28. post :create, params: {
  29. import: {
  30. type: 'blocking',
  31. data: fixture_file_upload('files/imports.txt')
  32. }
  33. }
  34. expect(response).to redirect_to(settings_import_path)
  35. end
  36. end
  37. end