aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
authorPhilip Arndt <git@p.arndt.io>2015-05-20 12:05:03 +1200
committerPhilip Arndt <git@p.arndt.io>2015-05-20 12:05:03 +1200
commitde954c625840adb7c1e98f1c675e56bb5e3074d7 (patch)
treebd2d2eb793f5a19847eba7d6e4efedc74fa1f5e0 /spec
parent99cdd519b209e05a6ed9ab81f23d22bd11b2490f (diff)
downloadrefinerycms-blog-de954c625840adb7c1e98f1c675e56bb5e3074d7.tar.gz
refinerycms-blog-de954c625840adb7c1e98f1c675e56bb5e3074d7.tar.bz2
refinerycms-blog-de954c625840adb7c1e98f1c675e56bb5e3074d7.zip
remove JS from tests for reliability and dramatic speed increase.
Diffstat (limited to 'spec')
-rw-r--r--spec/features/refinery/blog/admin/posts_spec.rb32
-rw-r--r--spec/features/refinery/blog/posts_spec.rb38
2 files changed, 32 insertions, 38 deletions
diff --git a/spec/features/refinery/blog/admin/posts_spec.rb b/spec/features/refinery/blog/admin/posts_spec.rb
index 9ab35c7..0efbb1d 100644
--- a/spec/features/refinery/blog/admin/posts_spec.rb
+++ b/spec/features/refinery/blog/admin/posts_spec.rb
@@ -32,27 +32,24 @@ module Refinery
expect(page).to have_content("Tags")
end
- it "should have category title", :js => true do
- find('#toggle_advanced_options').trigger(:click)
+ it "should have category title" do
expect(page).to have_content(blog_category.title)
end
- describe "create blog post", :js => true do
+ describe "create blog post" do
before do
expect(subject.class.count).to eq(0)
fill_in "post_title", :with => "This is my blog post"
+ fill_in "post_body", with: "<p>And I love it</p>"
- # this is a dirty hack but textarea that needs to be filled is
- # hidden and capybara refuses to fill in elements it can't see
- page.evaluate_script("WYMeditor.INSTANCES[0].html('<p>And I love it</p>')")
- find('#toggle_advanced_options').trigger(:click)
expect(page).to have_css '.blog_categories'
expect(page).to have_css "#post_category_ids_#{blog_category.id}"
- expect(page).to have_selector("#post_category_ids_#{blog_category.id}:not(:checked)")
- check blog_category.title
- expect(page).to have_selector("#post_category_ids_#{blog_category.id}:checked")
+ expect { check(blog_category.title) }.to change {
+ !!page.find("#post_category_ids_#{blog_category.id}").checked?
+ }.from(false).to(true)
+
click_button "Save"
- sleep 1
+
expect(page).to have_content("was successfully added.")
end
@@ -70,13 +67,11 @@ module Refinery
end
end
- describe "create blog post with tags", :js => true do
+ describe "create blog post with tags" do
let(:tag_list) { "chicago, bikes, beers, babes" }
before do
fill_in "Title", :with => "This is a tagged blog post"
- # this is a dirty hack but textarea that needs to be filled is
- # hidden and capybara refuses to fill in elements it can't see
- page.evaluate_script("WYMeditor.INSTANCES[0].html('<p>And I also love it</p>')")
+ fill_in "post_body", with: "<p>And I also love it</p>"
fill_in "Tags", :with => tag_list
click_button "Save"
end
@@ -160,17 +155,14 @@ module Refinery
context "with multiple users" do
let!(:other_guy) { FactoryGirl.create(:refinery_user, :username => "Other Guy") }
- describe "create blog post with alternate author", :js => true do
+ describe "create blog post with alternate author" do
before do
visit refinery.blog_admin_posts_path
click_link "Create new post"
fill_in "post_title", :with => "This is some other guy's blog post"
- # this is a dirty hack but textarea that needs to be filled is
- # hidden and capybara refuses to fill in elements it can't see
- page.evaluate_script("WYMeditor.INSTANCES[0].html('<p>I totally did not write it.</p>')")
+ fill_in "post_body", with: "<p>I totally did not write it.</p>"
- find("#toggle_advanced_options").trigger(:click)
expect(page).to have_content("Author")
select other_guy.username, :from => "Author"
diff --git a/spec/features/refinery/blog/posts_spec.rb b/spec/features/refinery/blog/posts_spec.rb
index a96b63a..3382398 100644
--- a/spec/features/refinery/blog/posts_spec.rb
+++ b/spec/features/refinery/blog/posts_spec.rb
@@ -41,25 +41,27 @@ module Refinery
describe "list tagged posts" do
context "when has tagged blog posts" do
- before do
- @tag_name = "chicago"
- @post = FactoryGirl.create(:blog_post,
- :title => "I Love my city",
- :tag_list => @tag_name)
- @tag = ::Refinery::Blog::Post.tag_counts_on(:tags).first
- end
+ let!(:tag_name) { "chicago" }
+ let!(:post) {
+ FactoryGirl.create(:blog_post,
+ :title => "I Love my city",
+ :tag_list => tag_name
+ )
+ }
+ let!(:tag) { ::Refinery::Blog::Post.tag_counts_on(:tags).first }
+
it "should have one tagged post" do
- visit refinery.blog_tagged_posts_path(@tag.id, @tag_name.parameterize)
+ visit refinery.blog_tagged_posts_path(tag.id, tag_name.parameterize)
- expect(page).to have_content(@tag_name)
- expect(page).to have_content(@post.title)
+ expect(page).to have_content(tag_name)
+ expect(page).to have_content(post.title)
end
end
end
describe "#show" do
context "when has no comments" do
- let(:blog_post) { FactoryGirl.create(:blog_post) }
+ let!(:blog_post) { FactoryGirl.create(:blog_post) }
it "should display the blog post" do
visit refinery.blog_post_path(blog_post)
@@ -68,7 +70,7 @@ module Refinery
end
end
context "when has approved comments" do
- let(:approved_comment) { FactoryGirl.create(:approved_comment) }
+ let!(:approved_comment) { FactoryGirl.create(:approved_comment) }
it "should display the comments" do
visit refinery.blog_post_path(approved_comment.post)
@@ -78,7 +80,7 @@ module Refinery
end
end
context "when has rejected comments" do
- let(:rejected_comment) { FactoryGirl.create(:rejected_comment) }
+ let!(:rejected_comment) { FactoryGirl.create(:rejected_comment) }
it "should not display the comments" do
visit refinery.blog_post_path(rejected_comment.post)
@@ -87,7 +89,7 @@ module Refinery
end
end
context "when has new comments" do
- let(:blog_comment) { FactoryGirl.create(:blog_comment) }
+ let!(:blog_comment) { FactoryGirl.create(:blog_comment) }
it "should not display the comments" do
visit refinery.blog_post_path(blog_comment.post)
@@ -97,7 +99,7 @@ module Refinery
end
context "when posting comments" do
- let(:blog_post) { FactoryGirl.create(:blog_post) }
+ let!(:blog_post) { FactoryGirl.create(:blog_post) }
let(:name) { "pete" }
let(:email) { "pete@mcawesome.com" }
let(:body) { "Witty comment." }
@@ -121,8 +123,8 @@ module Refinery
end
context "post popular" do
- let(:blog_post) { FactoryGirl.create(:blog_post) }
- let(:blog_post2) { FactoryGirl.create(:blog_post) }
+ let!(:blog_post) { FactoryGirl.create(:blog_post) }
+ let!(:blog_post2) { FactoryGirl.create(:blog_post) }
before do
visit refinery.blog_post_path(blog_post)
@@ -151,7 +153,7 @@ module Refinery
end
describe "#show draft preview" do
- let(:blog_post) { FactoryGirl.create(:blog_post_draft) }
+ let!(:blog_post) { FactoryGirl.create(:blog_post_draft) }
context "when logged in as admin" do
it "should display the draft notification" do