Sha256: 4eb2798c7bacbe7723146083df214eb960b94cd457a5094f3bdc2d7e271b375f

Contents?: true

Size: 1.78 KB

Versions: 12

Compression:

Stored size: 1.78 KB

Contents

describe Card::Set::All::Path do
  def path *args
    format.path(*args)
  end

  def with_complex_env
    Card.config.relative_url_root = "/root"
    Card::Env[:protocol] = "http://"
    Card::Env[:host] = "mydomain.com"
    yield
    Card.config.relative_url_root = nil
    Card::Env[:protocol] = nil
    Card::Env[:host] = nil
  end

  context "when in base format" do
    let :format do
      Card["A"].format(:base)
    end

    it "defaults to format card" do
      expect(path).to eq "/A"
    end

    it "handles other cards" do
      expect(path(mark: "B")).to eq "/B"
    end

    it "handles codenames" do
      expect(path(mark: :all)).to eq "/*all"
    end

    it "handles ids" do
      expect(path(mark: Card::SetID)).to eq "/Set"
    end

    it "handles :no_mark" do
      expect(path(no_mark: true, id: "Donate")).to eq "/?id=Donate"
    end

    it "handles formats" do
      expect(path(format: :csv)).to eq "/A.csv"
    end

    it "handles actions" do
      expect(path(action: :update)).to eq "/update/A"
    end

    it "handles query strings" do
      expect(path(view: :listing)).to eq "/A?view=listing"
    end

    it "handles special new card of type paths" do
      expect(path(mark: :pointer, action: :new)).to eq("/new/Pointer")
    end

    it "renders as absolute url" do
      with_complex_env do
        expect(path).to eq("http://mydomain.com/root/A")
      end
    end

    it "casts slot[hide] as array" do
      slot_hide = CGI.escape "slot[hide][]"
      expect(path(slot: { hide: "myview" })).to eq("/A?#{slot_hide}=myview")
    end
  end

  context "when in html format" do
    let :format do
      Card["A"].format(:html)
    end

    it "renders as absolute path (not absolute url)" do
      with_complex_env do
        expect(path).to eq("/root/A")
      end
    end
  end
end

Version data entries

12 entries across 12 versions & 1 rubygems

Version Path
card-1.100.0 mod/standard/spec/set/all/path_spec.rb
card-1.99.6 mod/standard/spec/set/all/path_spec.rb
card-1.99.5 mod/standard/spec/set/all/path_spec.rb
card-1.99.4 mod/standard/spec/set/all/path_spec.rb
card-1.99.3 mod/standard/spec/set/all/path_spec.rb
card-1.99.2 mod/standard/spec/set/all/path_spec.rb
card-1.99.1 mod/standard/spec/set/all/path_spec.rb
card-1.99.0 mod/standard/spec/set/all/path_spec.rb
card-1.98.3 mod/standard/spec/set/all/path_spec.rb
card-1.98.2 mod/standard/spec/set/all/path_spec.rb
card-1.98.1 mod/standard/spec/set/all/path_spec.rb
card-1.98.0 mod/standard/spec/set/all/path_spec.rb