source stringclasses 1
value | repo stringlengths 5 63 | repo_url stringlengths 24 82 | path stringlengths 5 167 | language stringclasses 1
value | license stringclasses 5
values | stars int64 10 51.4k | ref stringclasses 23
values | size_bytes int64 200 258k | text stringlengths 137 258k |
|---|---|---|---|---|---|---|---|---|---|
github | alphagov/publisher | https://github.com/alphagov/publisher | test/integration/edition_edit_tab/edit_amends_needed_edition_test.rb | Ruby | mit | 48 | main | 1,442 | require "integration_test_helper"
class EditAmendsNeededEditionTest < IntegrationTest
setup do
@govuk_editor = FactoryBot.create(:user, :govuk_editor, name: "Stub User")
login_as(@govuk_editor)
@amends_needed_edition = FactoryBot.create(:edition, :amends_needed)
visit edition_path(@amends_needed_edi... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/integration/edition_edit_tab/edit_ready_edition_test.rb | Ruby | mit | 48 | main | 4,541 | require "integration_test_helper"
class EditReadyEditionTest < IntegrationTest
setup do
@govuk_editor = FactoryBot.create(:user, :govuk_editor, name: "Stub User")
login_as(@govuk_editor)
@ready_edition = FactoryBot.create(:edition, :ready)
visit edition_path(@ready_edition)
end
context "user is... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/link_check_reports_controller_test.rb | Ruby | mit | 48 | main | 2,050 | require "test_helper"
require "gds_api/test_helpers/link_checker_api"
class LinkCheckReportsControllerTest < ActionController::TestCase
include GdsApi::TestHelpers::LinkCheckerApi
include Rails.application.routes.url_helpers
setup do
login_as_stub_user
@edition = FactoryBot.create(:place_edition, introd... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/legacy_artefacts_controller_test.rb | Ruby | mit | 48 | main | 1,538 | require "test_helper"
class LegacyArtefactsControllerTest < ActionController::TestCase
context "#update" do
should "allow update if govuk_editor" do
edition = FactoryBot.create(:simple_smart_answer_edition)
login_as_govuk_editor
patch :update, params: {
id: edition.artefact.id,
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/sitemap_controller_test.rb | Ruby | mit | 48 | main | 1,197 | require "test_helper"
class SitemapControllerTest < ActionController::TestCase
context "with no editions" do
should "return an empty XML file" do
get :index
assert_response :success
assert_select "url > loc", false
end
end
context "with an edition" do
setup do
FactoryBot.cr... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/event_notifications_test.rb | Ruby | mit | 48 | main | 3,536 | require "test_helper"
class EventNotificationsTest < ActiveSupport::TestCase
def fact_check_email
guide = FactoryBot.create(:guide_edition)
action = guide.actions.create!(email_addresses: "jys@ketlai.co.uk", customised_message: "Blah")
email = EventNotifierService.request_fact_check(action)
[guide, e... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/editions_controller_test.rb | Ruby | mit | 48 | main | 91,122 | require "test_helper"
class EditionsControllerTest < ActionController::TestCase
setup do
login_as_stub_user
@edition = FactoryBot.create(:edition, :fact_check)
@welsh_edition = FactoryBot.create(:edition, :fact_check, :welsh)
UpdateWorker.stubs(:perform_async)
stub_events_for_all_content_ids
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/legacy_editions_controller_test.rb | Ruby | mit | 48 | main | 44,179 | require "test_helper"
class LegacyEditionsControllerTest < ActionController::TestCase
setup do
login_as_stub_user
stub_linkables
stub_holidays_used_by_fact_check
stub_events_for_all_content_ids
stub_users_from_signon_api
end
context "#create" do
setup do
@artefact = FactoryBot.crea... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/artefacts_controller_test.rb | Ruby | mit | 48 | main | 8,889 | require "test_helper"
class ArtefactsControllerTest < ActionController::TestCase
context "#new" do
should "render the 'new' template if govuk_editor" do
login_as_govuk_editor
get :new
assert_response :ok
assert_template :new
end
should "not render the 'new' template if welsh_ed... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/user_search_controller_test.rb | Ruby | mit | 48 | main | 1,184 | require "test_helper"
class UserSearchControllerTest < ActionController::TestCase
setup do
login_as_stub_user
end
test "should get index" do
get :index
assert_response :success
end
test "should show commented editions" do
@guide = FactoryBot.create(:guide_edition)
FactoryBot.create(:gui... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/filtered_editions_controller_test.rb | Ruby | mit | 48 | main | 17,004 | require "test_helper"
class FilteredEditionsControllerTest < ActionController::TestCase
setup do
login_as_stub_user
@other_user = FactoryBot.create(:user, name: "Other User")
end
context "#my_content" do
should "render my_content template" do
get :my_content
assert_response :ok
as... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/content_item_controller_test.rb | Ruby | mit | 48 | main | 1,026 | require "test_helper"
class ContentItemControllerTest < ActionController::TestCase
def setup
login_as_stub_user
@edition = FactoryBot.create(:edition)
end
should "redirect to the design system publications page" do
get :by_content_id, params: { content_id: @edition.content_id }
assert_redirecte... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/link_checker_api_controller_test.rb | Ruby | mit | 48 | main | 2,295 | require "test_helper"
require "gds_api/test_helpers/link_checker_api"
class LinkCheckerApiControllerTest < ActionController::TestCase
include GdsApi::TestHelpers::LinkCheckerApi
def generate_signature(body, key)
OpenSSL::HMAC.hexdigest(OpenSSL::Digest.new("sha1"), key, body)
end
def create_edition_link_c... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/legacy_notes_controller_test.rb | Ruby | mit | 48 | main | 4,056 | require "test_helper"
class LegacyNotesControllerTest < ActionController::TestCase
setup do
login_as_stub_user
stub_linkables
stub_holidays_used_by_fact_check
end
context "#create" do
setup do
@edition = FactoryBot.create(:edition)
@note_text = "A New Note!"
end
context "whe... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/event_mailer_test.rb | Ruby | mit | 48 | main | 3,574 | require "test_helper"
class EventMailerTest < ActionMailer::TestCase
tests EventMailer
setup do
stub_calendars_has_no_bank_holidays(in_division: "england-and-wales")
end
def fact_check_email
guide = FactoryBot.create(:guide_edition)
action = guide.actions.create!(email_addresses: "jys@ketlai.co.u... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/downtimes_controller_test.rb | Ruby | mit | 48 | main | 7,206 | require "test_helper"
require "support/downtimes_controller_parameterised_tests"
class DowntimesControllerTest < ActionController::TestCase
extend DowntimesControllerParameterisedTests
setup do
login_as_stub_user
end
context "#new" do
should "render the page ok" do
get :new, params: { edition_i... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/guide_parts_controller_test.rb | Ruby | mit | 48 | main | 13,317 | # frozen_string_literal: true
require "test_helper"
class GuidePartsControllerTest < ActionController::TestCase
setup do
UpdateWorker.stubs(:perform_async)
end
context "adding a chapter to a guide" do
context "when user has no editor permissions" do
setup do
@edition = FactoryBot.create(:... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/reports_controller_test.rb | Ruby | mit | 48 | main | 1,783 | require "test_helper"
class ReportsControllerTest < ActionController::TestCase
context "When reports are available" do
setup do
login_as_stub_user
last_modified = Time.zone.local(2023, 12, 12, 1, 2, 3)
Aws.config[:s3] = {
stub_responses: {
head_object: { last_modified: },
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/homepage_controller_test.rb | Ruby | mit | 48 | main | 15,507 | require "test_helper"
class HomepageControllerTest < ActionController::TestCase
setup do
login_as_homepage_editor
end
context "#show" do
setup do
@popular_links = FactoryBot.create(:popular_links)
end
should "render show template" do
get :show
assert_response :ok
assert... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/tagging_controller_test.rb | Ruby | mit | 48 | main | 14,294 | # frozen_string_literal: true
require "test_helper"
class TaggingControllerTest < ActionController::TestCase
setup do
@edition = FactoryBot.create(:edition)
end
context "#breadcrumb_page" do
setup do
stub_linkables_with_data
end
context "user has govuk_editor permission" do
setup d... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/notes_controller_test.rb | Ruby | mit | 48 | main | 4,787 | require "test_helper"
class NotesControllerTest < ActionController::TestCase
setup do
login_as_stub_user
stub_linkables
stub_holidays_used_by_fact_check
end
context "#create" do
setup do
@edition = FactoryBot.create(:edition)
@note_text = "A New Note!"
end
context "when an E... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/functional/publications_controller_test.rb | Ruby | mit | 48 | main | 2,143 | require "test_helper"
class PublicationsControllerTest < ActionController::TestCase
setup do
login_as_stub_user
end
context "#show" do
context "with existing edition" do
should "redirect to the latest edition when requesting a panopticon_id" do
artefact = FactoryBot.create(
:arte... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/transaction_edition_test.rb | Ruby | mit | 48 | main | 945 | require "test_helper"
class TransactionEditionTest < ActiveSupport::TestCase
setup do
@artefact = FactoryBot.create(:artefact)
end
context "indexable_content" do
should "include the introduction without markup" do
transaction = FactoryBot.create(:transaction_edition, introduction: "## introduction... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/devolved_administration_availability_test.rb | Ruby | mit | 48 | main | 2,456 | require "test_helper"
class DevolvedAdministrationAvailabilityTest < ActiveSupport::TestCase
test "should not be valid with an unallowed type value" do
devolved_administration_availability = FactoryBot.build(
:devolved_administration_availability,
authority_type: "invalid_type",
)
assert_not ... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/edition_test.rb | Ruby | mit | 48 | main | 57,960 | require "test_helper"
class EditionTest < ActiveSupport::TestCase
def setup
@artefact = FactoryBot.create(:artefact)
lgsl_code = 800
FactoryBot.create(
:local_service,
lgsl_code:,
)
end
def template_answer(version_number = 1)
artefact = FactoryBot.create(
:artefact,
k... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/downtime_test.rb | Ruby | mit | 48 | main | 2,956 | require "test_helper"
class DowntimeTest < ActiveSupport::TestCase
context "validations" do
should "validate presence of message" do
downtime = FactoryBot.build(:downtime, message: nil)
assert_not downtime.valid?
assert_includes downtime.errors[:message], "can't be blank"
end
should "... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/artefact_action_test.rb | Ruby | mit | 48 | main | 4,486 | require "test_helper"
def merge_attributes(original, *update_hashes)
# Merge multiple attribute hashes: this also differs from Hash#merge in that
# it converts symbolic keys to strings
if update_hashes.empty?
original
else
first_update, *other_updates = update_hashes
updated = first_update.reduce(o... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/simple_smart_answer_option_test.rb | Ruby | mit | 48 | main | 2,856 | require "test_helper"
class SimpleSmartAnswerOptionTest < ActiveSupport::TestCase
context "given a smart answer exists with a node" do
setup do
@node = SimpleSmartAnswerEdition::Node.new(slug: "question1", title: "Question One?", kind: "question", order: 1)
@edition = FactoryBot.create(
:simp... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/artefact_test.rb | Ruby | mit | 48 | main | 14,120 | require "test_helper"
class ArtefactTest < ActiveSupport::TestCase
context "validating slug" do
should "allow nice clean slugs" do
a = FactoryBot.build(:artefact, slug: "its-a-nice-day")
assert a.valid?
end
should "not allow apostrophes in slugs" do
a = FactoryBot.build(:artefact, slug... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/link_test.rb | Ruby | mit | 48 | main | 1,920 | require_relative "../test_helper"
class LinkTest < ActiveSupport::TestCase
setup do
@link_check_report = FactoryBot.create(:link_check_report)
end
context "validations" do
should "be valid when all fields set" do
link = FactoryBot.build(:link, link_check_report: @link_check_report)
assert lin... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/overview_dashboard_test.rb | Ruby | mit | 48 | main | 1,043 | require "test_helper"
class OverviewDashboardTest < ActiveSupport::TestCase
test "Can create and retrieve dashboard overview objects" do
overview = create_test_overview
assert_equal overview.dashboard_type, "Format"
assert_equal overview.result_group, "Guide"
check_status_equal overview, row_status
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/help_page_edition_test.rb | Ruby | mit | 48 | main | 1,101 | require "test_helper"
class HelpPageEditionTest < ActiveSupport::TestCase
setup do
@artefact = FactoryBot.create(:artefact, kind: "help_page", slug: "help/foo")
end
should "have correct extra fields" do
h = FactoryBot.create(
:help_page_edition,
panopticon_id: @artefact.id,
body: "I'm ... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/host_content_update_event_test.rb | Ruby | mit | 48 | main | 8,459 | require "test_helper"
class HostContentUpdateEventTest < ActiveSupport::TestCase
extend Minitest::Spec::DSL
let(:artefact) { FactoryBot.create(:artefact) }
describe ".all_for_artefact" do
it "returns all HostContentUpdateJobs" do
user1_uuid = SecureRandom.uuid
user2_uuid = SecureRandom.uuid
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/action_test.rb | Ruby | mit | 48 | main | 613 | require "test_helper"
class ActionTest < ActiveSupport::TestCase
test "#to_s should return the humanized version of the request type" do
assert_equal "Approve review", Action.new(request_type: "approve_review").to_s
end
test "#to_s should contain the scheduled time when request type is SCHEDULE_FOR_PUBLISHI... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/link_check_report_test.rb | Ruby | mit | 48 | main | 2,453 | require_relative "../test_helper"
class LinkCheckReportTest < ActiveSupport::TestCase
context "validations" do
should "be valid when all fields set" do
link_check_report = FactoryBot.build(:link_check_report, :completed)
assert link_check_report.valid?
end
should "be valid without a complete... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/popular_links_edition_test.rb | Ruby | mit | 48 | main | 2,282 | require "test_helper"
class PopularLinksEditionTest < ActiveSupport::TestCase
should "save" do
popular_links = FactoryBot.build(:popular_links)
assert popular_links.save
end
should "validate 6 links are present" do
link_items = [{ url: "url1", title: "title1" }]
popular_links = FactoryBot.build(... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/report_test.rb | Ruby | mit | 48 | main | 1,997 | require "aws-sdk-s3"
require "test_helper"
class ReportTest < ActiveSupport::TestCase
def setup
@stubbed_s3_client = Aws::S3::Client.new(stub_responses: true)
Aws::S3::Client.stubs(:new).returns(@stubbed_s3_client)
@bucket_name = "my-test-bucket"
end
context "#filename" do
should "return filena... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/completed_transaction_edition_test.rb | Ruby | mit | 48 | main | 3,646 | require "test_helper"
class CompletedTransactionEditionTest < ActiveSupport::TestCase
test "controls whether organ donor registration promotion should be displayed on a completed transaction page" do
completed_transaction_edition = FactoryBot.build(:completed_transaction_edition)
assert_not completed_transa... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/simple_smart_answer_edition_test.rb | Ruby | mit | 48 | main | 16,759 | require "test_helper"
class SimpleSmartAnswerEditionTest < ActiveSupport::TestCase
setup do
@artefact = FactoryBot.create(:artefact)
end
should "be created with valid nodes" do
edition = FactoryBot.build(:simple_smart_answer_edition, nodes: [], panopticon_id: @artefact.id)
edition.body = "This is a ... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/artefact_external_link_test.rb | Ruby | mit | 48 | main | 1,357 | require "test_helper"
class ArtefactExternalLinkTest < ActiveSupport::TestCase
context "validating a link" do
setup do
@artefact = FactoryBot.create(:artefact)
end
should "not be valid without a title or URL" do
assert_not ArtefactExternalLink.new.valid?
end
should "not be valid wit... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/edition_scheduled_for_publishing_test.rb | Ruby | mit | 48 | main | 2,925 | require "test_helper"
class EditionScheduledForPublishingTest < ActiveSupport::TestCase
context "#schedule_for_publishing" do
context "when publish_at is not specified" do
setup do
@edition = FactoryBot.create(:edition, state: "ready")
@edition.schedule_for_publishing
end
shoul... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/part_test.rb | Ruby | mit | 48 | main | 2,685 | require "test_helper"
class PartTest < ActiveSupport::TestCase
context "validations" do
should validate_presence_of(:title).with_message(/Enter a title/)
should validate_presence_of(:slug).with_message(/Enter a slug/)
should validate_exclusion_of(:slug).in_array(%w[video]).with_message(/Slug can not be ... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/workflow_test.rb | Ruby | mit | 48 | main | 19,358 | require "test_helper"
require "minitest/autorun"
class WorkflowTest < ActiveSupport::TestCase
def setup
@artefact = FactoryBot.create(:artefact)
GovukContentModels::ActionProcessors::BaseProcessor.any_instance.stubs(:notify_about_event)
stub_holidays_used_by_fact_check
end
def template_users
use... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/parted_test.rb | Ruby | mit | 48 | main | 1,116 | require "test_helper"
class PartedTest < ActiveSupport::TestCase
test "should merge part validation errors with parent document's errors" do
edition = FactoryBot.create(:guide_edition)
edition.parts.build(id: "101", order: "1", title: "", slug: "overview")
edition.parts.build(id: "102", order: "2", title... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/local_transaction_edition_test.rb | Ruby | mit | 48 | main | 6,394 | require "test_helper"
class LocalTransactionEditionTest < ActiveSupport::TestCase
include LocalServicesHelper
BINS = 1
HOUSING_BENEFIT = 2
NONEXISTENT = 999
def setup
@artefact = FactoryBot.create(:artefact)
end
test "should be a transaction search format" do
bins_transaction = FactoryBot.build... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/user_test.rb | Ruby | mit | 48 | main | 5,982 | require "test_helper"
require "gds-sso/lint/user_test"
class GDS::SSO::Lint::UserTest
def user_class
::User
end
end
class UserTest < ActiveSupport::TestCase
def setup
@artefact = FactoryBot.create(:artefact)
end
test "#has_editor_permissions? is true with govuk_editor and non-Welsh editions" do
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/simple_smart_answer_node_test.rb | Ruby | mit | 48 | main | 4,368 | require "test_helper"
class SimpleSmartAnswerNodeTest < ActiveSupport::TestCase
context "given a smart answer exists" do
setup do
@edition = FactoryBot.create(:simple_smart_answer_edition, nodes: [])
@atts = {
title: "How much wood could a woodchuck chuck if a woodchuck could chuck wood?",
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/models/host_content_update_event/action_test.rb | Ruby | mit | 48 | main | 1,055 | require "test_helper"
class HostContentUpdateEvent::ActionTest < ActiveSupport::TestCase
extend Minitest::Spec::DSL
let(:content_id) { SecureRandom.uuid }
let(:host_content_update_event) { FactoryBot.build(:host_content_update_event, document_type: "content_block_email_address", content_id:) }
let(:action) {... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/edition_test.rb | Ruby | mit | 48 | main | 1,366 | require "test_helper"
class EditionTest < ActiveSupport::TestCase
context "state names" do
should "return an array of symbols" do
assert Edition.state_names.is_a? Array
assert(Edition.state_names.all? { |name| name.is_a? Symbol })
end
should "include the draft and published state" do
a... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/edition_progressor_test.rb | Ruby | mit | 48 | main | 4,084 | require "test_helper"
require "edition_progressor"
require "sidekiq/api"
class EditionProgressorTest < ActiveSupport::TestCase
setup do
@laura = FactoryBot.create(:user, :govuk_editor)
@guide = FactoryBot.create(:guide_edition, panopticon_id: FactoryBot.create(:artefact).id)
stub_register_published_conte... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/state_count_reporter_test.rb | Ruby | mit | 48 | main | 1,194 | require "test_helper"
require "state_count_reporter"
class StateCountReporterTest < ActiveSupport::TestCase
setup do
draft_scope_stub = stub("draft scope", count: 12)
published_scope_stub = stub("published scope", count: 15)
@model_class = stub(
"model class",
draft: draft_scope_stub,
p... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/tabs_helper_test.rb | Ruby | mit | 48 | main | 2,140 | require "test_helper"
class TabsHelperTest < ActionView::TestCase
include TabsHelper
context "Tab" do
should "return all tabs in order" do
assert_equal 7, tabs.count
assert_equal %w[edit tagging metadata history admin related_external_links unpublish], tabs.map(&:name)
end
should "return ... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/guide_edition_test.rb | Ruby | mit | 48 | main | 2,836 | require "test_helper"
class GuideEditionTest < ActiveSupport::TestCase
setup do
@artefact = FactoryBot.create(:artefact, name: "Childcare", slug: "childcare")
stub_calendars_has_no_bank_holidays(in_division: "england-and-wales")
end
def template_guide
edition = FactoryBot.create(:guide_edition, slug... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/all_urls_presenter_test.rb | Ruby | mit | 48 | main | 1,599 | require "test_helper"
class AllUrlsPresenterTest < ActiveSupport::TestCase
setup do
@response = {
"content_id" => "",
"expanded_links" => {
"mainstream_browse_pages" => [
{
"base_path" => "/browse/business/support",
},
{
"base_path" => "/b... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/edition_duplicator_test.rb | Ruby | mit | 48 | main | 2,903 | require "test_helper"
require "edition_duplicator"
# We might want to consider decoupling this test from
# the user and the edition, but for now at least those
# are the clear, minimal dependencies.
class EditionDuplicatorTest < ActiveSupport::TestCase
setup do
@laura = FactoryBot.create(:user, :govuk_editor)
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/all_content_workflow_presenter_test.rb | Ruby | mit | 48 | main | 4,172 | require "test_helper"
class AllContentWorkflowPresenterTest < ActiveSupport::TestCase
setup do
@transaction_created_at_time = Time.zone.now - 2.days
transaction_user = FactoryBot.create(:user, :govuk_editor, name: "Ray Khan")
transaction_edition = FactoryBot.create(
:transaction_edition,
titl... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/fact_check_config_test.rb | Ruby | mit | 48 | main | 9,912 | require "test_helper"
class FactCheckConfigTest < ActiveSupport::TestCase
subject_prefix = "test"
reply_to_address = "factcheck+1234@example.com"
valid_subjects_with_postgres_id = ["‘[Some title]’ GOV.UK preview of new edition [c9d67b66-80ab-446c-9998-e602926e3e06]",
"‘[Some ... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/primary_listing_presenter_test.rb | Ruby | mit | 48 | main | 5,179 | require "test_helper"
class PrimaryListingPresenterTest < ActiveSupport::TestCase
def setup_users
alice = FactoryBot.create(:user, :govuk_editor)
bob = FactoryBot.create(:user, :govuk_editor)
[alice, bob]
end
test "should filter by draft state" do
presenter = PrimaryListingPresenter.new(Edition,... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/editorial_progress_presenter_test.rb | Ruby | mit | 48 | main | 992 | require "test_helper"
class EditoriaProgressPresenterTest < ActiveSupport::TestCase
setup do
@artefact = FactoryBot.create(:artefact, name: "Childcare", slug: "childcare")
@guide = FactoryBot.create(:guide_edition, slug: "childcare", title: "One", panopticon_id: @artefact.id)
end
test "produces CSV outp... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/edition_churn_presenter_test.rb | Ruby | mit | 48 | main | 1,167 | require "legacy_integration_test_helper"
class EditionChurnPresenterTest < LegacyIntegrationTest
should "provide a CSV export of the churn in editions" do
document = FactoryBot.create(
:artefact,
name: "Important document",
)
edition1 = FactoryBot.create(
:edition,
title: "Import... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/user_test.rb | Ruby | mit | 48 | main | 1,037 | require "test_helper"
class UserTest < ActiveSupport::TestCase
test "it doesn't try to send a fact check email if no addresses were given" do
stub_holidays_used_by_fact_check
stub_post_new_fact_check_request
user = FactoryBot.create(:user, :govuk_editor, name: "bob")
EventMailer.expects(:request_fac... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/fact_check_message_processor_test.rb | Ruby | mit | 48 | main | 5,103 | require "test_helper"
require "fact_check_message_processor"
class FactCheckMessageProcessorTest < ActiveSupport::TestCase
def multipart_message
Mail.new do
to "nicolas@test.lindsaar.net.au"
from "Mikel Lindsaar <mikel@test.lindsaar.net.au>"
subject "First multipart email sent with Mail... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/csv_parser_test.rb | Ruby | mit | 48 | main | 481 | require "test_helper"
class CSVParserTest < ActiveSupport::TestCase
test "should raise an exception if the file is empty" do
parser = CSVParser.new(StringIO.new(""))
assert_raises(RuntimeError) { parser.parse }
end
test "can convert a CSV into an Array of Hash objects" do
csv_string = <<~CSV
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/scheduled_publisher_test.rb | Ruby | mit | 48 | main | 1,435 | require "test_helper"
class ScheduledPublisherTest < ActiveSupport::TestCase
context ".enqueue" do
setup do
Sidekiq::Testing.fake!
end
teardown do
ScheduledPublisher.jobs.clear
end
should "queue up an edition for publishing at the specified publish_at time" do
FactoryBot.creat... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/local_service_importer_test.rb | Ruby | mit | 48 | main | 2,385 | require "test_helper"
require "local_service_importer"
class LocalServiceImporterTest < ActiveSupport::TestCase
def fixture_file(file)
File.expand_path("fixtures/#{file}", File.dirname(__FILE__))
end
context "update" do
setup do
LocalServiceImporter.stubs(:new).returns(stub(run: nil))
end
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/fact_check_mail_test.rb | Ruby | mit | 48 | main | 1,544 | require "test_helper"
class FactCheckMailTest < ActiveSupport::TestCase
def email
Mail.new do
from "foo@example.com"
to "fact-check@gov.uk"
subject "This is a fact check response"
body "I like it. Good work!"
end
end
def email_with_header(key, value)
e = email
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/content_workflow_presenter_test.rb | Ruby | mit | 48 | main | 2,655 | require "test_helper"
class ContentWorkflowPresenterTest < ActiveSupport::TestCase
should "provide a CSV export of content workflow" do
user_transaction = FactoryBot.create(:user, name: "Ray Khan")
user_guide = FactoryBot.create(:user, name: "Constance Cerf")
transaction_edition = FactoryBot.create(:tran... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/dates_report_presenter_test.rb | Ruby | mit | 48 | main | 2,941 | require "test_helper"
class DatesReportPresenterTest < ActiveSupport::TestCase
should "provide a CSV export of content workflow" do
publish_action_1 = Action.new(
request_type: "publish",
created_at: "2015-04-30 09:16:03",
)
publish_action_2 = Action.new(
request_type: "publish",
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/csv_report_generator_test.rb | Ruby | mit | 48 | main | 2,528 | require "test_helper"
class CsvReportGeneratorTest < ActiveSupport::TestCase
setup do
@stubbed_s3_client = Aws::S3::Client.new(stub_responses: true)
Aws::S3::Client.stubs(:new).returns(@stubbed_s3_client)
@generator = CsvReportGenerator.new
end
test "editions_active_in_past_two_years returns editio... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/organisation_content_presenter_test.rb | Ruby | mit | 48 | main | 1,635 | require "test_helper"
class OrganisationContentPresenterTest < ActiveSupport::TestCase
setup do
@response = {
"content_id" => "",
"expanded_links" => {
"mainstream_browse_pages" => [
{
"base_path" => "/browse/business/support",
},
{
"base_... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/filtered_editions_presenter_test.rb | Ruby | mit | 48 | main | 13,004 | require "test_helper"
class FilteredEditionsPresenterTest < ActiveSupport::TestCase
def a_gds_user
FactoryBot.create(:user, organisation_content_id: PublishService::GDS_ORGANISATION_ID)
end
context "#content_type_options" do
should "return content type options with 'All types' selected when no content t... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/formats/simple_smart_answer_presenter_test.rb | Ruby | mit | 48 | main | 4,553 | require "test_helper"
class SimpleSmartAnswerPresenterTest < ActiveSupport::TestCase
def subject
Formats::SimpleSmartAnswerPresenter.new(edition)
end
def edition
@edition ||= begin
@edition = FactoryBot.create(
:simple_smart_answer_edition,
nodes: [],
start_button_text: "St... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/formats/edition_format_presenter_test.rb | Ruby | mit | 48 | main | 4,621 | require "test_helper"
class EditionFormatPresenterTest < ActiveSupport::TestCase
def subject
Formats::EditionFormatPresenter.new(edition)
end
def edition
@edition ||= stub(artefact:, in_beta: false)
end
def artefact
@artefact ||= stub
end
def result
subject.render_for_publishing_api
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/formats/answer_presenter_test.rb | Ruby | mit | 48 | main | 1,527 | require "test_helper"
class AnswerPresenterTest < ActiveSupport::TestCase
def subject
Formats::AnswerPresenter.new(edition)
end
def edition
@edition ||= FactoryBot.create(:answer_edition, panopticon_id: artefact.id)
end
def artefact
@artefact ||= FactoryBot.create(:artefact, kind: "answer")
e... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/formats/place_presenter_test.rb | Ruby | mit | 48 | main | 1,668 | require "test_helper"
class PlacePresenterTest < ActiveSupport::TestCase
def subject
Formats::PlacePresenter.new(edition)
end
def edition
@edition ||= FactoryBot.create(:place_edition, panopticon_id: artefact.id)
end
def artefact
@artefact ||= FactoryBot.create(:artefact, kind: "place", slug: "... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/formats/completed_transaction_presenter_test.rb | Ruby | mit | 48 | main | 2,599 | require "test_helper"
class CompletedTransactionPresenterTest < ActiveSupport::TestCase
setup do
@edition = FactoryBot.create(
:completed_transaction_edition,
:published,
title: "Whacked all moles",
slug: "done/good",
panopticon_id: artefact.id,
)
end
def subject
Format... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/formats/transaction_presenter_test.rb | Ruby | mit | 48 | main | 3,891 | require "test_helper"
class TransactionPresenterTest < ActiveSupport::TestCase
def subject
Formats::TransactionPresenter.new(edition)
end
def edition
@edition ||= FactoryBot.create(:transaction_edition, panopticon_id: artefact.id)
end
def artefact
@artefact ||= FactoryBot.create(:artefact, kind... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/formats/local_transaction_presenter_test.rb | Ruby | mit | 48 | main | 6,252 | require "test_helper"
class LocalTransactionPresenterTest < ActiveSupport::TestCase
setup do
LocalService.create(lgsl_code: 431, providing_tier: %w[county unitary])
end
def subject
Formats::LocalTransactionPresenter.new(edition)
end
def edition
@edition ||= FactoryBot.create(
:local_trans... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/formats/generic_edition_presenter_test.rb | Ruby | mit | 48 | main | 4,939 | require "test_helper"
class GenericEditionPresenterTest < ActiveSupport::TestCase
context ".render_for_publishing_api with a published document" do
setup do
artefact = FactoryBot.create(:artefact)
expected_external_related_links = [
{ title: "GOVUK", url: "https://www.gov.uk" },
{ ti... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/formats/guide_presenter_test.rb | Ruby | mit | 48 | main | 2,656 | require "test_helper"
class GuidePresenterTest < ActiveSupport::TestCase
def subject
Formats::GuidePresenter.new(edition)
end
def edition
@edition ||= FactoryBot.create(:guide_edition, panopticon_id: artefact.id)
end
def artefact
@artefact ||= FactoryBot.create(:artefact, kind: "guide", slug: "... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/formats/help_page_presenter_test.rb | Ruby | mit | 48 | main | 1,564 | require "test_helper"
class HelpPagePresenterTest < ActiveSupport::TestCase
def subject
Formats::HelpPagePresenter.new(edition)
end
def edition
@edition ||= FactoryBot.create(:help_page_edition, panopticon_id: artefact.id)
end
def artefact
@artefact ||= FactoryBot.create(:artefact, kind: "help_... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/presenters/formats/popular_links_presenter_test.rb | Ruby | mit | 48 | main | 1,385 | require "test_helper"
class PopularLinksPresenterTest < ActiveSupport::TestCase
def subject
Formats::PopularLinksPresenter.new(FactoryBot.create(:popular_links))
end
context "#render_for_publishing_api" do
setup do
@result = subject.render_for_publishing_api
end
should "be valid against s... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/services/republish_service_test.rb | Ruby | mit | 48 | main | 582 | require "test_helper"
class RepublishServiceTest < ActiveSupport::TestCase
setup do
UpdateService.stubs(:call)
PublishService.stubs(:call)
end
context ".call" do
should "call the UpdateService with the provided edition" do
UpdateService.expects(:call).with(edition, republish: true)
Repub... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/services/link_check_report_finder_test.rb | Ruby | mit | 48 | main | 534 | require "test_helper"
class LinkCheckReportFinderTest < ActiveSupport::TestCase
def link_check_report
@link_check_report ||= FactoryBot.create(
:edition,
:with_link_check_report,
link_uris: ["https://www.gov.uk"],
).latest_link_check_report
end
context ".call" do
should "find the l... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/services/publish_service_test.rb | Ruby | mit | 48 | main | 776 | require "test_helper"
class PublishServiceTest < ActiveSupport::TestCase
should "publish edition to PublishingAPI" do
Services.publishing_api.expects(:publish).with(
content_id,
update_type,
locale: language,
)
PublishService.call(edition, update_type)
end
should "set links" do
... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/services/publishing_api_workflow_bypass_publisher_test.rb | Ruby | mit | 48 | main | 2,866 | require "test_helper"
class PublishingApiWorkflowBypassPublisherTest < ActiveSupport::TestCase
setup do
UpdateService.stubs(:call)
PublishService.stubs(:call)
end
context ".call" do
context "when there is both a live and a draft edition" do
should "discard the draft edition in the publishing-a... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/services/update_service_test.rb | Ruby | mit | 48 | main | 612 | require "test_helper"
class UpdateServiceTest < ActiveSupport::TestCase
setup do
EditionPresenterFactory.stubs(:get_presenter).returns(presenter)
end
context ".call" do
should "send the rendered Edition to the publishing api" do
Services.publishing_api.expects(:put_content).with(
content_i... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/services/unpublish_service_test.rb | Ruby | mit | 48 | main | 3,378 | require "test_helper"
class UnpublishServiceTest < ActiveSupport::TestCase
setup do
@user = stub
@content_id = "foo"
@artefact = stub(update_as: true, content_id: @content_id, slug: "foo", state: "live", language: "en", exact_route?: true)
end
context "when publishing API returns an error" do
se... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/services/edition_link_extractor_test.rb | Ruby | mit | 48 | main | 1,676 | require "test_helper"
class EditionLinkExtractorTest < ActiveSupport::TestCase
context ".call" do
should "not error when edition has no links" do
result = call_edition_link_extractor(edition_with_no_links)
assert_kind_of Array, result
assert_empty result
end
should "extract links from... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/services/link_check_report_updater_test.rb | Ruby | mit | 48 | main | 1,776 | require "test_helper"
class LinkCheckReportUpdaterTest < ActiveSupport::TestCase
def completed_at
@completed_at ||= Time.zone.now.utc
end
def payload
{
status: "complete",
completed_at:,
links: links_payload,
}.with_indifferent_access
end
def links_payload
[{
uri: "h... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/services/edition_presenter_factory_test.rb | Ruby | mit | 48 | main | 2,357 | require "test_helper"
class EditionPresenterFactoryTest < ActiveSupport::TestCase
Klass = Class.new
context ".get_presenter" do
should "return an object" do
edition = stub(class: "foo")
edition.expects(:editionable_class).returns("editionable")
Klass.expects(:new).with(edition).returns("bar"... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/services/link_check_report_creator_test.rb | Ruby | mit | 48 | main | 1,396 | require "test_helper"
require "gds_api/test_helpers/link_checker_api"
class LinkCheckReportCreatorTest < ActiveSupport::TestCase
include GdsApi::TestHelpers::LinkCheckerApi
include Rails.application.routes.url_helpers
def create_edition(govspeak)
FactoryBot.create(:place_edition, introduction: govspeak)
e... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/services/fact_check_manager_api_service_test.rb | Ruby | mit | 48 | main | 3,343 | require "test_helper"
class FactCheckManagerApiServiceTest < ActiveSupport::TestCase
setup do
@user = FactoryBot.create(:user, :govuk_editor, uid: "123", name: "Ben")
@edition = FactoryBot.create(:answer_edition)
stub_holidays_used_by_fact_check
stub_post_new_fact_check_request
end
context ".req... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/constraints/feature_constraint_test.rb | Ruby | mit | 48 | main | 2,023 | require "test_helper"
class FeatureConstraintTest < ActiveSupport::TestCase
context "Feature 'feature_for_tests' is enabled by default" do
setup do
@test_strategy.switch!(:feature_for_tests, true)
end
should "match when a request cookie explicitly enables feature" do
request = stub(cookies: ... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/workers/downtime_scheduler_test.rb | Ruby | mit | 48 | main | 3,517 | require "test_helper"
class DowntimeSchedulerTest < ActiveSupport::TestCase
setup do
Sidekiq::Testing.fake!
end
teardown do
Sidekiq::Testing.inline!
end
context ".schedule_publish_and_expiry" do
context "when the downtime display start time is in the past" do
should "enqueue to run immedi... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/workers/downtime_remover_test.rb | Ruby | mit | 48 | main | 1,128 | require "test_helper"
class DowntimeRemoverTest < ActiveSupport::TestCase
setup do
Sidekiq::Testing.fake!
end
teardown do
Sidekiq::Testing.inline!
end
def downtime
@downtime ||= stub(artefact:, destroy!: nil)
end
def artefact
@artefact ||= stub(id: 123)
end
context ".destroy_immed... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/workers/update_worker_test.rb | Ruby | mit | 48 | main | 581 | require "test_helper"
class UpdateWorkerTest < ActiveSupport::TestCase
context "#perform" do
should "call the UpdateService" do
edition = FactoryBot.create(:edition)
UpdateService.expects(:call).with(edition)
PublishService.expects(:call).never
UpdateWorker.new.perform(edition.id)
en... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/workers/republish_worker_test.rb | Ruby | mit | 48 | main | 302 | require "test_helper"
class RepublishWorkerTest < ActiveSupport::TestCase
context "#perform" do
should "call the RepublishService" do
edition = FactoryBot.create(:edition)
RepublishService.expects(:call).with(edition)
RepublishWorker.new.perform(edition.id)
end
end
end |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/workers/publish_worker_test.rb | Ruby | mit | 48 | main | 346 | require "test_helper"
class PublishWorkerTest < ActiveSupport::TestCase
context "#perform" do
should "call the PublishService" do
edition = FactoryBot.create(:edition)
update_type = "foo"
PublishService.expects(:call).with(edition, update_type)
PublishWorker.new.perform(edition.id, updat... |
github | alphagov/publisher | https://github.com/alphagov/publisher | test/unit/helpers/error_summary_helper_test.rb | Ruby | mit | 48 | main | 2,458 | require "test_helper"
class ErrorSummaryHelperTest < ActionView::TestCase
include ErrorSummaryHelper
context "A Simple Smart Answer" do
should "errors_to_display returns useful error messages and correct hrefs for invalid fields" do
valid_outcome_node = SimpleSmartAnswerEdition::Node.new(kind: "outcome"... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.