Sha256: 367f6816595134197f00630e9e334343ab1c1bf648b311493fe07706f7f7ed92

Contents?: true

Size: 1.75 KB

Versions: 19

Compression:

Stored size: 1.75 KB

Contents

# -*- encoding : utf-8 -*-

describe Card::Set::All::RichHtml::Form do
  describe "type_list" do
    before do
      @card = Card["UserForm"]  # no cards with this type
    end

    it "gets type options from type_field renderer method" do
      expect(@card.format.type_field).to match(/<option [^>]*selected/)
      tf = @card.format.type_field(no_current_type: true)
      expect(tf).not_to match(/<option [^>]*selected/)
      expect(tf.scan(/<option /).length).to eq(SharedData::CARDTYPE_COUNT)
      tf = @card.format.type_field
      expect(tf).to match(/<option [^>]*selected/)
      expect(tf.scan(/<option /).length).to eq(SharedData::CARDTYPE_COUNT)
    end

    it "gets type list" do
      Card::Auth.as :anonymous do
        tf = @card.format.type_field(no_current_type: true)
        expect(tf).not_to match(/<option [^>]*selected/)
        expect(tf.scan(/<option /).length).to eq(1)
        tf = @card.format.type_field
        expect(tf).to match(/<option [^>]*selected/)
        expect(tf.scan(/<option /).length).to eq(2)
      end
    end
  end

  context "type and header" do
    it "renders type without no-edit class when no cards of type" do
      card = Card["UserForm"]  # no cards with this type
      expect(card.format.render_type)
        .to match(/<a[^>]* class="([^"]*)?\bcardtype\b[^"]*"/)
      expect(card.format.render_type)
        .not_to match(/<a[^>]* class="([^"]*)?\bno-edit\b[^"]*"/)
    end
    it "renders type header with no-edit class when cards of type exist" do
      no_edit_card = Card["cardtype a"]
      expect(no_edit_card.format.render_type)
        .to match(/<a[^>]* class="([^"]*)?\bcardtype\b[^"]*"/)
      expect(no_edit_card.format.render_type)
        .to match(/<a[^>]* class="([^"]*)?\bno-edit\b[^"]*"/)
    end
  end
end

Version data entries

19 entries across 19 versions & 1 rubygems

Version Path
card-1.94.1 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.94.0 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.13 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.12 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.11 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.10 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.9 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.8 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.7 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.6 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.5 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.4 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.3 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.2 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.1 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.93.0 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.92.2 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.92.1 mod/standard/spec/set/all/rich_html/form_spec.rb
card-1.92 mod/standard/spec/set/all/rich_html/form_spec.rb