Sha256: 0af093bd7e1fb1a520fd0b36525fb89c1a39632631920a6b2815b1f2924bde58

Contents?: true

Size: 1.22 KB

Versions: 1

Compression:

Stored size: 1.22 KB

Contents

require "spec_helper"

module Refinery
  module Blog
    module Admin
      describe PostsController, type: :controller do
        refinery_login

        describe "#delete_translation" do
          let!(:blog_post) { FactoryBot.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, params: { :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, params: { :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, params: { :id => blog_post.id, :locale_to_delete => :fr }
            expect(response).to be_redirect
          end
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
refinerycms-blog-4.0.0 spec/controllers/refinery/blog/admin/posts_controller_spec.rb