Sha256: 86407a6d60df4446b41c23801188b9509da8db1bbeda222f4fe538ad3ef9e312

Contents?: true

Size: 1.85 KB

Versions: 1

Compression:

Stored size: 1.85 KB

Contents

require "spec_helper"

describe "Modifying Documents", :type => :request do
  it "lets me create new documents by passing data and content" do
    begin
      post "/create/epics/newly-created-epic.html.md", content: "# Epic Title"
      expect(json["path"]).to be_present
      expect(json["path"].to_pathname).to be_exist
      expect(last_response.status).to eq(200)
    ensure
      doc = Brief.case.docs_path.join("epics","newly-created-epic.html.md")
      doc.unlink if doc.exist?
    end
  end

  it "lets me create documents passing raw yaml and content" do
    begin
      needle = rand(36**36).to_s(36)
      data = {newly: needle, type: "epic"}.to_yaml
      post "/create/epics/newly-created-epic-raw.html.md", raw: "#{ data }\n---\n\n# Epic Title"
      doc = Brief::Document.new(Brief.case.docs_path.join("epics","newly-created-epic-raw.html.md"))
      expect(doc.path.read).to include(needle)
      expect(last_response.status).to eq(200)
    ensure
      doc = Brief.case.docs_path.join("epics","newly-created-epic-raw.html.md")
      doc.unlink if doc.exist?
    end
  end

  it "lets me update existing documents" do
    needle = rand(36**36).to_s(36)
    post "/update/concept.html.md", content: "# Modified Content #{ needle }"
    doc = Brief.case.document_at("concept.html.md")
    expect(doc.content).to include(needle)
    expect(last_response.status).to eq(200)
  end

  it "lets me update just the metadata for an existing document" do
    needle = rand(36**36).to_s(36)
    post "/update/concept.html.md", data: {needle: needle}

    expect(last_response.status).to eq(200)
  end

  it "lets me remove documents" do
    post "/remove/epics/newly-created-epic.html.md"
    expect(last_response.status).to eq(200)
  end

  it "lets me run actions on documents" do
    post "/actions/custom_action/epics/epic.html.md"
    expect(last_response.status).to eq(200)
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
brief-1.5.0 spec/acceptance/modifying_spec.rb