Sha256: 01a4e781fc5306f4cfaa482bd7e3993bf846d34f1396dad5dd56d5f7d2cc0ab9

Contents?: true

Size: 1.82 KB

Versions: 13

Compression:

Stored size: 1.82 KB

Contents

require 'spec_helper'

describe Topic do
  describe 'transparent navigation api' do
    let!(:topic) { create(:topic, slug: 'foo/bar') }
    let(:params) { { organization: 'foo', repository: 'bar' } }

    it { expect(topic.transparent_id).to eq 'foo/bar' }
    it { expect(topic.transparent_params).to eq params }
    it { expect(Topic.find_transparently!(params)).to eq topic }
  end

  describe 'slug normalization' do
    let(:topic) { create(:topic, slug: 'fLbUlGaReLlI/MuMUkI-saMPle-gUIde') }

    it { expect(topic.slug).to eq('flbulgarelli/mumuki-sample-guide') }
  end

  describe '#import_from_resource_h!' do
    let!(:haskell) { create(:haskell) }
    let!(:gobstones) { create(:gobstones) }

    let!(:lesson_1) { create(:lesson, name: 'l1') }
    let(:guide_1) { lesson_1.guide }

    let!(:lesson_2) { create(:lesson, name: 'l2') }

    let!(:guide_2) { create(:guide, name: 'g2') }
    let!(:guide_3) { create(:guide, name: 'g3') }

    let(:topic_resource_h) do
      {name: 'sample topic',
       description: 'topic description',
       slug: 'mumuki/mumuki-sample-topic',
       locale: 'en',
       lessons: [guide_2, guide_1, guide_3].map(&:slug)}
    end

    context 'when guide is empty' do
      let(:topic) { create(:topic, lessons: [lesson_1, lesson_2]) }

      before do
        topic.import_from_resource_h!(topic_resource_h)
      end

      it { expect(topic.name).to eq 'sample topic' }
      it { expect(topic.description).to eq 'topic description' }
      it { expect(topic.locale).to eq 'en' }
      it { expect(topic.lessons.count).to eq 3 }
      it { expect(topic.lessons.first.guide).to eq guide_2 }
      it { expect(topic.lessons.second).to eq lesson_1 }
      it { expect(topic.lessons.third.guide).to eq guide_3 }
      it { expect(Guide.count).to eq 4 }
      it { expect(Lesson.count).to eq 3 }
    end
  end
end

Version data entries

13 entries across 13 versions & 1 rubygems

Version Path
mumuki-laboratory-7.11.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-c92f2a7212e2/spec/models/topic_spec.rb
mumuki-laboratory-7.11.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-2e15c3330133/spec/models/topic_spec.rb
mumuki-laboratory-7.9.2 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-7082a83493eb/spec/models/topic_spec.rb
mumuki-laboratory-7.9.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-b162dc91aa77/spec/models/topic_spec.rb
mumuki-laboratory-7.9.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-520f859ca8af/spec/models/topic_spec.rb
mumuki-laboratory-7.7.1 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-cb7a9018bb94/spec/models/topic_spec.rb
mumuki-laboratory-7.7.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-cb7a9018bb94/spec/models/topic_spec.rb
mumuki-laboratory-7.5.2 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-ad16a5930cec/spec/models/topic_spec.rb
mumuki-laboratory-7.5.1 vendor/bundle/ruby/2.3.0/bundler/gems/mumuki-domain-a059418e5fd8/spec/models/topic_spec.rb
mumuki-laboratory-7.5.0 vendor/bundle/ruby/2.6.0/bundler/gems/mumuki-domain-acb12583b793/spec/models/topic_spec.rb
mumuki-laboratory-7.1.0 vendor/bundle/ruby/2.3.0/bundler/gems/mumuki-domain-925adf85cca8/spec/models/topic_spec.rb
mumuki-laboratory-7.0.12 vendor/bundle/ruby/2.3.0/bundler/gems/mumuki-domain-74da3d4af98c/spec/models/topic_spec.rb
mumuki-laboratory-7.0.11 vendor/bundle/ruby/2.3.0/bundler/gems/mumuki-domain-f892f79c60f0/spec/models/topic_spec.rb