aboutsummaryrefslogtreecommitdiffstats
path: root/spec/requests/refinery/blog/admin/categories_spec.rb
diff options
context:
space:
mode:
authorAdrien Coquio <adrien.coquio@gmail.com>2012-06-03 21:37:41 +0200
committerPhilip Arndt <parndt@gmail.com>2012-06-09 11:19:38 +1200
commitd0c249af2a2e630ac993eb23a691ef996613b55f (patch)
tree6992cf3816a6f5b1e022637a6780a7d24f1753cf /spec/requests/refinery/blog/admin/categories_spec.rb
parent7743fab73a5c60d9f5f0cf2ce65a3f0914b1376f (diff)
downloadrefinerycms-blog-d0c249af2a2e630ac993eb23a691ef996613b55f.tar.gz
refinerycms-blog-d0c249af2a2e630ac993eb23a691ef996613b55f.tar.bz2
refinerycms-blog-d0c249af2a2e630ac993eb23a691ef996613b55f.zip
Added i18n support to models through globalize3.
* Added Post translation * Added Category translation * Use friendly_id globalize with category * Added migrate_data option on migrations for translations * Use Refinery locale instead of I18n * Refactored duplicate locale_picker partial * Removed useless .all call * Use presence instead if / blank? * Added with_globalize scopes when loading posts of one category * Use Globalize when creating post factory * Fix failing specs by creating blog posts/categories using needed locale.
Diffstat (limited to 'spec/requests/refinery/blog/admin/categories_spec.rb')
-rw-r--r--spec/requests/refinery/blog/admin/categories_spec.rb101
1 files changed, 100 insertions, 1 deletions
diff --git a/spec/requests/refinery/blog/admin/categories_spec.rb b/spec/requests/refinery/blog/admin/categories_spec.rb
index c1809f7..9d4ddf3 100644
--- a/spec/requests/refinery/blog/admin/categories_spec.rb
+++ b/spec/requests/refinery/blog/admin/categories_spec.rb
@@ -1,8 +1,9 @@
+# encoding: utf-8
require 'spec_helper'
describe "Categories admin" do
refinery_login_with :refinery_user
-
+
let(:title) { "lol" }
it "can create categories" do
@@ -17,4 +18,102 @@ describe "Categories admin" do
category = Refinery::Blog::Category.first
category.title.should eq(title)
end
+
+ context "with translations" do
+ before(:each) do
+ Refinery::I18n.stub(:frontend_locales).and_return([:en, :ru])
+ blog_page = Globalize.with_locale(:en) { Factory.create(:page, :link_url => "/blog", :title => "Blog") }
+ Globalize.with_locale(:ru) do
+ blog_page.title = 'блог'
+ blog_page.save
+ end
+ end
+
+ describe "add a category with title for default locale" do
+ before do
+ Globalize.locale = :en
+ visit refinery.blog_admin_posts_path
+ click_link "Create new category"
+ fill_in "Title", :with => "Testing Category"
+ click_button "Save"
+ @c = Refinery::Blog::Category.find_by_title("Testing Category")
+ end
+
+ it "suceeds" do
+ page.should have_content("'#{@c.title}' was successfully added.")
+ Refinery::Blog::Category.count.should eq(1)
+ end
+
+ it "shows locale flag for category" do
+ click_link "Manage"
+ within "#category_#{@c.id}" do
+ page.should have_css("img[src='/assets/refinery/icons/flags/en.png']")
+ 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')
+ 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')
+ end
+
+ end
+
+ describe "add a category with title for secondary locale" do
+
+ let(:ru_category_title) { 'категория' }
+
+ before do
+ visit refinery.blog_admin_posts_path
+ click_link "Create new category"
+ within "#switch_locale_picker" do
+ click_link "Ru"
+ end
+ fill_in "Title", :with => ru_category_title
+ click_button "Save"
+ @c = Refinery::Blog::Category.find_by_title(ru_category_title)
+ end
+
+ it "suceeds" do
+ page.should have_content("'#{@c.title}' was successfully added.")
+ Refinery::Blog::Category.count.should eq(1)
+ end
+
+ it "shows locale flag for category" do
+ click_link "Manage"
+ within "#category_#{@c.id}" do
+ page.should have_css("img[src='/assets/refinery/icons/flags/ru.png']")
+ end
+ end
+
+ it "does not show locale flag 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']")
+ 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')
+ 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')
+ end
+ end
+
+
+ end
+
+
+ end
end