Sha256: 1354f7656cd80360619c692c7e3b8b50b2d8187d10740dc7e1a2bf30585d5425

Contents?: true

Size: 971 Bytes

Versions: 3

Compression:

Stored size: 971 Bytes

Contents

require "spec_helper"

RSpec.describe Book, type: :model do
  it { is_expected.to have_many(:approval_items).class_name("Approval::Item") }

  describe ".assign_ignore_fields" do
    subject { described_class.assign_ignore_fields(ignore_fields) }

    context "when ignore_fields are duplicated symbolized value" do
      let(:ignore_fields) { %i[id id created_at updated_at] }
      it { is_expected.to match_array %w[id created_at updated_at] }
    end
  end

  describe "#create_params_for_approval" do
    let(:book) { build :book }
    let(:result) { book.attributes.except("id", "created_at", "updated_at") }

    subject { book.create_params_for_approval }
    it { is_expected.to eq result }
  end

  describe "#update_params_for_approval" do
    let(:book) { create(:book).tap { |book| book.name = "changed name" } }
    let(:result) { { "name" => "changed name" } }

    subject { book.update_params_for_approval }
    it { is_expected.to eq result }
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
approval-0.3.2 spec/models/book_spec.rb
approval-0.3.1 spec/models/book_spec.rb
approval-0.3.0 spec/models/book_spec.rb