aboutsummaryrefslogtreecommitdiff
path: root/test/controllers/govuk_guix/revisions_controller_test.rb
blob: 6f08489e2f1f344e00b9356e550e7512675e5744 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
require 'integration_test_helper'

class GovukGuix::RevisionsControllerTest < ActionDispatch::IntegrationTest
  setup do
    login_as User.new(name: 'Test', email: 'test@example.com')
  end

  test 'show' do
    revision = GovukGuix::Revision.create(
      commit_hash: 'test-commit-hash',
      store_path: 'test-store-path'
    )

    get govuk_guix_revision_path(revision)

    assert_response :success
  end

  test 'enqueue_fetch_revision' do
    revision = 'test-revision'

    Guix.stubs(:available_locally?).returns(true)
    GovukGuix::FetchRevisionJob.expects(:enqueue).with(revision, {})

    post(
      enqueue_fetch_govuk_guix_revision_path,
      params: {
        revision: revision
      }
    )

    assert_response :redirect
    follow_redirect!
    assert_response :success
  end
end