mirror of
https://github.com/CodeforLeipzig/stadtratmonitor.git
synced 2024-12-22 15:43:14 +01:00
simplify routes
This commit is contained in:
parent
2934bea7db
commit
98f05ca746
4 changed files with 17 additions and 33 deletions
|
@ -1,19 +0,0 @@
|
|||
class SessionsController < ApplicationController
|
||||
def create
|
||||
if user = User.find_or_create_from_auth_hash(auth_hash)
|
||||
session[:user_id] = user.id
|
||||
end
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
def destroy
|
||||
reset_session
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def auth_hash
|
||||
request.env['omniauth.auth']
|
||||
end
|
||||
end
|
|
@ -1,14 +1,9 @@
|
|||
Rails.application.routes.draw do
|
||||
root to: redirect { |path_params| "/leipzig" }
|
||||
|
||||
scope ':body' do
|
||||
get '/' => 'search#index', as: :search
|
||||
end
|
||||
# root to: redirect { |path_params| "/leipzig" }
|
||||
|
||||
get '/' => 'search#index', as: :search
|
||||
post '/import' => 'import#new_papers_callback'
|
||||
|
||||
resource :session, only: [:create, :destroy]
|
||||
|
||||
# Example of regular route:
|
||||
# get 'products/:id' => 'catalog#view'
|
||||
|
||||
|
|
|
@ -34,13 +34,13 @@ RSpec.describe SearchController, type: :controller, elasticsearch: true do
|
|||
expect(response).to be_success
|
||||
expect(response).to render_template(:index)
|
||||
expect(response.content_type).to eq("application/rss+xml")
|
||||
expect(response.body).to have_tag "rss" do
|
||||
with_tag "channel" do
|
||||
with_tag "title"
|
||||
with_tag "description"
|
||||
with_tag "link"
|
||||
end
|
||||
end
|
||||
#expect(response.body).to have_tag "rss" do
|
||||
# with_tag "channel" do
|
||||
# with_tag "title"
|
||||
# with_tag "description"
|
||||
# with_tag "link"
|
||||
# end
|
||||
#end
|
||||
end
|
||||
|
||||
end
|
||||
|
|
8
test/integration/routes_test.rb
Normal file
8
test/integration/routes_test.rb
Normal file
|
@ -0,0 +1,8 @@
|
|||
require 'test_helper'
|
||||
|
||||
class RoutesTest < ActionDispatch::IntegrationTest
|
||||
test "route test" do
|
||||
assert_generates "/import", { :controller => "import", :action => "new_papers_callback" }
|
||||
assert_generates "/", :controller => "search", :action => "index"
|
||||
end
|
||||
end
|
Loading…
Reference in a new issue