Skip to content

Commit

Permalink
Fix #6: application routes in engine
Browse files Browse the repository at this point in the history
  • Loading branch information
toothfairy committed Jul 31, 2014
1 parent 3eba843 commit 06656cc
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 1 deletion.
11 changes: 11 additions & 0 deletions app/helpers/tasuku/url_helper.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
module Tasuku
module UrlHelper
def url_for(options)
begin
super options
rescue ActionController::UrlGenerationError
main_app.url_for options
end
end
end
end
1 change: 1 addition & 0 deletions spec/dummy/app/controllers/application_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,5 @@ class ApplicationController < ActionController::Base
protect_from_forgery with: :exception

include ApplicationHelper
include Tasuku::UrlHelper
end
2 changes: 2 additions & 0 deletions spec/dummy/config/routes.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
Rails.application.routes.draw do

mount Tasks::Engine => "/tasks"

get "/", to: "application#test", as: :test
end
2 changes: 1 addition & 1 deletion spec/dummy/db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 20140611084458) do
ActiveRecord::Schema.define(version: 20140613115558) do

create_table "articles", force: true do |t|
t.datetime "created_at"
Expand Down
1 change: 1 addition & 0 deletions spec/spec_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

config.include FactoryGirl::Syntax::Methods
config.include ActionDispatch::TestProcess
config.include Rails.application.routes.url_helpers

config.fixture_path = "#{File.dirname(__FILE__)}/fixtures"
end
Expand Down
9 changes: 9 additions & 0 deletions spec/support/shared_examples_for_redirectable.rb
Original file line number Diff line number Diff line change
Expand Up @@ -33,5 +33,14 @@
expect(response).to redirect_to after_completion_path
end
end

context 'with application route' do
before { expect(subject).to receive(:after_completion_path_for).and_return test_path }

it 'redirects to the configured url' do
send(verb, action, params)
expect(response).to redirect_to test_path
end
end
end
end

0 comments on commit 06656cc

Please sign in to comment.