Skip to content

Commit

Permalink
add home specs
Browse files Browse the repository at this point in the history
  • Loading branch information
croyfish committed Oct 3, 2024
1 parent 7582d0d commit 1b0e402
Show file tree
Hide file tree
Showing 10 changed files with 169 additions and 37 deletions.
4 changes: 4 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,10 @@ gem 'httparty'
gem 'json'
gem 'lograge'
#gem 'logstash-event', github: 'elastic/logstash', tag: 'v8.15.2'
gem 'mutex_m'
gem 'nokogiri'
gem 'open_uri_redirections'
gem 'ostruct'
gem 'paper_trail'
gem 'pg'
gem 'rack-cors'
Expand Down Expand Up @@ -95,4 +97,6 @@ group :test do
gem 'simplecov'
gem 'database_cleaner'
gem 'rspec-rails'
gem 'spring'
gem 'spring-commands-rspec'
end
9 changes: 9 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -1881,6 +1881,7 @@ GEM
multi_xml (0.7.1)
bigdecimal (~> 3.1)
multipart-post (2.4.1)
mutex_m (0.2.0)
net-http-persistent (4.0.4)
connection_pool (~> 2.2)
net-http-pipeline (1.0.1)
Expand All @@ -1899,6 +1900,7 @@ GEM
open_uri_redirections (0.2.1)
orm_adapter (0.5.0)
os (1.1.4)
ostruct (0.6.0)
paper_trail (15.2.0)
activerecord (>= 6.1)
request_store (~> 1.4)
Expand Down Expand Up @@ -2074,6 +2076,9 @@ GEM
simplecov-html (0.13.1)
simplecov_json_formatter (0.1.4)
slop (3.6.0)
spring (4.2.1)
spring-commands-rspec (1.0.4)
spring (>= 0.9.1)
sprockets (4.2.1)
concurrent-ruby (~> 1.0)
rack (>= 2.2.4, < 4)
Expand Down Expand Up @@ -2188,8 +2193,10 @@ DEPENDENCIES
mini_racer
minitest
minitest-stub_any_instance
mutex_m
nokogiri
open_uri_redirections
ostruct
paper_trail
pg
pry
Expand All @@ -2211,6 +2218,8 @@ DEPENDENCIES
rubocop-performance
sass-rails
simplecov
spring
spring-commands-rspec
sprockets-rails
stimulus-rails
test-unit
Expand Down
44 changes: 9 additions & 35 deletions app/controllers/home_controller.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,7 @@
class HomeController < ApplicationController
layout 'empty', :only => [ :extend_session_iframe ]

def index

end
def index; end

def mln_file_names
calendar_event = Document.calendar_of_events
Expand All @@ -16,57 +14,33 @@ def mln_file_names
end

def swagger_docs
render :json => File.read("app/controllers/api/swagger/swaggerDoc.json")
end

def secondary_menu
render :json => File.read("app/controllers/api/swagger/swaggerDoc.json")
end


# I'm not sure this is still needed (@JC 2024-10-03)
def secondary_menu; end

# for timing out sessions, this method reloads a hidden iframe so that the user's session["warden.user.user.session"]["last_request_at"] updates
def extend_session_iframe
user_signed_in?
end

# Display's mylibrarynyc information
def about; end


# Display's mylibrarynyc contact's information
def contacts; end


# Display's mylibrarynyc school's information
def participating_schools; end


def digital_resources; end

def help
store_location_for(:user, "contact")
end

def faq
faqs = FaqsController.new.frequently_asked_questions
render json: { faqs: faqs }
end

def faq_data

end
def faq_data; end

# Create news-letter confirmation email in google sheets
def newsletter_confirmation

end
def newsletter_confirmation; end

def newsletter_confirmation_msg
is_success = NewsLetterController.new.create_news_letter_email_in_google_sheets(params)
render json: { success: is_success }
end

def calendar_event_error
end

def calendar_event
render json: { calendar_event: Document.calendar_of_events }
end
Expand All @@ -91,7 +65,7 @@ def menu_of_services
respond_to do |format|
file = URI.open(File.join(Rails.root, 'app/javascript/pdf/2021_2022_MyLibraryNYC_Menu_of_Services_for_Educators.pdf'))
menu_of_services_pdf = file.read
format.pdf do
format.pdf do
send_data(menu_of_services_pdf, type: "application/pdf", disposition: :inline)
end
end
Expand Down
4 changes: 4 additions & 0 deletions bin/rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/usr/bin/env ruby
load File.expand_path("spring", __dir__)
require 'bundler/setup'
load Gem.bin_path('rspec-core', 'rspec')
14 changes: 14 additions & 0 deletions bin/spring
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
#!/usr/bin/env ruby

# This file loads Spring without loading other gems in the Gemfile in order to be fast.
# It gets overwritten when you run the `spring binstub` command.

if !defined?(Spring) && [nil, "development", "test"].include?(ENV["RAILS_ENV"])
require "bundler"

Bundler.locked_gems.specs.find { |spec| spec.name == "spring" }&.tap do |spring|
Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path
gem "spring", spring.version
require "spring/binstub"
end
end
2 changes: 1 addition & 1 deletion config/environments/test.rb
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
# test suite. You never need to work with it otherwise. Remember that
# your test database is "scratch space" for the test suite and is wiped
# and recreated between test runs. Don't rely on the data there!
config.cache_classes = true
config.cache_classes = false

# Configure static asset server for tests with Cache-Control for performance
config.serve_static_assets = true
Expand Down
1 change: 0 additions & 1 deletion config/routes.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
get '/logged_in', to: 'sessions#logged_in?'
get 'extend_session_iframe' => 'home#extend_session_iframe'
get 'home/calendar_event/:filename', to: 'home#mln_calendar'
get 'home/calendar_event/error', to: 'home#calendar_event_error'
get 'home/calendar_event', to: 'home#calendar_event'
get 'home/newsletter_confirmation_msg', to: 'home#newsletter_confirmation_msg'
get '/menu_of_services/:filename', to: 'home#menu_of_services'
Expand Down
3 changes: 3 additions & 0 deletions spec/factories/factories.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
FactoryBot.define do
factory :book do
end

factory :faq do
end
end
8 changes: 8 additions & 0 deletions spec/requests/faq_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
require 'rails_helper'

RSpec.describe 'Faq', type: :request do
# describe '#show' do
# let!(:faq) { create(:faq) }
# let(:get_url) { "http://localhost:3000/faq" }
# end
end
117 changes: 117 additions & 0 deletions spec/requests/home_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,117 @@
require 'rails_helper'

RSpec.describe 'Home', type: :request do
describe '#index' do
let(:get_url) { "http://localhost:3000" }

it 'gets successfully' do
get get_url
expect(response).to be_successful
end
end

describe '#mln_file_names' do
let(:get_url) { "http://localhost:3000/home/get_mln_file_names" }

it 'gets successfully' do
get get_url
expect(response).to be_successful
end
end

describe '#swagger_docs' do
let(:get_url) { "http://localhost:3000/docs/mylibrarynyc" }

it 'gets successfully' do
get get_url
expect(response).to be_successful
end
end

describe '#digital_resources' do
let(:get_url) { "http://localhost:3000/help/access-digital-resources" }

it 'gets successfully' do
get get_url
expect(response).to be_successful
end
end

describe '#help' do
let(:get_url) { "http://localhost:3000/contact" }

it 'gets successfully' do
get get_url
expect(response).to be_successful
end
end

describe '#faq_data' do
let(:get_url) { "http://localhost:3000/faq" }

it 'gets successfully' do
get get_url
expect(response).to be_successful
end
end

describe '#newsletter_confirmation' do
let(:get_url) { "http://localhost:3000/newsletter_confirmation" }

it 'gets successfully' do
get get_url
expect(response).to be_successful
end
end

describe '#newsletter_confirmation_msg' do
let(:get_url) { "http://localhost:3000/home/newsletter_confirmation_msg" }

it 'gets successfully' do
get get_url
expect(response).to be_successful
end
end

describe '#calendar_event' do
let(:get_url) { "http://localhost:3000/home/calendar_event" }

it 'gets successfully' do
get get_url
expect(response).to be_successful
end
end

describe '#mln_calendar' do
let(:get_url) { "http://localhost:3000/home/calendar_event/#{filename}" }
let(:filename) { 'some_filename.pdf' }

it 'gets successfully' do
get get_url
expect(response).to be_successful
end
end

describe '#menu_of_services' do
let(:get_url) { "http://localhost:3000/menu_of_services/#{filename}" }

context 'filename is menu_of_services.pdf' do
let(:filename) { 'menu_of_services.pdf' }

it 'gets successfully' do
get get_url
expect(response).to be_successful
end
end

context 'filename is something else' do
let(:filename) { 'something_else.pdf' }

it 'redirects' do
get get_url
expect(response.response_code).to eq(302)
end
end
end

end

0 comments on commit 1b0e402

Please sign in to comment.