Sha256: 06263a847e8c72035759354a8c6bab5bd16bb34e55a456ae7e519cacc85d75f0

Contents?: true

Size: 1.67 KB

Versions: 15

Compression:

Stored size: 1.67 KB

Contents

require File.expand_path(File.dirname(__FILE__) + '/../../test_helper' )

if ActionController::Base.respond_to?(:tracks_url_history)
  module IntegrationTests
    module UrlHistoryTests
      class SectionTest < ActionController::IntegrationTest
        def setup
          super
          @section = Page.find_by_title 'a page'
          @another_section = Page.find_by_title 'another page'
          @site = @section.site
          use_site! @site
        end
      
        unless ApplicationController.tracks_url_history?
          test "without url_history: Admin views page, edits the permalink and gets 404" do
            visit '/another-page'
            login_as_admin
            revise_the_page_permalink
            visit '/another-page'
            assert_status 404
          end
        end

        if ApplicationController.tracks_url_history?
          test "with url_history: Admin views page, edits the permalink and gets redirected" do
            visit '/another-page'
            assert_status 200
            request.url.should =~ %r(/another-page)
            UrlHistory::Entry.recent_by_url(request.url).should_not be_nil

            login_as_admin
            revise_the_page_permalink
            visit '/another-page'
            assert_status 200
            request.url.should =~ %r(/another-page-updated-permalink)
          end
        end
    
        def revise_the_page_permalink
          visit "/admin/sites/#{@site.id}/sections/#{@another_section.id}/edit"
          fill_in 'section[permalink]', :with => 'another-page-updated-permalink'
          click_button 'Save'
          request.url.should =~ %r(/admin/sites/\d+/sections)
        end
      end
    end
  end
end

Version data entries

15 entries across 15 versions & 2 rubygems

Version Path
adva-0.3.2 test/plugins/adva_url_history/section_test.rb
adva-0.3.1 test/plugins/adva_url_history/section_test.rb
adva-0.3.0 test/plugins/adva_url_history/section_test.rb
adva-0.2.4 test/plugins/adva_url_history/section_test.rb
adva-0.2.3 test/plugins/adva_url_history/section_test.rb
adva-0.2.2 test/plugins/adva_url_history/section_test.rb
adva-0.2.1 test/plugins/adva_url_history/section_test.rb
adva-0.2.0 test/plugins/adva_url_history/section_test.rb
adva-0.1.4 test/plugins/adva_url_history/section_test.rb
adva-0.1.3 test/plugins/adva_url_history/section_test.rb
adva-0.1.2 test/plugins/adva_url_history/section_test.rb
adva-0.1.1 test/plugins/adva_url_history/section_test.rb
adva-0.1.0 test/plugins/adva_url_history/section_test.rb
adva_cms-0.0.1 test/plugins/adva_url_history/section_test.rb
adva-0.0.1 adva_cms/test/plugins/adva_url_history/section_test.rb