aboutsummaryrefslogtreecommitdiffstats
path: root/spec/controllers/refinery/blog/admin/posts_controller_spec.rb
blob: 65df5b3d199225a5c2a5ddf8d6c036eedf2dd479 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
require "spec_helper"

module Refinery
  module Blog
    module Admin
      describe PostsController, type: :controller do
        refinery_login_with_devise [:refinery, :superuser]

        describe "#delete_translation" do
          let!(:blog_post) { FactoryGirl.create(:blog_post) }

          before do
            blog_post.translations.create(:locale => :fr, :title => 'Un titre francais', :body => "La baguette, c'est bon. Mangez-en.")
            blog_post.translations.create(:locale => :es, :title => 'Un titulo espanol', :body => "Mi casa e su casa.")
          end

          it "destroys the translation" do
            post :delete_translation, :id => blog_post.id, :locale_to_delete => :fr
            expect(blog_post.translations.exists?(:locale => :fr)).to be_falsey
          end

          it "does not destroy other translations" do
            post :delete_translation, :id => blog_post.id, :locale_to_delete => :fr
            expect(blog_post.translations.exists?(:locale => :es)).to be_truthy
          end

          it "redirects on success" do
            post :delete_translation, :id => blog_post.id, :locale_to_delete => :fr
            expect(response).to be_redirect
          end
        end
      end
    end
  end
end