Sha256: d4a96b0cbb2d40220f436ee22e3dca428c116824b209578d13f7cd761de5924b

Contents?: true

Size: 1.19 KB

Versions: 5

Compression:

Stored size: 1.19 KB

Contents

# frozen_string_literal: true
require 'rails_helper'

RSpec.describe AtomicCms::MediaController, type: :controller do
  # Previously the engines guide contained an incorrect example that
  # recommended using the `use_route` option to test an engine's controllers
  # within the dummy application. That recommendation was incorrect and has
  # since been corrected. Instead, you should override the `@routes` variable
  # in the test case with `Foo::Engine.routes`.
  before { @routes = AtomicCms::Engine.routes }

  it 'accepts a post request and fails with bad data' do
    scrubber = double('scrubber')
    allow(MediaScrubber).to receive(:new).and_return(scrubber)
    allow(scrubber).to receive(:save).and_return(false)
    allow(scrubber).to receive(:errors)

    post :create, file: double('file')

    expect(response).to have_http_status(:unprocessable_entity)
  end

  it 'accepts a post with a file' do
    scrubber = double('scrubber', save: true, url: 'http://www.google.com')
    expect(MediaScrubber).to receive(:new).and_return(scrubber)

    post :create, file: double('file')

    expect(response).to have_http_status(:created)
    expect(response.body).to include('http://www.google.com')
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
atomic_cms-0.4.0 spec/controllers/media_controller_spec.rb
atomic_cms-0.3.3 spec/controllers/media_controller_spec.rb
atomic_cms-0.3.2 spec/controllers/media_controller_spec.rb
atomic_cms-0.3.1 spec/controllers/media_controller_spec.rb
atomic_cms-0.3.0 spec/controllers/media_controller_spec.rb