* Update Travis.yml * Update README * Update README * Adjust test to not rely on env vars * Update encryption * Refactor * Update env key * Stub AWS calls * Create ApplicationConfig * Fix specs * Fix lint * Update ApplicationConfig * Remove travis env vars * Fix lint * Extend character limit to 100 * Add env to travis * Take out auto-restart after deploy * Immediately discarded test cache * Stub GA in request specs * Stub Pusher * Fix broken specs * Update fixture * Add CodeClimate id * Change CodeClimate key * Remove merge mistakes * WIP * Add Envied gem & Change README * Add missing keys * Add missing key * Update fixture * Fix broken spec * Add Slack Notification for Travis * Fix wording * Fix typo
62 lines
2.1 KiB
Ruby
62 lines
2.1 KiB
Ruby
require "rails_helper"
|
|
|
|
describe "Using the editor" do
|
|
let(:user) { create(:user) }
|
|
let(:raw_text) { "../support/fixtures/sample_article_template_spec.txt" }
|
|
# what are these
|
|
let(:dir) { "../support/fixtures/sample_article.txt" }
|
|
let(:rich_dir) { "../support/fixtures/sample_rich_article.txt" }
|
|
let(:template) { File.read(File.join(File.dirname(__FILE__), dir)) }
|
|
let(:rich_template) { File.read(File.join(File.dirname(__FILE__), rich_dir)) }
|
|
|
|
before do
|
|
sign_in user
|
|
end
|
|
|
|
def read_from_file(dir)
|
|
File.read(File.join(File.dirname(__FILE__), dir))
|
|
end
|
|
|
|
def fill_markdown_with(content)
|
|
visit "/new"
|
|
fill_in "article_body_markdown", with: content
|
|
end
|
|
|
|
describe "Previewing an article", js: true do
|
|
after do
|
|
page.evaluate_script("window.onbeforeunload = function(){}")
|
|
end
|
|
|
|
it "fill out form with ruch content and click preview" do
|
|
fill_markdown_with(read_from_file(raw_text))
|
|
page.execute_script("window.scrollTo(0, -100000)")
|
|
find("button#previewbutt").click
|
|
article_body = find(:xpath, "//div[@id='article_body']")["innerHTML"]
|
|
Approvals.verify(article_body, name: "user_preview_article_body", format: :html)
|
|
end
|
|
end
|
|
|
|
describe "Submitting an article" do
|
|
it "fill out form and submit" do
|
|
fill_markdown_with(read_from_file(raw_text))
|
|
click_button("article-submit")
|
|
article_body = find(:xpath, "//div[@id='article-body']")["innerHTML"]
|
|
Approvals.verify(article_body, name: "user_submit_article", format: :html)
|
|
end
|
|
|
|
it "user write and publish an article" do
|
|
fill_markdown_with(template.gsub("false", "true"))
|
|
click_button("article-submit")
|
|
["Sample Article", template[-200..-1], "test"].each do |text|
|
|
expect(page).to have_text(text)
|
|
end
|
|
end
|
|
|
|
it "user write and publish an article without a title" do
|
|
fill_markdown_with(template.gsub("Sample Article", ""))
|
|
click_button("article-submit")
|
|
expect(page).to have_css("div#error_explanation",
|
|
text: "Title can't be blank")
|
|
end
|
|
end
|
|
end
|