aboutsummaryrefslogtreecommitdiffstats
path: root/spec
diff options
context:
space:
mode:
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 2c7b82c..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
- click_link "toggle_advanced_options"
+ 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>')")
- click_link "toggle_advanced_options"
- sleep 1
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"
+
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 dpage_titleirty 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>"
- click_link "toggle_advanced_options"
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