diff options
Diffstat (limited to 'spec/features/refinery/blog/admin')
-rw-r--r-- | spec/features/refinery/blog/admin/categories_spec.rb | 210 | ||||
-rw-r--r-- | spec/features/refinery/blog/admin/comments_spec.rb | 2 | ||||
-rw-r--r-- | spec/features/refinery/blog/admin/menu_spec.rb | 20 | ||||
-rw-r--r-- | spec/features/refinery/blog/admin/posts_spec.rb | 30 |
4 files changed, 139 insertions, 123 deletions
diff --git a/spec/features/refinery/blog/admin/categories_spec.rb b/spec/features/refinery/blog/admin/categories_spec.rb index 7a8df8c..b1c8fd5 100644 --- a/spec/features/refinery/blog/admin/categories_spec.rb +++ b/spec/features/refinery/blog/admin/categories_spec.rb @@ -1,119 +1,121 @@ # encoding: utf-8 require 'spec_helper' -describe "Categories admin", type: :feature do - refinery_login_with :refinery_user +module Refinery + module Blog + module Admin + describe Category, type: :feature do + refinery_login_with_devise :authentication_devise_refinery_superuser - let(:title) { "lol" } + let(:title) { "lol" } - it "can create categories" do - visit refinery.admin_root_path + it "can create categories" do + visit refinery.admin_root_path - within("nav#menu") { click_link "Blog" } - within("nav.multilist") { click_link "Create new category" } + within("nav#menu") { click_link "Blog" } + within("nav.multilist") { click_link "Create new category" } - fill_in "Title", :with => title - click_button "Save" + fill_in "Title", :with => title + click_button "Save" - category = Refinery::Blog::Category.first - expect(category.title).to eq(title) - end - - context "with translations" do - before do - 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 = 'блог' - 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" - expect { click_button "Save" }.to change(Refinery::Blog::Category, :count).by(1) - @c = Refinery::Blog::Category.by_title("Testing Category") - end - - it "suceeds" do - expect(page).to have_content("'#{@c.title}' was successfully added.") - expect(Refinery::Blog::Category.count).to eq(1) - end - - it "shows locale for category" do - click_link "Manage" - within "#category_#{@c.id}" do - 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 - 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) - expect(page).not_to 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 - expect { click_button "Save" }.to change(Refinery::Blog::Category, :count).by(1) - @c = Refinery::Blog::Category.by_title(ru_category_title) - end - - it "suceeds" do - expect(page).to have_content("'#{@c.title}' was successfully added.") - expect(Refinery::Blog::Category.count).to eq(1) - end - - it "shows locale for category" do - click_link "Manage" - within "#category_#{@c.id}" do - expect(page).to have_css(".locale_icon.ru") - end - end - - it "does not show locale for primary locale" do - click_link "Manage" - within "#category_#{@c.id}" do - expect(page).not_to have_css(".locale_icon.en") + category = Refinery::Blog::Category.first + expect(category.title).to eq(title) end - end - - it "does not shows up in blog page for default locale" do - visit refinery.blog_root_path - 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 - expect(page).to have_selector('li') + context "with translations" do + before do + 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 = 'блог' + 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" + expect { click_button "Save" }.to change(Refinery::Blog::Category, :count).by(1) + @c = Refinery::Blog::Category.by_title("Testing Category") + end + + it "suceeds" do + expect(page).to have_content("'#{@c.title}' was successfully added.") + expect(Refinery::Blog::Category.count).to eq(1) + end + + it "shows locale for category" do + click_link "Manage" + within "#category_#{@c.id}" do + 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 + 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) + expect(page).not_to 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 + expect { click_button "Save" }.to change(Refinery::Blog::Category, :count).by(1) + @c = Refinery::Blog::Category.by_title(ru_category_title) + end + + it "suceeds" do + expect(page).to have_content("'#{@c.title}' was successfully added.") + expect(Refinery::Blog::Category.count).to eq(1) + end + + it "shows locale for category" do + click_link "Manage" + within "#category_#{@c.id}" do + expect(page).to have_css(".locale_icon.ru") + end + end + + it "does not show locale for primary locale" do + click_link "Manage" + within "#category_#{@c.id}" do + 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 + 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 + expect(page).to have_selector('li') + end + end + end end end - - end - - end end diff --git a/spec/features/refinery/blog/admin/comments_spec.rb b/spec/features/refinery/blog/admin/comments_spec.rb index 097210d..1c6d67d 100644 --- a/spec/features/refinery/blog/admin/comments_spec.rb +++ b/spec/features/refinery/blog/admin/comments_spec.rb @@ -4,7 +4,7 @@ module Refinery module Blog module Admin describe Comment, type: :feature do - refinery_login_with :refinery_user + refinery_login_with_devise :authentication_devise_refinery_superuser describe "#index" do context "when has no new unapproved comments" do diff --git a/spec/features/refinery/blog/admin/menu_spec.rb b/spec/features/refinery/blog/admin/menu_spec.rb index 748d5c3..64f6461 100644 --- a/spec/features/refinery/blog/admin/menu_spec.rb +++ b/spec/features/refinery/blog/admin/menu_spec.rb @@ -1,13 +1,19 @@ require 'spec_helper' -describe "Blog menu entry", type: :feature do - refinery_login_with :refinery_user +module Refinery + module Blog + module Admin + describe Menu, type: :feature do + refinery_login_with_devise :authentication_devise_refinery_superuser - it "is highlighted when managing the blog" do - visit refinery.admin_root_path + it "is highlighted when managing the blog" do + visit refinery.admin_root_path - within("#menu") { click_link "Blog" } + within("#menu") { click_link "Blog" } - expect(page).to have_css("a.active", :text => "Blog") + expect(page).to have_css("a.active", :text => "Blog") + end + end + end end -end +end
\ No newline at end of file diff --git a/spec/features/refinery/blog/admin/posts_spec.rb b/spec/features/refinery/blog/admin/posts_spec.rb index 0efbb1d..ffb4b15 100644 --- a/spec/features/refinery/blog/admin/posts_spec.rb +++ b/spec/features/refinery/blog/admin/posts_spec.rb @@ -5,7 +5,7 @@ module Refinery module Blog module Admin describe Post, type: :feature do - refinery_login_with :refinery_user + refinery_login_with_devise :authentication_devise_refinery_superuser let!(:blog_category) do Globalize.with_locale(:en) { FactoryGirl.create(:blog_category) } @@ -58,7 +58,7 @@ module Refinery end it "should belong to me" do - expect(subject.class.first.author).to eq(::Refinery::User.last) + expect(subject.class.first.author).to eq(::Refinery::Blog.user_class.last) end it "should save categories" do @@ -153,7 +153,7 @@ module Refinery end context "with multiple users" do - let!(:other_guy) { FactoryGirl.create(:refinery_user, :username => "Other Guy") } + let!(:other_guy) { FactoryGirl.create(:authentication_devise_refinery_user, :username => "Other Guy") } describe "create blog post with alternate author" do before do @@ -210,13 +210,20 @@ module Refinery end it "shows up in blog page for default locale" do - visit refinery.blog_root_path + visit refinery.blog_admin_root_path 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) - expect(page).not_to have_selector("#post_#{@p.id}") + it "does show locale for default locale" do + within "#post_#{@p.id}" do + expect(page).to have_css(".locale_icon.en") + end + end + + it "does not show locale for secondary locale" do + within "#post_#{@p.id}" do + expect(page).not_to have_css(".locale_icon.ru") + end end end @@ -259,13 +266,14 @@ module Refinery end end - it "does not show up in blog page for default locale" do - visit refinery.blog_root_path - expect(page).not_to have_selector("#post_#{@p.id}") + it "does show locale for secondary locale" do + within "#post_#{@p.id}" do + expect(page).to have_css(".locale_icon.ru") + end end it "shows up in blog page for secondary locale" do - visit refinery.blog_root_path(:locale => :ru) + visit refinery.blog_admin_root_path(:locale => :ru) expect(page).to have_selector("#post_#{@p.id}") end |