diff --git a/.env.sample b/.env.sample index 288b44a..5d8b73a 100644 --- a/.env.sample +++ b/.env.sample @@ -1,19 +1,7 @@ -HOST: lvh.me -DEVISE_SECRET: devise_secret -SECRET_TOKEN: caste_secret_token -TUMBLR_KEY: tumblr_key +ASSET_HOST=http://localhost:7000 +INSTAGRAM_CLIENT_ID=instagram-client-id +RACK_ENV=development +TUMBLR_KEY=tumblr-key TUMBLR_SECRET: tumblr_secret - -NEW_RELIC_APP_NAME: caste -NEW_RELIC_LICENSE_KEY: new_relic_key - -S3_BUCKET: s3_bucket -S3_ACCESS_KEY_ID: s3_access_key_id -S3_SECRET_ACCESS_KEY: s3_secret_access_key - -WEB_CONCURRENCY: 1 +WEB_CONCURRENCY=1 WEB_TIMEOUT: 30 - -INSTAGRAM_USER_ID: 12345 -INSTAGRAM_CLIENT_ID: instagram_client_id -INSTAGRAM_CLIENT_SECRET: instagram_client_secret diff --git a/Gemfile b/Gemfile index 68f8809..d9fe27e 100644 --- a/Gemfile +++ b/Gemfile @@ -27,11 +27,13 @@ gem 'paperclip' gem 'rack-cors', require: 'rack/cors' gem 'rack-timeout' gem 'rails', '>= 4.0.1' +gem 'rails_serve_static_assets' gem 'rails-assets-lodash' gem 'rails-assets-moment' gem 'rich', github: 'bastiaanterhorst/rich' gem 'roman-numerals' gem 'recipient_interceptor' +gem 'redis' gem 'sass-rails' gem 'tumblr_client' gem 'uglifier' @@ -65,6 +67,7 @@ group :test do end group :staging, :production do + gem 'sprockets-redirect' gem 'heroku_rails_deflate' gem 'newrelic_rpm', '>= 3.6.7' gem 'rails_12factor' diff --git a/Gemfile.lock b/Gemfile.lock index cc6c5a3..d2d4a8c 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -74,10 +74,10 @@ GEM json (~> 1.4) nokogiri (>= 1.4.4) uuidtools (~> 2.1) - barber (0.4.2) + barber (0.5.0) ember-source execjs - handlebars-source + handlebars-source (>= 1.0.0.rc.4) bcrypt (3.1.7) better_errors (1.0.1) coderay (>= 1.0.0) @@ -88,7 +88,7 @@ GEM sass (>= 3.2.0) thor builder (3.1.4) - chunky_png (1.2.9) + chunky_png (1.3.3) climate_control (0.0.3) activesupport (>= 3.0) cocaine (0.5.3) @@ -105,7 +105,7 @@ GEM chunky_png (~> 1.2) fssm (>= 0.2.7) sass (~> 3.1) - compass-rails (1.1.2) + compass-rails (2.0.0) compass (>= 0.12.2) crack (0.4.1) safe_yaml (~> 0.9.0) @@ -133,13 +133,13 @@ GEM activemodel ember-data-source (1.0.0.beta.11) ember-source - ember-rails (0.14.1) + ember-rails (0.15.0) active_model_serializers barber (>= 0.4.1) - ember-data-source - ember-source + ember-data-source (>= 1.0.0.beta.5) + ember-source (>= 1.1.0) execjs (>= 1.2) - handlebars-source + handlebars-source (> 1.0.0) jquery-rails (>= 1.0.17) railties (>= 3.1) ember-source (1.8.0) @@ -257,6 +257,7 @@ GEM polyamorous (~> 1.0.0) recipient_interceptor (0.1.2) mail + redis (3.1.0) responders (1.0.0) railties (>= 3.2, < 5) roman-numerals (0.3.0) @@ -300,6 +301,9 @@ GEM actionpack (>= 3.0) activesupport (>= 3.0) sprockets (~> 2.8) + sprockets-redirect (0.2.0) + activesupport (>= 3.1.0) + rack teaspoon (0.7.9) railties (>= 3.2.5, < 5) thor (0.18.1) @@ -373,7 +377,9 @@ DEPENDENCIES rails-assets-lodash rails-assets-moment rails_12factor + rails_serve_static_assets recipient_interceptor + redis rich! roman-numerals rspec-rails (>= 2.14) @@ -383,6 +389,7 @@ DEPENDENCIES spring spring-commands-rspec spring-commands-teaspoon + sprockets-redirect teaspoon timecop tumblr_client diff --git a/app/assets/images/projects/magenta/1.jpg b/app/assets/images/projects/magenta/1.jpg new file mode 100644 index 0000000..30f6ca5 Binary files /dev/null and b/app/assets/images/projects/magenta/1.jpg differ diff --git a/app/assets/images/projects/magenta/10.jpg b/app/assets/images/projects/magenta/10.jpg new file mode 100644 index 0000000..1ed6d84 Binary files /dev/null and b/app/assets/images/projects/magenta/10.jpg differ diff --git a/app/assets/images/projects/magenta/11.jpg b/app/assets/images/projects/magenta/11.jpg new file mode 100644 index 0000000..ee1e5bf Binary files /dev/null and b/app/assets/images/projects/magenta/11.jpg differ diff --git a/app/assets/images/projects/magenta/13.jpg b/app/assets/images/projects/magenta/13.jpg new file mode 100644 index 0000000..24ee58f Binary files /dev/null and b/app/assets/images/projects/magenta/13.jpg differ diff --git a/app/assets/images/projects/magenta/2.jpg b/app/assets/images/projects/magenta/2.jpg new file mode 100644 index 0000000..78c44a8 Binary files /dev/null and b/app/assets/images/projects/magenta/2.jpg differ diff --git a/app/assets/images/projects/magenta/3.jpg b/app/assets/images/projects/magenta/3.jpg new file mode 100644 index 0000000..4e5b88c Binary files /dev/null and b/app/assets/images/projects/magenta/3.jpg differ diff --git a/app/assets/images/projects/magenta/4.jpg b/app/assets/images/projects/magenta/4.jpg new file mode 100644 index 0000000..67029e3 Binary files /dev/null and b/app/assets/images/projects/magenta/4.jpg differ diff --git a/app/assets/images/projects/magenta/5.jpg b/app/assets/images/projects/magenta/5.jpg new file mode 100644 index 0000000..77ba13e Binary files /dev/null and b/app/assets/images/projects/magenta/5.jpg differ diff --git a/app/assets/images/projects/magenta/7.jpg b/app/assets/images/projects/magenta/7.jpg new file mode 100644 index 0000000..5de55f5 Binary files /dev/null and b/app/assets/images/projects/magenta/7.jpg differ diff --git a/app/assets/images/projects/magenta/8.jpg b/app/assets/images/projects/magenta/8.jpg new file mode 100644 index 0000000..b827cfc Binary files /dev/null and b/app/assets/images/projects/magenta/8.jpg differ diff --git a/app/assets/images/projects/magenta/9.jpg b/app/assets/images/projects/magenta/9.jpg new file mode 100644 index 0000000..2f0f2b9 Binary files /dev/null and b/app/assets/images/projects/magenta/9.jpg differ diff --git a/app/assets/images/projects/the-philadelphia-experiment/1.jpg b/app/assets/images/projects/the-philadelphia-experiment/1.jpg new file mode 100644 index 0000000..00380fe Binary files /dev/null and b/app/assets/images/projects/the-philadelphia-experiment/1.jpg differ diff --git a/app/assets/images/projects/the-philadelphia-experiment/10.jpg b/app/assets/images/projects/the-philadelphia-experiment/10.jpg new file mode 100644 index 0000000..a1d19b5 Binary files /dev/null and b/app/assets/images/projects/the-philadelphia-experiment/10.jpg differ diff --git a/app/assets/images/projects/the-philadelphia-experiment/12.jpg b/app/assets/images/projects/the-philadelphia-experiment/12.jpg new file mode 100644 index 0000000..11a088f Binary files /dev/null and b/app/assets/images/projects/the-philadelphia-experiment/12.jpg differ diff --git a/app/assets/images/projects/the-philadelphia-experiment/2.jpg b/app/assets/images/projects/the-philadelphia-experiment/2.jpg new file mode 100644 index 0000000..e46d53a Binary files /dev/null and b/app/assets/images/projects/the-philadelphia-experiment/2.jpg differ diff --git a/app/assets/images/projects/the-philadelphia-experiment/3.jpg b/app/assets/images/projects/the-philadelphia-experiment/3.jpg new file mode 100644 index 0000000..e07fc0f Binary files /dev/null and b/app/assets/images/projects/the-philadelphia-experiment/3.jpg differ diff --git a/app/assets/images/projects/the-philadelphia-experiment/4.jpg b/app/assets/images/projects/the-philadelphia-experiment/4.jpg new file mode 100644 index 0000000..fedb9e0 Binary files /dev/null and b/app/assets/images/projects/the-philadelphia-experiment/4.jpg differ diff --git a/app/assets/images/projects/the-philadelphia-experiment/5.jpg b/app/assets/images/projects/the-philadelphia-experiment/5.jpg new file mode 100644 index 0000000..da9dc1d Binary files /dev/null and b/app/assets/images/projects/the-philadelphia-experiment/5.jpg differ diff --git a/app/assets/images/projects/the-philadelphia-experiment/6.jpg b/app/assets/images/projects/the-philadelphia-experiment/6.jpg new file mode 100644 index 0000000..3abcfea Binary files /dev/null and b/app/assets/images/projects/the-philadelphia-experiment/6.jpg differ diff --git a/app/assets/images/projects/the-philadelphia-experiment/7.jpg b/app/assets/images/projects/the-philadelphia-experiment/7.jpg new file mode 100644 index 0000000..7e3fc94 Binary files /dev/null and b/app/assets/images/projects/the-philadelphia-experiment/7.jpg differ diff --git a/app/assets/images/projects/the-philadelphia-experiment/8.jpg b/app/assets/images/projects/the-philadelphia-experiment/8.jpg new file mode 100644 index 0000000..04c1c56 Binary files /dev/null and b/app/assets/images/projects/the-philadelphia-experiment/8.jpg differ diff --git a/app/assets/images/projects/the-philadelphia-experiment/9.jpg b/app/assets/images/projects/the-philadelphia-experiment/9.jpg new file mode 100644 index 0000000..d632cb5 Binary files /dev/null and b/app/assets/images/projects/the-philadelphia-experiment/9.jpg differ diff --git a/app/assets/images/projects/zachary-armstrong/1.jpg b/app/assets/images/projects/zachary-armstrong/1.jpg new file mode 100644 index 0000000..77438ff Binary files /dev/null and b/app/assets/images/projects/zachary-armstrong/1.jpg differ diff --git a/app/assets/images/projects/zachary-armstrong/11.jpg b/app/assets/images/projects/zachary-armstrong/11.jpg new file mode 100644 index 0000000..e232419 Binary files /dev/null and b/app/assets/images/projects/zachary-armstrong/11.jpg differ diff --git a/app/assets/images/projects/zachary-armstrong/2.jpg b/app/assets/images/projects/zachary-armstrong/2.jpg new file mode 100644 index 0000000..4c2aac6 Binary files /dev/null and b/app/assets/images/projects/zachary-armstrong/2.jpg differ diff --git a/app/assets/images/projects/zachary-armstrong/3.jpg b/app/assets/images/projects/zachary-armstrong/3.jpg new file mode 100644 index 0000000..8f4485d Binary files /dev/null and b/app/assets/images/projects/zachary-armstrong/3.jpg differ diff --git a/app/assets/images/projects/zachary-armstrong/4.jpg b/app/assets/images/projects/zachary-armstrong/4.jpg new file mode 100644 index 0000000..15b01a0 Binary files /dev/null and b/app/assets/images/projects/zachary-armstrong/4.jpg differ diff --git a/app/assets/images/projects/zachary-armstrong/5.jpg b/app/assets/images/projects/zachary-armstrong/5.jpg new file mode 100644 index 0000000..5a62901 Binary files /dev/null and b/app/assets/images/projects/zachary-armstrong/5.jpg differ diff --git a/app/assets/images/projects/zachary-armstrong/6.jpg b/app/assets/images/projects/zachary-armstrong/6.jpg new file mode 100644 index 0000000..c09bcde Binary files /dev/null and b/app/assets/images/projects/zachary-armstrong/6.jpg differ diff --git a/app/assets/images/projects/zachary-armstrong/7.jpg b/app/assets/images/projects/zachary-armstrong/7.jpg new file mode 100644 index 0000000..a6be3c7 Binary files /dev/null and b/app/assets/images/projects/zachary-armstrong/7.jpg differ diff --git a/app/assets/images/projects/zachary-armstrong/8.jpg b/app/assets/images/projects/zachary-armstrong/8.jpg new file mode 100644 index 0000000..beb1584 Binary files /dev/null and b/app/assets/images/projects/zachary-armstrong/8.jpg differ diff --git a/app/assets/images/projects/zachary-armstrong/9.jpg b/app/assets/images/projects/zachary-armstrong/9.jpg new file mode 100644 index 0000000..ee90e24 Binary files /dev/null and b/app/assets/images/projects/zachary-armstrong/9.jpg differ diff --git a/app/controllers/embers_controller.rb b/app/controllers/embers_controller.rb deleted file mode 100644 index cc33525..0000000 --- a/app/controllers/embers_controller.rb +++ /dev/null @@ -1,2 +0,0 @@ -class EmbersController < ApplicationController -end diff --git a/app/controllers/lookbooks_controller.rb b/app/controllers/lookbooks_controller.rb new file mode 100644 index 0000000..a060f98 --- /dev/null +++ b/app/controllers/lookbooks_controller.rb @@ -0,0 +1,20 @@ +class LookbooksController < StaticController + def index + @lookbooks = build_lookbooks + + render json: { lookbooks: @lookbooks } + end + + def build_lookbooks + [{ + id: "fall2014", + pages: [ + { url: image_url("lookbooks/fall2014/1.jpg") }, + { url: image_url("lookbooks/fall2014/2.jpg") }, + { url: image_url("lookbooks/fall2014/3.jpg") }, + { url: image_url("lookbooks/fall2014/4.jpg") }, + { url: image_url("lookbooks/fall2014/5.jpg") }, + ] + }] + end +end diff --git a/app/controllers/projects_controller.rb b/app/controllers/projects_controller.rb index 2ebbc96..3b84047 100644 --- a/app/controllers/projects_controller.rb +++ b/app/controllers/projects_controller.rb @@ -1,7 +1,67 @@ -class ProjectsController < InheritedResources::Base +class ProjectsController < StaticController def index - @projects = Project.all + @projects = find_projects - render json: @projects, serializer: CachedCollectionSerializer + render json: { projects: @projects } + end + + private + + def find_projects + [{ + id: 1, + numeral: "I", + slug: "the-philadelphia-experiment", + pages: [ + { url: image_url("projects/the-philadelphia-experiment/1.jpg") }, + { url: image_url("projects/the-philadelphia-experiment/2.jpg") }, + { url: image_url("projects/the-philadelphia-experiment/3.jpg") }, + { url: image_url("projects/the-philadelphia-experiment/4.jpg") }, + { url: image_url("projects/the-philadelphia-experiment/5.jpg") }, + { url: image_url("projects/the-philadelphia-experiment/6.jpg") }, + { url: image_url("projects/the-philadelphia-experiment/7.jpg") }, + { url: image_url("projects/the-philadelphia-experiment/8.jpg") }, + { url: image_url("projects/the-philadelphia-experiment/9.jpg") }, + { url: image_url("projects/the-philadelphia-experiment/10.jpg") }, + { url: vimeo_url(61014435), video: true }, + { url: image_url("projects/the-philadelphia-experiment/12.jpg") }, + ] + }, { + id: 2, + numeral: "II", + slug: "zachary-armstrong", + pages: [ + { url: image_url("projects/zachary-armstrong/1.jpg") }, + { url: image_url("projects/zachary-armstrong/2.jpg") }, + { url: image_url("projects/zachary-armstrong/3.jpg") }, + { url: image_url("projects/zachary-armstrong/4.jpg") }, + { url: image_url("projects/zachary-armstrong/5.jpg") }, + { url: image_url("projects/zachary-armstrong/6.jpg") }, + { url: image_url("projects/zachary-armstrong/7.jpg") }, + { url: image_url("projects/zachary-armstrong/8.jpg") }, + { url: image_url("projects/zachary-armstrong/9.jpg") }, + { url: vimeo_url(86785302), video: true }, + { url: image_url("projects/zachary-armstrong/11.jpg") }, + ] + }, { + id: 3, + numeral: "III", + slug: "magenta", + pages: [ + { url: image_url("projects/magenta/1.jpg") }, + { url: image_url("projects/magenta/2.jpg") }, + { url: image_url("projects/magenta/3.jpg") }, + { url: image_url("projects/magenta/4.jpg") }, + { url: image_url("projects/magenta/5.jpg") }, + { url: vimeo_url(90116548), video: true }, + { url: image_url("projects/magenta/7.jpg") }, + { url: image_url("projects/magenta/8.jpg") }, + { url: image_url("projects/magenta/9.jpg") }, + { url: image_url("projects/magenta/10.jpg") }, + { url: image_url("projects/magenta/11.jpg") }, + { url: vimeo_url(93339618), video: true }, + { url: image_url("projects/magenta/13.jpg") }, + ] + }] end end diff --git a/app/controllers/redis_controller.rb b/app/controllers/redis_controller.rb new file mode 100644 index 0000000..63d7505 --- /dev/null +++ b/app/controllers/redis_controller.rb @@ -0,0 +1,46 @@ +class RedisController < ApplicationController + def index + with_redis do |redis| + version = params[:version].presence || "current" + + html_key = "index:#{version}" + + html = redis.get(html_key) + + raise ActionController::RoutingError, "#{html_key} not found" if html.blank? + + insert_csrf_meta(html) + + render text: html + end + end + + private + + def insert_csrf_meta(html) + html.insert(head_pos(html), render_to_string(inline: "<%= csrf_meta_tags %>")) + end + + def head_pos(html) + head_open = html.index("", head_open) + 1 + end + + def body_bottom_pos(html) + html.index("") + end + + def with_redis + uri = URI.parse(ENV["REDISTOGO_URL"]) + + redis = Redis.new( + host: uri.host, + port: uri.port, + password: uri.password + ) + + yield redis + + redis.quit + end +end diff --git a/app/controllers/splashes_controller.rb b/app/controllers/splashes_controller.rb deleted file mode 100644 index 046f72e..0000000 --- a/app/controllers/splashes_controller.rb +++ /dev/null @@ -1,7 +0,0 @@ -class SplashesController < ApplicationController - def index - @splashes = Splash.all - - render json: @splashes, serializer: CachedCollectionSerializer - end -end diff --git a/app/controllers/static_controller.rb b/app/controllers/static_controller.rb new file mode 100644 index 0000000..ce28873 --- /dev/null +++ b/app/controllers/static_controller.rb @@ -0,0 +1,15 @@ +class StaticController < ApplicationController + + protected + + def image_url(name) + URI.join( + root_url, + self.class.helpers.asset_url(name), + ).to_s + end + + def vimeo_url(id) + "http://player.vimeo.com/video/#{id}?title=0&byline=0&portrait=0&color=cfcfcf%22%20width=%22888" + end +end diff --git a/app/controllers/videos_controller.rb b/app/controllers/videos_controller.rb new file mode 100644 index 0000000..ad444e2 --- /dev/null +++ b/app/controllers/videos_controller.rb @@ -0,0 +1,36 @@ +class VideosController < StaticController + def index + @videos = find_videos + + render json: { videos: @videos } + end + + private + + def find_videos + [{ + id: 6, + url: vimeo_url(109002548), + }, + { + id: 5, + url: vimeo_url(99653555), + }, + { + id: 4, + url: vimeo_url(84338572), + }, + { + id: 3, + url: vimeo_url(83601495), + }, + { + id: 2, + url: vimeo_url(81305762), + }, + { + id: 1, + url: vimeo_url(73152136), + }] + end +end diff --git a/app/views/embers/index.html b/app/views/embers/index.html deleted file mode 100644 index 8b13789..0000000 --- a/app/views/embers/index.html +++ /dev/null @@ -1 +0,0 @@ - diff --git a/config/application.rb b/config/application.rb index aa54a39..24d4412 100644 --- a/config/application.rb +++ b/config/application.rb @@ -12,6 +12,7 @@ module CasteServer class Application < Rails::Application + config.middleware.use "Rack::Deflater" config.middleware.insert_before "ActionDispatch::Static", "Rack::Cors" do allow do origins "*" @@ -32,9 +33,11 @@ class Application < Rails::Application end %w[services].each do |loaded| - config.autoload_paths << File.join(Rails.root, 'app', loaded) + config.autoload_paths << Rails.root.join("app", loaded) end + config.action_controller.asset_host = ENV.fetch("ASSET_HOST", "") + # Settings in config/environments/* take precedence over those specified here. # Application configuration should go into files in config/initializers # -- all .rb files in that directory are automatically loaded. diff --git a/config/environments/production.rb b/config/environments/production.rb index bbc4d4b..c29aeb4 100644 --- a/config/environments/production.rb +++ b/config/environments/production.rb @@ -8,8 +8,6 @@ # Code is not reloaded between requests. config.cache_classes = true - config.action_controller.asset_host = ENV.fetch("ASSET_HOST") - # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both thread web servers # and those relying on copy on write to perform better. diff --git a/config/environments/staging.rb b/config/environments/staging.rb index 091e175..841d3f9 100644 --- a/config/environments/staging.rb +++ b/config/environments/staging.rb @@ -9,8 +9,6 @@ # Code is not reloaded between requests. config.cache_classes = true - config.action_controller.asset_host = ENV.fetch("ASSET_HOST") - # Eager load code on boot. This eager loads most of Rails and # your application in memory, allowing both thread web servers # and those relying on copy on write to perform better. diff --git a/config/newrelic.yml b/config/newrelic.yml new file mode 100644 index 0000000..0d17255 --- /dev/null +++ b/config/newrelic.yml @@ -0,0 +1,34 @@ +common: &default_settings + app_name: "caste-server" + audit_log: + enabled: false + browser_monitoring: + auto_instrument: true + capture_params: false + developer_mode: false + error_collector: + capture_source: true + enabled: true + ignore_errors: "ActionController::RoutingError,Sinatra::NotFound" + license_key: "<%= ENV["NEW_RELIC_LICENSE_KEY"] %>" + log_level: info + monitor_mode: true + transaction_tracer: + enabled: true + record_sql: obfuscated + stack_trace_threshold: 0.500 + transaction_threshold: apdex_f +development: + <<: *default_settings + monitor_mode: false + developer_mode: true +test: + <<: *default_settings + monitor_mode: false +production: + <<: *default_settings + monitor_mode: true +staging: + <<: *default_settings + app_name: "caste-server (staging)" + monitor_mode: true diff --git a/config/routes.rb b/config/routes.rb index 3b1c8d5..1a07d27 100644 --- a/config/routes.rb +++ b/config/routes.rb @@ -6,10 +6,11 @@ scope :api, constraints: { format: :json } do resources :posts, only: [:index] resources :projects - resources :splashes, only: [:index] + resources :lookbooks, only: [:index] + resources :videos, only: [:index] resources :visuals, only: [:index] end - get "*path" => "embers#index" - root "embers#index" + get "*ember", to: "redis#index", constraints: ->(req){ req.format != :json } + root to: "redis#index" end diff --git a/spec/models/project_spec.rb b/spec/models/project_spec.rb deleted file mode 100644 index 41f5358..0000000 --- a/spec/models/project_spec.rb +++ /dev/null @@ -1,4 +0,0 @@ -describe Project do - it { should have_one(:banner) } - it { should have_many(:photos) } -end diff --git a/spec/models/splash_spec.rb b/spec/models/splash_spec.rb deleted file mode 100644 index 2d5b9a7..0000000 --- a/spec/models/splash_spec.rb +++ /dev/null @@ -1,37 +0,0 @@ -require 'spec_helper' - -describe Splash do - describe '#vimeo_id=' do - it 'sets the #video_url' do - splash = Splash.new(vimeo_id: 1234) - - expect(splash.video_url).to eq '//player.vimeo.com/video/1234?title=0&byline=0&portrait=0&color=ffffff' - end - - context 'when the video_url is set' do - it "doesn't override the #video_url" do - splash = Splash.new(video_url: 'http://thing.com') - - splash.vimeo_id = 1234 - - expect(splash.video_url).to eq 'http://thing.com' - end - end - end - - describe '#vimeo_id' do - it 'comes from the #video_url' do - splash = Splash.new(video_url: '//player.vimeo.com/video/1234?title=0&byline=0&portrait=0&color=ffffff') - - expect(splash.vimeo_id).to eq '1234' - end - - context 'when there is no #video_url' do - it 'returns nil' do - splash = Splash.new - - expect(splash.vimeo_id).to be_nil - end - end - end -end diff --git a/spec/requests/lookbooks_spec.rb b/spec/requests/lookbooks_spec.rb new file mode 100644 index 0000000..7cf3a76 --- /dev/null +++ b/spec/requests/lookbooks_spec.rb @@ -0,0 +1,8 @@ +describe "GET /api/lookbooks", type: :request do + it "returns all lookbooks" do + get "/api/lookbooks", json_header + + expect(response.status).to eq 200 + expect(response).to match_response_schema("lookbooks") + end +end diff --git a/spec/requests/projects_spec.rb b/spec/requests/projects_spec.rb index f2cf782..d0f7cd9 100644 --- a/spec/requests/projects_spec.rb +++ b/spec/requests/projects_spec.rb @@ -1,8 +1,5 @@ describe "GET /api/projects" do it "includes all published projects" do - project = create(:project, :published, photos: [create(:photo)], ) - create(:banner, resource: project) - get "/api/projects", {}, json_header expect(response.status).to eq 200 diff --git a/spec/requests/splashes_spec.rb b/spec/requests/splashes_spec.rb deleted file mode 100644 index 0637aed..0000000 --- a/spec/requests/splashes_spec.rb +++ /dev/null @@ -1,10 +0,0 @@ -describe "GET /api/splashes" do - it "returns published splashes" do - create(:splash, :published) - - get "/api/splashes", {}, json_header - - expect(response.status).to eq 200 - expect(response).to match_response_schema("splashes") - end -end diff --git a/spec/requests/videos_spec.rb b/spec/requests/videos_spec.rb new file mode 100644 index 0000000..aaace6d --- /dev/null +++ b/spec/requests/videos_spec.rb @@ -0,0 +1,8 @@ +describe "GET /api/videos" do + it "returns published videos" do + get "/api/videos", {}, json_header + + expect(response.status).to eq 200 + expect(response).to match_response_schema("videos") + end +end diff --git a/spec/support/api/schemas/lookbooks.json b/spec/support/api/schemas/lookbooks.json new file mode 100644 index 0000000..fe5ec21 --- /dev/null +++ b/spec/support/api/schemas/lookbooks.json @@ -0,0 +1,28 @@ +{ + "type": "object", + "required": ["lookbooks"], + "properties": { + "lookbooks": { + "type": "array", + "items": { + "required": [ + "id", + "pages" + ], + "properties": { + "id": { "type": "string" }, + "pages": { + "type": "array", + "items": { + "type": "object", + "required": ["url"], + "properties": { + "url": { "type": "string" } + } + } + } + } + } + } + } +} diff --git a/spec/support/api/schemas/projects.json b/spec/support/api/schemas/projects.json index 85181dc..80f25d7 100644 --- a/spec/support/api/schemas/projects.json +++ b/spec/support/api/schemas/projects.json @@ -1,45 +1,29 @@ { "type": "object", - "required": ["projects", "photos"], + "required": ["projects"], "properties": { "projects": { "type": "array", "items": { "required": [ "id", - "name", - "video_url", - "published_at", - "photo_ids" + "numeral", + "pages", + "slug" ], "properties" : { "id": { "type": "integer" }, - "name": { "type": "string" }, - "video_url": { "type": "string" }, - "published_at": { "type": "string", "format": "date-time" }, - "photo_ids": { "type": "array" }, - "banner": { "type": "string" }, - "banner_hover": { "type": "string" } - } - } - }, - "photos": { - "type": "array", - "items": { - "required": [ - "id", - "url", - "caption", - "thumbnail" - ], - "properties" : { - "id": { "type": "integer" }, - "url": { "type": "string" }, - "caption": { "type": "string" }, - "thumbnail": { "type": "string" } + "numeral": { "type": "string" }, + "slug": { "type": "string" }, + "pages": { + "type": "array", + "items": { + "url": { "type": "string" }, + "video": { "type": "boolean" } + } + } } } } } } - diff --git a/spec/support/api/schemas/splashes.json b/spec/support/api/schemas/splashes.json deleted file mode 100644 index 84dae66..0000000 --- a/spec/support/api/schemas/splashes.json +++ /dev/null @@ -1,23 +0,0 @@ -{ - "type": "object", - "required": ["splashes"], - "properties": { - "splashes": { - "type": "array", - "items": { - "required": [ - "id", - "name", - "video_url", - "published_at" - ], - "properties" : { - "id": { "type": "integer" }, - "name": { "type": "string" }, - "video_url": { "type": "string" }, - "published_at": { "type": "string", "format": "date-time" } - } - } - } - } -} diff --git a/spec/support/api/schemas/videos.json b/spec/support/api/schemas/videos.json new file mode 100644 index 0000000..ab1c989 --- /dev/null +++ b/spec/support/api/schemas/videos.json @@ -0,0 +1,19 @@ +{ + "type": "object", + "required": ["videos"], + "properties": { + "videos": { + "type": "array", + "items": { + "required": [ + "id", + "url" + ], + "properties" : { + "id": { "type": "integer" }, + "url": { "type": "string" } + } + } + } + } +}