Sha256: e221b4a854b9a3d1af67be6bed079c346314baf274cef4a402ced85333298744

Contents?: true

Size: 1.62 KB

Versions: 15

Compression:

Stored size: 1.62 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
  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

15 entries across 15 versions & 1 rubygems

Version Path
card-1.97.0.1 mod/standard/spec/set/all/path_spec.rb
card-1.97.0 mod/standard/spec/set/all/path_spec.rb
card-1.96.8 mod/standard/spec/set/all/path_spec.rb
card-1.96.7 mod/standard/spec/set/all/path_spec.rb
card-1.96.6 mod/standard/spec/set/all/path_spec.rb
card-1.96.5 mod/standard/spec/set/all/path_spec.rb
card-1.96.4 mod/standard/spec/set/all/path_spec.rb
card-1.96.3 mod/standard/spec/set/all/path_spec.rb
card-1.96.2 mod/standard/spec/set/all/path_spec.rb
card-1.96.1 mod/standard/spec/set/all/path_spec.rb
card-1.96.0 mod/standard/spec/set/all/path_spec.rb
card-1.95.3 mod/standard/spec/set/all/path_spec.rb
card-1.95.2 mod/standard/spec/set/all/path_spec.rb
card-1.95.1 mod/standard/spec/set/all/path_spec.rb
card-1.95.0 mod/standard/spec/set/all/path_spec.rb