parent
53a30439ca
commit
61f913b727
3 changed files with 41 additions and 2 deletions
|
|
@ -1,6 +1,14 @@
|
||||||
class HomeController < ApplicationController
|
class HomeController < ApplicationController
|
||||||
|
before_filter :respond_to_options
|
||||||
|
|
||||||
def index
|
def index
|
||||||
@today = Date.current
|
@today = Date.current
|
||||||
@current = Conference.where("end_date >= ?", @today).order("start_date ASC")
|
@current = Conference.where("end_date >= ?", @today).order("start_date ASC")
|
||||||
end
|
end
|
||||||
|
|
||||||
|
def respond_to_options
|
||||||
|
respond_to do |format|
|
||||||
|
format.html { head :ok }
|
||||||
|
end if request.options?
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
||||||
|
|
@ -114,6 +114,5 @@ Osem::Application.routes.draw do
|
||||||
|
|
||||||
get "/admin" => redirect("/admin/conference")
|
get "/admin" => redirect("/admin/conference")
|
||||||
|
|
||||||
root :to => "home#index"
|
root to: 'home#index', via: [:get, :options]
|
||||||
|
|
||||||
end
|
end
|
||||||
|
|
|
||||||
32
spec/controllers/home_controller_spec.rb
Normal file
32
spec/controllers/home_controller_spec.rb
Normal file
|
|
@ -0,0 +1,32 @@
|
||||||
|
require 'spec_helper'
|
||||||
|
|
||||||
|
describe HomeController do
|
||||||
|
let(:conference) { create(:conference) }
|
||||||
|
describe 'GET #index' do
|
||||||
|
it 'Response code is 200' do
|
||||||
|
get :index
|
||||||
|
expect(response.response_code).to eq(200)
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Assigns conference' do
|
||||||
|
get :index
|
||||||
|
expect(assigns(:current)).to eq [conference]
|
||||||
|
end
|
||||||
|
|
||||||
|
it 'Assigns only pending conferences' do
|
||||||
|
create(:conference,
|
||||||
|
end_date: Date.today - 7,
|
||||||
|
start_date: Date.today - 14)
|
||||||
|
get :index
|
||||||
|
expect(assigns(:current)).to eq [conference]
|
||||||
|
end
|
||||||
|
|
||||||
|
end
|
||||||
|
|
||||||
|
describe 'OPTIONS #index' do
|
||||||
|
it 'Response code is 200' do
|
||||||
|
process :index, 'OPTIONS'
|
||||||
|
expect(response.response_code).to eq(200)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
Loading…
Add table
Add a link
Reference in a new issue