# frozen_string_literal: true

require "application_system_test_case"

module Glad
  module Admin
    class ManagingBucketsTest < ApplicationSystemTestCase
      def test_creating_another_bucket
        visit glad.admin_buckets_path

        click_on "New Bucket"

        fill_in "Name", with: "A New Website"
        assert_difference -> { Glad::Bucket.count }, +1 do
          click_button "Create Bucket"
        end
      end

      def test_editing_bucket
        bucket = glad_buckets(:marketing)
        visit glad.admin_buckets_path

        click_on bucket.name
        click_on "Edit"

        fill_in "Name", with: "A Different Name"
        assert_changes -> { bucket.reload.name }, to: "A Different Name" do
          click_button "Update Bucket"
        end
      end
    end
  end
end
