aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Gemfile1
-rw-r--r--app/views/refinery/blog/admin/categories/_category.html.erb10
-rw-r--r--app/views/refinery/blog/admin/posts/_post.html.erb14
-rw-r--r--spec/controllers/refinery/blog/admin/comments_controller_spec.rb26
-rw-r--r--spec/controllers/refinery/blog/posts_controller_spec.rb4
-rw-r--r--spec/features/refinery/blog/admin/categories_spec.rb34
-rw-r--r--spec/features/refinery/blog/admin/comments_spec.rb32
-rw-r--r--spec/features/refinery/blog/admin/menu_spec.rb2
-rw-r--r--spec/features/refinery/blog/admin/posts_spec.rb108
-rw-r--r--spec/features/refinery/blog/categories_spec.rb4
-rw-r--r--spec/features/refinery/blog/posts_spec.rb42
-rw-r--r--spec/helpers/refinery/blog/posts_helper_spec.rb24
-rw-r--r--spec/lib/refinery/blog/engine_spec.rb2
-rw-r--r--spec/models/refinery/blog/category_spec.rb10
-rw-r--r--spec/models/refinery/blog/comment_spec.rb4
-rw-r--r--spec/models/refinery/blog/post_spec.rb66
-rw-r--r--spec/spec_helper.rb1
17 files changed, 194 insertions, 190 deletions
diff --git a/Gemfile b/Gemfile
index b26b44e..c049859 100644
--- a/Gemfile
+++ b/Gemfile
@@ -4,7 +4,6 @@ gemspec
gem 'refinerycms', github: 'refinery/refinerycms'
gem 'refinerycms-i18n', github: 'refinery/refinerycms-i18n'
-gem 'refinerycms-settings', github: 'refinery/refinerycms-settings'
gem 'refinerycms-acts-as-indexed', github: 'refinery/refinerycms-acts-as-indexed'
gem 'filters_spam', github: 'resolve/filters_spam'
diff --git a/app/views/refinery/blog/admin/categories/_category.html.erb b/app/views/refinery/blog/admin/categories/_category.html.erb
index c1cfa15..3f813f5 100644
--- a/app/views/refinery/blog/admin/categories/_category.html.erb
+++ b/app/views/refinery/blog/admin/categories/_category.html.erb
@@ -4,10 +4,14 @@
<span class="preview">
<% category.translations.each do |translation| %>
<% if translation.title.present? %>
- <%= link_to refinery_icon_tag("flags/#{translation.locale}.png", :size => '16x11'),
- refinery.edit_blog_admin_category_path(category, :switch_locale => translation.locale),
- :class => 'locale' %>
+ <%= link_to refinery.edit_blog_admin_category_path(category, :switch_locale => translation.locale),
+ :class => 'locale' do %>
+ <div class="locale_icon <%= translation.locale %>">
+ <%= refinery_icon_tag('locale-blue.svg', :size => '24x24') %>
+ <span class="code"><%= translation.locale.upcase %></span>
+ </div>
<% end %>
+ <% end %>
<% end %>
</span>
</span>
diff --git a/app/views/refinery/blog/admin/posts/_post.html.erb b/app/views/refinery/blog/admin/posts/_post.html.erb
index eb9cc9d..6457c7b 100644
--- a/app/views/refinery/blog/admin/posts/_post.html.erb
+++ b/app/views/refinery/blog/admin/posts/_post.html.erb
@@ -2,12 +2,14 @@
<span class='title'>
<%= post.title.presence || post.translations.detect {|t| t.title.present?}.title %>
<span class="preview">
- <% post.translations.each do |translation| %>
- <% if translation.title.present? %>
- <%= link_to refinery_icon_tag("flags/#{translation.locale}.png", :size => '16x11'),
- refinery.edit_blog_admin_post_path(post, :switch_locale => translation.locale),
- :class => 'locale' %>
- <% end %>
+ <% post.translations.reject {|t| t.title.blank? }.each do |translation| %>
+ <%= link_to refinery.edit_blog_admin_post_path(post, :switch_locale => translation.locale),
+ :class => 'locale' do %>
+ <div class="locale_icon <%= translation.locale %>">
+ <%= refinery_icon_tag('locale-blue.svg', :size => '24x24') %>
+ <span class="code"><%= translation.locale.upcase %></span>
+ </div>
+ <% end %>
<% end %>
<%= post.published_at.try(:strftime, '%b %d, %Y') || 'draft' %>
diff --git a/spec/controllers/refinery/blog/admin/comments_controller_spec.rb b/spec/controllers/refinery/blog/admin/comments_controller_spec.rb
index 5a439f1..4139c18 100644
--- a/spec/controllers/refinery/blog/admin/comments_controller_spec.rb
+++ b/spec/controllers/refinery/blog/admin/comments_controller_spec.rb
@@ -14,13 +14,13 @@ module Refinery
it "succeeds" do
get :index
- response.should be_success
- response.should render_template(:index)
+ expect(response).to be_success
+ expect(response).to render_template(:index)
end
it "assigns unmoderated comments" do
get :index
- assigns(:comments).first.should eq(comment)
+ expect(assigns(:comments).first).to eq(comment)
end
end
@@ -29,13 +29,13 @@ module Refinery
it "succeeds" do
get :approved
- response.should be_success
- response.should render_template(:index)
+ expect(response).to be_success
+ expect(response).to render_template(:index)
end
it "assigns approved comments" do
get :approved
- assigns(:comments).first.should eq(comment)
+ expect(assigns(:comments).first).to eq(comment)
end
end
@@ -44,12 +44,12 @@ module Refinery
it "redirects on success" do
post :approve, :id => comment.id
- response.should be_redirect
+ expect(response).to be_redirect
end
it "approves the comment" do
post :approve, :id => comment.id
- Refinery::Blog::Comment.approved.count.should eq(1)
+ expect(Refinery::Blog::Comment.approved.count).to eq(1)
end
end
@@ -58,13 +58,13 @@ module Refinery
it "succeeds" do
get :rejected
- response.should be_success
- response.should render_template(:index)
+ expect(response).to be_success
+ expect(response).to render_template(:index)
end
it "assigns rejected comments" do
get :rejected
- assigns(:comments).first.should eq(comment)
+ expect(assigns(:comments).first).to eq(comment)
end
end
@@ -73,12 +73,12 @@ module Refinery
it "redirects on success" do
post :reject, :id => comment.id
- response.should be_redirect
+ expect(response).to be_redirect
end
it "rejects the comment" do
post :reject, :id => comment.id
- Refinery::Blog::Comment.rejected.count.should eq(1)
+ expect(Refinery::Blog::Comment.rejected.count).to eq(1)
end
end
end
diff --git a/spec/controllers/refinery/blog/posts_controller_spec.rb b/spec/controllers/refinery/blog/posts_controller_spec.rb
index 4b62d53..7265d64 100644
--- a/spec/controllers/refinery/blog/posts_controller_spec.rb
+++ b/spec/controllers/refinery/blog/posts_controller_spec.rb
@@ -11,12 +11,12 @@ module Refinery
it "should not limit rss feed" do
get :index, :format => :rss
- assigns[:posts].size.should == 3
+ expect(assigns[:posts].size).to eq(3)
end
it "should limit rss feed" do
get :index, :format => :rss, :max_results => 2
- assigns[:posts].count.should == 2
+ expect(assigns[:posts].count).to eq(2)
end
end
end
diff --git a/spec/features/refinery/blog/admin/categories_spec.rb b/spec/features/refinery/blog/admin/categories_spec.rb
index 507f417..b3e3f31 100644
--- a/spec/features/refinery/blog/admin/categories_spec.rb
+++ b/spec/features/refinery/blog/admin/categories_spec.rb
@@ -16,12 +16,12 @@ describe "Categories admin", type: :feature do
click_button "Save"
category = Refinery::Blog::Category.first
- category.title.should eq(title)
+ expect(category.title).to eq(title)
end
context "with translations" do
before do
- Refinery::I18n.stub(:frontend_locales).and_return([:en, :ru])
+ allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru])
blog_page = Globalize.with_locale(:en) { FactoryGirl.create(:page, :link_url => "/blog", :title => "Blog") }
Globalize.with_locale(:ru) do
blog_page.title = 'блог'
@@ -40,27 +40,27 @@ describe "Categories admin", type: :feature do
end
it "suceeds" do
- page.should have_content("'#{@c.title}' was successfully added.")
- Refinery::Blog::Category.count.should eq(1)
+ expect(page).to have_content("'#{@c.title}' was successfully added.")
+ expect(Refinery::Blog::Category.count).to eq(1)
end
- it "shows locale flag for category" do
+ it "shows locale for category" do
click_link "Manage"
within "#category_#{@c.id}" do
- page.should have_css("img[src='/assets/refinery/icons/flags/en.png']")
+ expect(page).to have_css(".locale_icon.en")
end
end
it "shows up in blog page for default locale" do
visit refinery.blog_root_path
within "#categories" do
- page.should have_selector('li')
+ expect(page).to have_selector('li')
end
end
it "does not show up in blog page for secondary locale" do
visit refinery.blog_root_path(:locale => :ru)
- page.should_not have_selector('#categories')
+ expect(page).not_to have_selector('#categories')
end
end
@@ -73,7 +73,7 @@ describe "Categories admin", type: :feature do
visit refinery.blog_admin_posts_path
click_link "Create new category"
within "#switch_locale_picker" do
- click_link "ru"
+ click_link "RU"
end
fill_in "Title", :with => ru_category_title
click_button "Save"
@@ -81,33 +81,33 @@ describe "Categories admin", type: :feature do
end
it "suceeds" do
- page.should have_content("'#{@c.title}' was successfully added.")
- Refinery::Blog::Category.count.should eq(1)
+ expect(page).to have_content("'#{@c.title}' was successfully added.")
+ expect(Refinery::Blog::Category.count).to eq(1)
end
- it "shows locale flag for category" do
+ it "shows locale for category" do
click_link "Manage"
within "#category_#{@c.id}" do
- page.should have_css("img[src='/assets/refinery/icons/flags/ru.png']")
+ expect(page).to have_css(".locale_icon.ru")
end
end
- it "does not show locale flag for primary locale" do
+ it "does not show locale for primary locale" do
click_link "Manage"
within "#category_#{@c.id}" do
- page.should_not have_css("img[src='/assets/refinery/icons/flags/en.png']")
+ expect(page).not_to have_css(".locale_icon.en")
end
end
it "does not shows up in blog page for default locale" do
visit refinery.blog_root_path
- page.should_not have_selector('#categories')
+ expect(page).not_to have_selector('#categories')
end
it "shows up in blog page for secondary locale" do
visit refinery.blog_root_path(:locale => :ru)
within "#categories" do
- page.should have_selector('li')
+ expect(page).to have_selector('li')
end
end
diff --git a/spec/features/refinery/blog/admin/comments_spec.rb b/spec/features/refinery/blog/admin/comments_spec.rb
index 0eb5108..097210d 100644
--- a/spec/features/refinery/blog/admin/comments_spec.rb
+++ b/spec/features/refinery/blog/admin/comments_spec.rb
@@ -16,7 +16,7 @@ module Refinery
it "should list no comments" do
visit refinery.blog_admin_comments_path
- page.should have_content('There are no new comments')
+ expect(page).to have_content('There are no new comments')
end
end
context "when has new unapproved comments" do
@@ -24,20 +24,20 @@ module Refinery
before { visit refinery.blog_admin_comments_path }
it "should list comments" do
- page.should have_content(blog_comment.body)
- page.should have_content(blog_comment.name)
+ expect(page).to have_content(blog_comment.body)
+ expect(page).to have_content(blog_comment.name)
end
it "should allow me to approve a comment" do
click_link "Approve this comment"
- page.should have_content("has been approved")
+ expect(page).to have_content("has been approved")
end
it "should allow me to reject a comment" do
click_link "Reject this comment"
- page.should have_content("has been rejected")
+ expect(page).to have_content("has been rejected")
end
end
end
@@ -50,7 +50,7 @@ module Refinery
end
it "should list no comments" do
- page.should have_content('There are no approved comments')
+ expect(page).to have_content('There are no approved comments')
end
end
context "when has approved comments" do
@@ -60,14 +60,14 @@ module Refinery
before { visit refinery.approved_blog_admin_comments_path }
it "should list comments" do
- page.should have_content(blog_comment.body)
- page.should have_content(blog_comment.name)
+ expect(page).to have_content(blog_comment.body)
+ expect(page).to have_content(blog_comment.name)
end
it "should allow me to reject a comment" do
click_link "Reject this comment"
- page.should have_content("has been rejected")
+ expect(page).to have_content("has been rejected")
end
end
end
@@ -80,7 +80,7 @@ module Refinery
end
it "should list no comments" do
- page.should have_content('There are no rejected comments')
+ expect(page).to have_content('There are no rejected comments')
end
end
context "when has rejected comments" do
@@ -90,14 +90,14 @@ module Refinery
before { visit refinery.rejected_blog_admin_comments_path }
it "should list comments" do
- page.should have_content(blog_comment.body)
- page.should have_content(blog_comment.name)
+ expect(page).to have_content(blog_comment.body)
+ expect(page).to have_content(blog_comment.name)
end
it "should allow me to approve a comment" do
click_link "Approve this comment"
- page.should have_content("has been approved")
+ expect(page).to have_content("has been approved")
end
end
end
@@ -106,13 +106,13 @@ module Refinery
let!(:blog_comment) { FactoryGirl.create(:blog_comment) }
before { visit refinery.blog_admin_comment_path(blog_comment) }
it "should display the comment" do
- page.should have_content(blog_comment.body)
- page.should have_content(blog_comment.name)
+ expect(page).to have_content(blog_comment.body)
+ expect(page).to have_content(blog_comment.name)
end
it "should allow me to approve the comment" do
click_link "Approve this comment"
- page.should have_content("has been approved")
+ expect(page).to have_content("has been approved")
end
end
end
diff --git a/spec/features/refinery/blog/admin/menu_spec.rb b/spec/features/refinery/blog/admin/menu_spec.rb
index 3411c6c..748d5c3 100644
--- a/spec/features/refinery/blog/admin/menu_spec.rb
+++ b/spec/features/refinery/blog/admin/menu_spec.rb
@@ -8,6 +8,6 @@ describe "Blog menu entry", type: :feature do
within("#menu") { click_link "Blog" }
- page.should have_css("a.active", :text => "Blog")
+ expect(page).to have_css("a.active", :text => "Blog")
end
end
diff --git a/spec/features/refinery/blog/admin/posts_spec.rb b/spec/features/refinery/blog/admin/posts_spec.rb
index 591c6b0..ca45fd3 100644
--- a/spec/features/refinery/blog/admin/posts_spec.rb
+++ b/spec/features/refinery/blog/admin/posts_spec.rb
@@ -18,7 +18,7 @@ module Refinery
before { visit refinery.blog_admin_posts_path }
it "invites to create new post" do
- page.should have_content("There are no Blog Posts yet. Click \"Create new post\" to add your first blog post.")
+ expect(page).to have_content("There are no Blog Posts yet. Click \"Create new post\" to add your first blog post.")
end
end
@@ -29,42 +29,42 @@ module Refinery
end
it "should have Tags" do
- page.should have_content("Tags")
+ expect(page).to have_content("Tags")
end
it "should have category title", :js => true do
click_link "toggle_advanced_options"
- page.should have_content(blog_category.title)
+ expect(page).to have_content(blog_category.title)
end
describe "create blog post", :js => true do
before do
- subject.class.count.should eq(0)
+ expect(subject.class.count).to eq(0)
fill_in "post_title", :with => "This is my 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 love it</p>')")
click_link "toggle_advanced_options"
- page.should have_css '.blog_categories'
- page.should have_css "#post_category_ids_#{blog_category.id}"
+ expect(page).to have_css '.blog_categories'
+ expect(page).to have_css "#post_category_ids_#{blog_category.id}"
check blog_category.title
- find(:css, "#post_category_ids_#{blog_category.id}").checked?.should be_truthy
+ expect(find(:css, "#post_category_ids_#{blog_category.id}").checked?).to be_truthy
click_button "Save"
- page.should have_content("was successfully added.")
+ expect(page).to have_content("was successfully added.")
end
it "should be the only blog post" do
- subject.class.count.should eq(1)
+ expect(subject.class.count).to eq(1)
end
it "should belong to me" do
- subject.class.first.author.should eq(::Refinery::User.last)
+ expect(subject.class.first.author).to eq(::Refinery::User.last)
end
it "should save categories" do
- subject.class.last.categories.count.should eq(1)
- subject.class.last.categories.first.title.should eq(blog_category.title)
+ expect(subject.class.last.categories.count).to eq(1)
+ expect(subject.class.last.categories.first.title).to eq(blog_category.title)
end
end
@@ -80,15 +80,15 @@ module Refinery
end
it "should succeed" do
- page.should have_content("was successfully added.")
+ expect(page).to have_content("was successfully added.")
end
it "should be the only blog post" do
- subject.class.count.should eq(1)
+ expect(subject.class.count).to eq(1)
end
it "should have the specified tags" do
- subject.class.last.tag_list.sort.should eq(tag_list.split(', ').sort)
+ expect(subject.class.last.tag_list.sort).to eq(tag_list.split(', ').sort)
end
end
end
@@ -104,26 +104,26 @@ module Refinery
describe "edit blog post" do
it "should succeed" do
- page.should have_content(blog_post.title)
+ expect(page).to have_content(blog_post.title)
click_link("Edit this blog post")
- current_path.should == refinery.edit_blog_admin_post_path(blog_post)
+ expect(current_path).to eq(refinery.edit_blog_admin_post_path(blog_post))
fill_in "post_title", :with => "hax0r"
click_button "Save"
- page.should_not have_content(blog_post.title)
- page.should have_content("'hax0r' was successfully updated.")
+ expect(page).not_to have_content(blog_post.title)
+ expect(page).to have_content("'hax0r' was successfully updated.")
end
end
describe "deleting blog post" do
it "should succeed" do
- page.should have_content(blog_post.title)
+ expect(page).to have_content(blog_post.title)
click_link "Remove this blog post forever"
- page.should have_content("'#{blog_post.title}' was successfully removed.")
+ expect(page).to have_content("'#{blog_post.title}' was successfully removed.")
end
end
@@ -131,8 +131,8 @@ module Refinery
it "redirects to blog post in the frontend" do
click_link "View this blog post live"
- current_path.should == refinery.blog_post_path(blog_post)
- page.should have_content(blog_post.title)
+ expect(current_path).to eq(refinery.blog_post_path(blog_post))
+ expect(page).to have_content(blog_post.title)
end
end
end
@@ -140,7 +140,7 @@ module Refinery
context "when uncategorized post" do
it "shows up in the list" do
visit refinery.uncategorized_blog_admin_posts_path
- page.should have_content(blog_post.title)
+ expect(page).to have_content(blog_post.title)
end
end
@@ -150,7 +150,7 @@ module Refinery
blog_post.save!
visit refinery.uncategorized_blog_admin_posts_path
- page.should_not have_content(blog_post.title)
+ expect(page).not_to have_content(blog_post.title)
end
end
end
@@ -173,11 +173,11 @@ module Refinery
select other_guy.username, :from => "Author"
click_button "Save"
- page.should have_content("was successfully added.")
+ expect(page).to have_content("was successfully added.")
end
it "belongs to another user" do
- subject.class.last.author.should eq(other_guy)
+ expect(subject.class.last.author).to eq(other_guy)
end
end
end
@@ -185,7 +185,7 @@ module Refinery
context "with translations" do
before do
Globalize.locale = :en
- Refinery::I18n.stub(:frontend_locales).and_return([:en, :ru])
+ allow(Refinery::I18n).to receive(:frontend_locales).and_return([:en, :ru])
blog_page = FactoryGirl.create(:page, :link_url => "/blog", :title => "Blog")
Globalize.with_locale(:ru) do
blog_page.title = 'блог'
@@ -204,25 +204,25 @@ module Refinery
end
it "succeeds" do
- page.should have_content("'Post' was successfully added.")
- Refinery::Blog::Post.count.should eq(1)
+ expect(page).to have_content("'Post' was successfully added.")
+ expect(Refinery::Blog::Post.count).to eq(1)
end
- it "shows locale flag for post" do
+ it "shows locale for post" do
within "#post_#{@p.id}" do
- page.should have_css("img[src='/assets/refinery/icons/flags/en.png']")
+ expect(page).to have_css(".locale_icon.en")
end
end
it "shows up in blog page for default locale" do
visit refinery.blog_root_path
- page.should have_selector("#post_#{@p.id}")
+ expect(page).to have_selector("#post_#{@p.id}")
end
it "does not show up in blog page for secondary locale" do
visit refinery.blog_root_path(:locale => :ru)
- page.should_not have_selector("#post_#{@p.id}")
+ expect(page).not_to have_selector("#post_#{@p.id}")
end
end
@@ -234,7 +234,7 @@ module Refinery
before do
click_link "Create new post"
within "#switch_locale_picker" do
- click_link "ru"
+ click_link "RU"
end
fill_in "Title", :with => ru_page_title
fill_in "post_body", :with => "One post in my blog"
@@ -243,36 +243,36 @@ module Refinery
end
it "succeeds" do
- page.should have_content("was successfully added.")
- Refinery::Blog::Post.count.should eq(1)
+ expect(page).to have_content("was successfully added.")
+ expect(Refinery::Blog::Post.count).to eq(1)
end
it "shows title in secondary locale" do
within "#post_#{@p.id}" do
- page.should have_content(ru_page_title)
+ expect(page).to have_content(ru_page_title)
end
end
- it "shows locale flag for post" do
+ it "shows locale for post" do
within "#post_#{@p.id}" do
- page.should have_css("img[src='/assets/refinery/icons/flags/ru.png']")
+ expect(page).to have_css(".locale_icon.ru")
end
end
- it "does not show locale flag for primary locale" do
+ it "does not show locale for primary locale" do
within "#post_#{@p.id}" do
- page.should_not have_css("img[src='/assets/refinery/icons/flags/en.png']")
+ expect(page).not_to have_css(".locale_icon.en")
end
end
it "does not show up in blog page for default locale" do
visit refinery.blog_root_path
- page.should_not have_selector("#post_#{@p.id}")
+ expect(page).not_to have_selector("#post_#{@p.id}")
end
it "shows up in blog page for secondary locale" do
visit refinery.blog_root_path(:locale => :ru)
- page.should have_selector("#post_#{@p.id}")
+ expect(page).to have_selector("#post_#{@p.id}")
end
end
@@ -292,10 +292,10 @@ module Refinery
visit refinery.blog_admin_posts_path
end
- it "shows both locale flags for post" do
+ it "shows both locales for post" do
within "#post_#{blog_post.id}" do
- page.should have_css("img[src='/assets/refinery/icons/flags/en.png']")
- page.should have_css("img[src='/assets/refinery/icons/flags/ru.png']")
+ expect(page).to have_css(".locale_icon.en")
+ expect(page).to have_css(".locale_icon.ru")
end
end
@@ -303,28 +303,28 @@ module Refinery
it "succeeds" do
within "#post_#{blog_post.id}" do
- click_link("En")
+ click_link("EN")
end
- current_path.should == refinery.edit_blog_admin_post_path(blog_post)
+ expect(current_path).to eq(refinery.edit_blog_admin_post_path(blog_post))
fill_in "Title", :with => "New Post Title"
click_button "Save"
- page.should_not have_content(blog_post.title)
- page.should have_content("'New Post Title' was successfully updated.")
+ expect(page).not_to have_content(blog_post.title)
+ expect(page).to have_content("'New Post Title' was successfully updated.")
end
end
describe "edit the post in secondary locale" do
it "succeeds" do
within "#post_#{blog_post.id}" do
- click_link("ru")
+ click_link("RU")
end
fill_in "Title", :with => "Нов"
click_button "Save"
- page.should_not have_content(blog_post.title)
- page.should have_content("'Нов' was successfully updated.")
+ expect(page).not_to have_content(blog_post.title)
+ expect(page).to have_content("'Нов' was successfully updated.")
end
end
diff --git a/spec/features/refinery/blog/categories_spec.rb b/spec/features/refinery/blog/categories_spec.rb
index efcf388..b778254 100644
--- a/spec/features/refinery/blog/categories_spec.rb
+++ b/spec/features/refinery/blog/categories_spec.rb
@@ -19,8 +19,8 @@ module Refinery
describe "show categories blog posts" do
it "should displays categories blog posts" do
visit refinery.blog_category_path(@category)
- page.should have_content("Refinery CMS blog post")
- page.should have_content("Video Games")
+ expect(page).to have_content("Refinery CMS blog post")
+ expect(page).to have_content("Video Games")
end
end
end
diff --git a/spec/features/refinery/blog/posts_spec.rb b/spec/features/refinery/blog/posts_spec.rb
index daba07e..a96b63a 100644
--- a/spec/features/refinery/blog/posts_spec.rb
+++ b/spec/features/refinery/blog/posts_spec.rb
@@ -12,7 +12,7 @@ module Refinery
it "should display blog post" do
visit refinery.blog_post_path(blog_post)
- page.should have_content(blog_post.title)
+ expect(page).to have_content(blog_post.title)
end
describe "visit blog" do
@@ -25,14 +25,14 @@ module Refinery
it "shows blog link in menu" do
visit "/"
within "#menu" do
- page.should have_content("Blog")
- page.should have_selector("a[href='/blog']")
+ expect(page).to have_content("Blog")
+ expect(page).to have_selector("a[href='/blog']")
end
end
it "shows blog posts" do
visit refinery.blog_root_path
- page.should have_content blog_post.title
+ expect(page).to have_content blog_post.title
end
end
@@ -51,8 +51,8 @@ module Refinery
it "should have one tagged post" do
visit refinery.blog_tagged_posts_path(@tag.id, @tag_name.parameterize)
- page.should have_content(@tag_name)
- page.should have_content(@post.title)
+ expect(page).to have_content(@tag_name)
+ expect(page).to have_content(@post.title)
end
end
end
@@ -63,8 +63,8 @@ module Refinery
it "should display the blog post" do
visit refinery.blog_post_path(blog_post)
- page.should have_content(blog_post.title)
- page.should have_content(blog_post.body)
+ expect(page).to have_content(blog_post.title)
+ expect(page).to have_content(blog_post.body)
end
end
context "when has approved comments" do
@@ -73,8 +73,8 @@ module Refinery
it "should display the comments" do
visit refinery.blog_post_path(approved_comment.post)
- page.should have_content(approved_comment.body)
- page.should have_content("Posted by #{approved_comment.name}")
+ expect(page).to have_content(approved_comment.body)
+ expect(page).to have_content("Posted by #{approved_comment.name}")
end
end
context "when has rejected comments" do
@@ -83,7 +83,7 @@ module Refinery
it "should not display the comments" do
visit refinery.blog_post_path(rejected_comment.post)
- page.should_not have_content(rejected_comment.body)
+ expect(page).not_to have_content(rejected_comment.body)
end
end
context "when has new comments" do
@@ -92,7 +92,7 @@ module Refinery
it "should not display the comments" do
visit refinery.blog_post_path(blog_comment.post)
- page.should_not have_content(blog_comment.body)
+ expect(page).not_to have_content(blog_comment.body)
end
end
@@ -114,9 +114,9 @@ module Refinery
it "creates the comment" do
comment = blog_post.reload.comments.last
- comment.name.should eq(name)
- comment.email.should eq(email)
- comment.body.should eq(body)
+ expect(comment.name).to eq(name)
+ expect(comment.email).to eq(email)
+ expect(comment.body).to eq(body)
end
end
@@ -129,13 +129,13 @@ module Refinery
end
it "should increment access count" do
- blog_post.reload.access_count.should eq(1)
+ expect(blog_post.reload.access_count).to eq(1)
visit refinery.blog_post_path(blog_post)
- blog_post.reload.access_count.should eq(2)
+ expect(blog_post.reload.access_count).to eq(2)
end
it "should be most popular" do
- Refinery::Blog::Post.popular(2).first.should eq(blog_post)
+ expect(Refinery::Blog::Post.popular(2).first).to eq(blog_post)
end
end
@@ -144,7 +144,7 @@ module Refinery
let!(:blog_post2) { FactoryGirl.create(:blog_post, :published_at => Time.now - 2.minutes) }
it "should be the most recent" do
- Refinery::Blog::Post.recent(2).first.id.should eq(blog_post2.id)
+ expect(Refinery::Blog::Post.recent(2).first.id).to eq(blog_post2.id)
end
end
@@ -157,7 +157,7 @@ module Refinery
it "should display the draft notification" do
visit refinery.blog_post_path(blog_post)
- page.should have_content('This page is NOT live for public viewing.')
+ expect(page).to have_content('This page is NOT live for public viewing.')
end
end
@@ -172,7 +172,7 @@ module Refinery
it "should not display the blog post" do
visit refinery.blog_post_path(blog_post)
- page.should have_content("The page you requested was not found.")
+ expect(page).to have_content("The page you requested was not found.")
end
end
end
diff --git a/spec/helpers/refinery/blog/posts_helper_spec.rb b/spec/helpers/refinery/blog/posts_helper_spec.rb
index 4a791d9..4e19999 100644
--- a/spec/helpers/refinery/blog/posts_helper_spec.rb
+++ b/spec/helpers/refinery/blog/posts_helper_spec.rb
@@ -2,7 +2,7 @@ require 'spec_helper'
module Refinery
module Blog
- describe PostsHelper do
+ describe PostsHelper, :type => :helper do
describe "#blog_archive_widget", type: :helper do
let(:html) { helper.blog_archive_widget(dates) }
let(:links) { Capybara.string(html).find("#blog_archive_widget ul") }
@@ -11,7 +11,7 @@ module Refinery
let(:dates) { [] }
it "does not display anything" do
- html.should be_blank
+ expect(html).to be_blank
end
end
@@ -29,18 +29,18 @@ module Refinery
month = Date::MONTHNAMES[recent_post.month]
year = recent_post.year
- links.should have_link("#{month} #{year} (3)")
+ expect(links).to have_link("#{month} #{year} (3)")
end
it "has a link for the year of dates older than one year" do
year = old_post.year
- links.should have_link("#{year} (3)")
+ expect(links).to have_link("#{year} (3)")
end
it "sorts recent links before old links" do
- links.find("li:first").should have_content(recent_post.year.to_s)
- links.find("li:last").should have_content(old_post.year.to_s)
+ expect(links.find("li:first")).to have_content(recent_post.year.to_s)
+ expect(links.find("li:last")).to have_content(old_post.year.to_s)
end
end
@@ -50,8 +50,8 @@ module Refinery
it "sorts by the more recent date" do
first, second = dates.map {|p| Date::MONTHNAMES[p.month] }
- links.find("li:first").should have_content(second)
- links.find("li:last").should have_content(first)
+ expect(links.find("li:first")).to have_content(second)
+ expect(links.find("li:last")).to have_content(first)
end
end
@@ -61,8 +61,8 @@ module Refinery
it "sorts by the more recent date" do
first, second = dates.map {|p| p.year.to_s }
- links.find("li:first").should have_content(second)
- links.find("li:last").should have_content(first)
+ expect(links.find("li:first")).to have_content(second)
+ expect(links.find("li:last")).to have_content(first)
end
end
end
@@ -71,11 +71,11 @@ module Refinery
let(:email) { "test@test.com" }
it "returns gravatar url" do
- helper.avatar_url(email).should eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=60.jpg")
+ expect(helper.avatar_url(email)).to eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=60.jpg")
end
it "accepts options hash to change default size" do
- helper.avatar_url(email, :size => 55).should eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=55.jpg")
+ expect(helper.avatar_url(email, :size => 55)).to eq("http://gravatar.com/avatar/b642b4217b34b1e8d3bd915fc65c4452?s=55.jpg")
end
end
end
diff --git a/spec/lib/refinery/blog/engine_spec.rb b/spec/lib/refinery/blog/engine_spec.rb
index 0e2952d..37edce3 100644
--- a/spec/lib/refinery/blog/engine_spec.rb
+++ b/spec/lib/refinery/blog/engine_spec.rb
@@ -8,7 +8,7 @@ module Refinery
Engine.load_seed
Engine.load_seed
- Refinery::Page.where(:link_url => '/blog').count.should eq(1)
+ expect(Refinery::Page.where(:link_url => '/blog').count).to eq(1)
end
end
end
diff --git a/spec/models/refinery/blog/category_spec.rb b/spec/models/refinery/blog/category_spec.rb
index 0292991..577cb9d 100644
--- a/spec/models/refinery/blog/category_spec.rb
+++ b/spec/models/refinery/blog/category_spec.rb
@@ -8,17 +8,17 @@ module Refinery
describe "validations" do
it "requires title" do
- FactoryGirl.build(:blog_category, :title => "").should_not be_valid
+ expect(FactoryGirl.build(:blog_category, :title => "")).not_to be_valid
end
it "won't allow duplicate titles" do
- FactoryGirl.build(:blog_category, :title => category.title).should_not be_valid
+ expect(FactoryGirl.build(:blog_category, :title => category.title)).not_to be_valid
end
end
describe "blog posts association" do
it "has a posts attribute" do
- category.should respond_to(:posts)
+ expect(category).to respond_to(:posts)
end
it "returns posts by published_at date in descending order" do
@@ -32,7 +32,7 @@ module Refinery
:published_at => Time.now,
:author => refinery_user })
- category.posts.newest_first.first.should == latest_post
+ expect(category.posts.newest_first.first).to eq(latest_post)
end
end
@@ -42,7 +42,7 @@ module Refinery
2.times do
category.posts << FactoryGirl.create(:blog_post)
end
- category.post_count.should == 2
+ expect(category.post_count).to eq(2)
end
end
end
diff --git a/spec/models/refinery/blog/comment_spec.rb b/spec/models/refinery/blog/comment_spec.rb
index 7a35a59..69430ac 100644
--- a/spec/models/refinery/blog/comment_spec.rb
+++ b/spec/models/refinery/blog/comment_spec.rb
@@ -7,11 +7,11 @@ module Refinery
let(:comment) { FactoryGirl.create(:blog_comment) }
it "saves" do
- comment.should_not be_nil
+ expect(comment).not_to be_nil
end
it "has a blog post" do
- comment.post.should_not be_nil
+ expect(comment.post).not_to be_nil
end
end
end
diff --git a/spec/models/refinery/blog/post_spec.rb b/spec/models/refinery/blog/post_spec.rb
index 73668e4..a56a33b 100644
--- a/spec/models/refinery/blog/post_spec.rb
+++ b/spec/models/refinery/blog/post_spec.rb
@@ -7,51 +7,51 @@ module Refinery
describe "validations" do
it "requires title" do
- FactoryGirl.build(:blog_post, :title => "").should_not be_valid
+ expect(FactoryGirl.build(:blog_post, :title => "")).not_to be_valid
end
it "won't allow duplicate titles" do
- FactoryGirl.build(:blog_post, :title => post.title).should_not be_valid
+ expect(FactoryGirl.build(:blog_post, :title => post.title)).not_to be_valid
end
it "requires body" do
- FactoryGirl.build(:blog_post, :body => nil).should_not be_valid
+ expect(FactoryGirl.build(:blog_post, :body => nil)).not_to be_valid
end
end
describe "comments association" do
it "have a comments attribute" do
- post.should respond_to(:comments)
+ expect(post).to respond_to(:comments)
end
it "destroys associated comments" do
FactoryGirl.create(:blog_comment, :blog_post_id => post.id)
post.destroy
- Blog::Comment.where(:blog_post_id => post.id).should be_empty
+ expect(Blog::Comment.where(:blog_post_id => post.id)).to be_empty
end
end
describe "categories association" do
it "have categories attribute" do
- post.should respond_to(:categories)
+ expect(post).to respond_to(:categories)
end
end
describe "tags" do
it "acts as taggable" do
- post.should respond_to(:tag_list)
+ expect(post).to respond_to(:tag_list)
post.tag_list = "refinery, cms"
post.save!
- post.tag_list.should include("refinery")
+ expect(post.tag_list).to include("refinery")
end
end
describe "authors" do
it "are authored" do
- described_class.instance_methods.map(&:to_sym).should include(:author)
+ expect(described_class.instance_methods.map(&:to_sym)).to include(:author)
end
end
@@ -67,8 +67,8 @@ module Refinery
it "returns all posts from specified month" do
#check for this month
date = "03/2011"
- described_class.by_month(Time.parse(date)).count.should be == 2
- described_class.by_month(Time.parse(date)).should == [@post2, @post1]
+ expect(described_class.by_month(Time.parse(date)).count).to eq(2)
+ expect(described_class.by_month(Time.parse(date))).to eq([@post2, @post1])
end
end
@@ -82,7 +82,7 @@ module Refinery
it "returns all published dates older than the argument" do
expected = [@post2.published_at, @post1.published_at]
- described_class.published_dates_older_than(5.minutes.ago).should eq(expected)
+ expect(described_class.published_dates_older_than(5.minutes.ago)).to eq(expected)
end
end
@@ -96,9 +96,9 @@ module Refinery
it "returns all posts which aren't in draft and pub date isn't in future" do
live_posts = described_class.live
- live_posts.count.should be == 2
- live_posts.should include(@post2)
- live_posts.should include(@post1)
+ expect(live_posts.count).to eq(2)
+ expect(live_posts).to include(@post2)
+ expect(live_posts).to include(@post1)
end
end
@@ -111,22 +111,22 @@ module Refinery
end
it "returns uncategorized posts if they exist" do
- described_class.uncategorized.should include @uncategorized_post
- described_class.uncategorized.should_not include @categorized_post
+ expect(described_class.uncategorized).to include @uncategorized_post
+ expect(described_class.uncategorized).not_to include @categorized_post
end
end
describe "#live?" do
it "returns true if post is not in draft and it's published" do
- FactoryGirl.build(:blog_post).should be_live
+ expect(FactoryGirl.build(:blog_post)).to be_live
end
it "returns false if post is in draft" do
- FactoryGirl.build(:blog_post, :draft => true).should_not be_live
+ expect(FactoryGirl.build(:blog_post, :draft => true)).not_to be_live
end
it "returns false if post pub date is in future" do
- FactoryGirl.build(:blog_post, :published_at => Time.now.advance(:minutes => 1)).should_not be_live
+ expect(FactoryGirl.build(:blog_post, :published_at => Time.now.advance(:minutes => 1))).not_to be_live
end
end
@@ -137,7 +137,7 @@ module Refinery
end
it "returns next article when called on current article" do
- described_class.newest_first.last.next.should == @post
+ expect(described_class.newest_first.last.next).to eq(@post)
end
end
@@ -148,7 +148,7 @@ module Refinery
end
it "returns previous article when called on current article" do
- described_class.first.prev.should == @post
+ expect(described_class.first.prev).to eq(@post)
end
end
@@ -159,7 +159,7 @@ module Refinery
end
it "should be true" do
- described_class.comments_allowed?.should be_truthy
+ expect(described_class.comments_allowed?).to be_truthy
end
end
@@ -169,14 +169,14 @@ module Refinery
end
it "should be false" do
- described_class.comments_allowed?.should be_falsey
+ expect(described_class.comments_allowed?).to be_falsey
end
end
end
describe "custom teasers" do
it "should allow a custom teaser" do
- FactoryGirl.create(:blog_post, :custom_teaser => 'This is some custom content').should be_valid
+ expect(FactoryGirl.create(:blog_post, :custom_teaser => 'This is some custom content')).to be_valid
end
end
@@ -187,7 +187,7 @@ module Refinery
end
it "should be true" do
- described_class.teasers_enabled?.should be_truthy
+ expect(described_class.teasers_enabled?).to be_truthy
end
end
@@ -197,7 +197,7 @@ module Refinery
end
it "should be false" do
- described_class.teasers_enabled?.should be_falsey
+ expect(described_class.teasers_enabled?).to be_falsey
end
end
end
@@ -205,9 +205,9 @@ module Refinery
describe "source url" do
it "should allow a source url and title" do
p = FactoryGirl.create(:blog_post, :source_url => 'google.com', :source_url_title => 'author')
- p.should be_valid
- p.source_url.should include('google')
- p.source_url_title.should include('author')
+ expect(p).to be_valid
+ expect(p.source_url).to include('google')
+ expect(p.source_url_title).to include('author')
end
end
@@ -217,10 +217,10 @@ module Refinery
Refinery::Blog.validate_source_url = true
end
it "should have canonical url" do
- UrlValidator.any_instance.should_receive(:resolve_redirects_verify_url).
+ expect_any_instance_of(UrlValidator).to receive(:resolve_redirects_verify_url).
and_return('http://www.google.com')
p = FactoryGirl.create(:blog_post, :source_url => 'google.com', :source_url_title => 'google')
- p.source_url.should include('www')
+ expect(p.source_url).to include('www')
end
end
context "with Refinery::Blog.validate_source_url set to false" do
@@ -229,7 +229,7 @@ module Refinery
end
it "should have original url" do
p = FactoryGirl.create(:blog_post, :source_url => 'google.com', :source_url_title => 'google')
- p.source_url.should_not include('www')
+ expect(p.source_url).not_to include('www')
end
end
end
diff --git a/spec/spec_helper.rb b/spec/spec_helper.rb
index 4b29712..3875b33 100644
--- a/spec/spec_helper.rb
+++ b/spec/spec_helper.rb
@@ -13,7 +13,6 @@ Rails.backtrace_cleaner.remove_silencers!
RSpec.configure do |config|
config.mock_with :rspec
- config.treat_symbols_as_metadata_keys_with_true_values = true
config.filter_run :focus => true
config.run_all_when_everything_filtered = true
end