summaryrefslogtreecommitdiff
path: root/spec/migrations/add_upvotes_count_index_to_issues_spec.rb
blob: c04cb98a10782eadf6596b24a8b39580894e1194 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
# frozen_string_literal: true

require 'spec_helper'
require_migration!

RSpec.describe AddUpvotesCountIndexToIssues do
  let(:migration_instance) { described_class.new }

  describe '#up' do
    it 'adds index' do
      expect { migrate! }.to change { migration_instance.index_exists?(:issues, [:project_id, :upvotes_count], name: described_class::INDEX_NAME) }.from(false).to(true)
    end
  end

  describe '#down' do
    it 'removes index' do
      migrate!

      expect { schema_migrate_down! }.to change { migration_instance.index_exists?(:issues, [:project_id, :upvotes_count], name: described_class::INDEX_NAME) }.from(true).to(false)
    end
  end
end