Sha256: 00fc5da1640dd0e7306270940b0f1a85307a61b8cb885fdf04e9155f0ef29e66

Contents?: true

Size: 1.18 KB

Versions: 17

Compression:

Stored size: 1.18 KB

Contents

require 'spec_helper'

describe Book, organization_workspace: :test do
  let!(:haskell) { create(:haskell) }
  let!(:gobstones) { create(:gobstones) }

  let!(:guide_1) { create(:guide, name: 'a lesson') }
  let!(:guide_2) { create(:guide, name: 'other lesson') }

  let!(:topic_1) { create(:topic, name: 'a topic') }
  let!(:topic_2) { create(:topic, name: 'other topic') }

  let(:book) { Organization.current.book }

  let(:book_json) do
    {name: 'sample book',
     description: 'a sample book description',
     slug: 'mumuki/mumuki-sample-book',
     locale: 'en',
     chapters: [topic_1.slug, topic_2.slug],
     complements: [guide_2.slug, guide_1.slug]
    }.deep_stringify_keys
  end

  describe '#import_from_json!' do
    before do
      book.import_from_json!(book_json)
    end

    it { expect(book.name).to eq 'sample book' }
    it { expect(book.description).to eq 'a sample book description' }
    it { expect(book.locale).to eq 'en' }
    it { expect(book.chapters.count).to eq 2 }
    it { expect(book.complements.count).to eq 2 }

    it { expect(topic_2.reload.usage_in_organization).to be_a Chapter }
    it { expect(guide_2.reload.usage_in_organization).to be_a Complement }
  end
end

Version data entries

17 entries across 17 versions & 1 rubygems

Version Path
mumuki-laboratory-5.9.1 spec/models/book_import_spec.rb
mumuki-laboratory-5.9.0 spec/models/book_import_spec.rb
mumuki-laboratory-5.8.3 spec/models/book_import_spec.rb
mumuki-laboratory-5.8.1 spec/models/book_import_spec.rb
mumuki-laboratory-5.8.0 spec/models/book_import_spec.rb
mumuki-laboratory-5.7.0 spec/models/book_import_spec.rb
mumuki-laboratory-5.6.3 spec/models/book_import_spec.rb
mumuki-laboratory-5.6.2 spec/models/book_import_spec.rb
mumuki-laboratory-5.6.1 spec/models/book_import_spec.rb
mumuki-laboratory-5.6.0 spec/models/book_import_spec.rb
mumuki-laboratory-5.5.0 spec/models/book_import_spec.rb
mumuki-laboratory-5.4.0 spec/models/book_import_spec.rb
mumuki-laboratory-5.3.0 spec/models/book_import_spec.rb
mumuki-laboratory-5.2.1 spec/models/book_import_spec.rb
mumuki-laboratory-5.2.0 spec/models/book_import_spec.rb
mumuki-laboratory-5.1.1 spec/models/book_import_spec.rb
mumuki-laboratory-5.1.0 spec/models/book_import_spec.rb