├── log └── .keep ├── tmp └── .keep ├── vendor └── .keep ├── lib ├── assets │ └── .keep └── tasks │ └── .keep ├── public ├── favicon.ico ├── apple-touch-icon.png ├── apple-touch-icon-precomposed.png ├── robots.txt ├── 500.html ├── 422.html └── 404.html ├── app ├── assets │ ├── images │ │ └── .keep │ ├── javascripts │ │ ├── channels │ │ │ └── .keep │ │ ├── cable.js │ │ └── application.js │ ├── config │ │ └── manifest.js │ └── stylesheets │ │ └── application.css ├── graphql │ ├── types │ │ ├── .keep │ │ ├── authenticate_type.rb │ │ ├── auth_provider_signup_data.rb │ │ ├── auth_provider_email_input.rb │ │ ├── mutation_type.rb │ │ ├── query_type.rb │ │ ├── user_type.rb │ │ ├── booking_type.rb │ │ └── rental_type.rb │ ├── mutations │ │ ├── .keep │ │ ├── sign_in_user.rb │ │ ├── create_user.rb │ │ └── book_rental.rb │ ├── record_loader.rb │ └── landbnb_schema.rb ├── models │ ├── concerns │ │ └── .keep │ ├── application_record.rb │ ├── booking.rb │ ├── user.rb │ ├── rental.rb │ └── auth_token.rb ├── controllers │ ├── concerns │ │ └── .keep │ ├── application_controller.rb │ └── graphql_controller.rb ├── views │ └── layouts │ │ ├── mailer.text.erb │ │ ├── mailer.html.erb │ │ └── application.html.erb ├── helpers │ └── application_helper.rb ├── jobs │ └── application_job.rb ├── channels │ └── application_cable │ │ ├── channel.rb │ │ └── connection.rb └── mailers │ └── application_mailer.rb ├── .rspec ├── package.json ├── bin ├── bundle ├── rake ├── rails ├── yarn ├── spring ├── update └── setup ├── config ├── spring.rb ├── boot.rb ├── environment.rb ├── initializers │ ├── graphiql.rb │ ├── mime_types.rb │ ├── application_controller_renderer.rb │ ├── optics_agent.rb │ ├── filter_parameter_logging.rb │ ├── cookies_serializer.rb │ ├── backtrace_silencers.rb │ ├── wrap_parameters.rb │ ├── assets.rb │ └── inflections.rb ├── cable.yml ├── routes.rb ├── locales │ └── en.yml ├── application.rb ├── secrets.yml ├── environments │ ├── test.rb │ ├── development.rb │ └── production.rb ├── puma.rb └── database.yml ├── config.ru ├── Rakefile ├── db ├── migrate │ ├── 20170807142900_create_users.rb │ ├── 20170807143003_create_bookings.rb │ └── 20170807142908_create_rentals.rb ├── seeds.rb └── schema.rb ├── .gitignore ├── README.md ├── spec ├── graphql │ └── mutations │ │ └── sign_in_user_spec.rb ├── rails_helper.rb └── spec_helper.rb ├── Gemfile └── Gemfile.lock /log/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /tmp/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /vendor/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/assets/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/tasks/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/favicon.ico: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/images/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/graphql/types/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/graphql/mutations/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/models/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /.rspec: -------------------------------------------------------------------------------- 1 | --require spec_helper 2 | -------------------------------------------------------------------------------- /app/controllers/concerns/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/assets/javascripts/channels/.keep: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /public/apple-touch-icon-precomposed.png: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.text.erb: -------------------------------------------------------------------------------- 1 | <%= yield %> 2 | -------------------------------------------------------------------------------- /app/helpers/application_helper.rb: -------------------------------------------------------------------------------- 1 | module ApplicationHelper 2 | end 3 | -------------------------------------------------------------------------------- /app/jobs/application_job.rb: -------------------------------------------------------------------------------- 1 | class ApplicationJob < ActiveJob::Base 2 | end 3 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "landbnb", 3 | "private": true, 4 | "dependencies": {} 5 | } 6 | -------------------------------------------------------------------------------- /app/models/application_record.rb: -------------------------------------------------------------------------------- 1 | class ApplicationRecord < ActiveRecord::Base 2 | self.abstract_class = true 3 | end 4 | -------------------------------------------------------------------------------- /public/robots.txt: -------------------------------------------------------------------------------- 1 | # See http://www.robotstxt.org/robotstxt.html for documentation on how to use the robots.txt file 2 | -------------------------------------------------------------------------------- /app/channels/application_cable/channel.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Channel < ActionCable::Channel::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/assets/config/manifest.js: -------------------------------------------------------------------------------- 1 | //= link_tree ../images 2 | //= link_directory ../javascripts .js 3 | //= link_directory ../stylesheets .css 4 | -------------------------------------------------------------------------------- /app/channels/application_cable/connection.rb: -------------------------------------------------------------------------------- 1 | module ApplicationCable 2 | class Connection < ActionCable::Connection::Base 3 | end 4 | end 5 | -------------------------------------------------------------------------------- /app/controllers/application_controller.rb: -------------------------------------------------------------------------------- 1 | class ApplicationController < ActionController::Base 2 | protect_from_forgery with: :exception 3 | end 4 | -------------------------------------------------------------------------------- /app/mailers/application_mailer.rb: -------------------------------------------------------------------------------- 1 | class ApplicationMailer < ActionMailer::Base 2 | default from: 'from@example.com' 3 | layout 'mailer' 4 | end 5 | -------------------------------------------------------------------------------- /bin/bundle: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../../Gemfile', __FILE__) 3 | load Gem.bin_path('bundler', 'bundle') 4 | -------------------------------------------------------------------------------- /config/spring.rb: -------------------------------------------------------------------------------- 1 | %w( 2 | .ruby-version 3 | .rbenv-vars 4 | tmp/restart.txt 5 | tmp/caching-dev.txt 6 | ).each { |path| Spring.watch(path) } 7 | -------------------------------------------------------------------------------- /config/boot.rb: -------------------------------------------------------------------------------- 1 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__) 2 | 3 | require 'bundler/setup' # Set up gems listed in the Gemfile. 4 | -------------------------------------------------------------------------------- /config.ru: -------------------------------------------------------------------------------- 1 | # This file is used by Rack-based servers to start the application. 2 | 3 | require_relative 'config/environment' 4 | 5 | run Rails.application 6 | -------------------------------------------------------------------------------- /config/environment.rb: -------------------------------------------------------------------------------- 1 | # Load the Rails application. 2 | require_relative 'application' 3 | 4 | # Initialize the Rails application. 5 | Rails.application.initialize! 6 | -------------------------------------------------------------------------------- /config/initializers/graphiql.rb: -------------------------------------------------------------------------------- 1 | if Rails.env.development? 2 | GraphiQL::Rails.config.headers['Authorization'] = -> (_ctx) { 3 | "bearer #{ENV['JWT_TOKEN']}" 4 | } 5 | end 6 | -------------------------------------------------------------------------------- /app/graphql/types/authenticate_type.rb: -------------------------------------------------------------------------------- 1 | Types::AuthenticateType = GraphQL::ObjectType.define do 2 | name 'Authenticate' 3 | 4 | field :token, types.String 5 | field :user, Types::UserType 6 | end 7 | -------------------------------------------------------------------------------- /config/initializers/mime_types.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new mime types for use in respond_to blocks: 4 | # Mime::Type.register "text/richtext", :rtf 5 | -------------------------------------------------------------------------------- /app/graphql/types/auth_provider_signup_data.rb: -------------------------------------------------------------------------------- 1 | Types::AuthProviderSignupData = GraphQL::InputObjectType.define do 2 | name 'AuthProviderSignupData' 3 | 4 | argument :email, Types::AuthProviderEmailInput 5 | end 6 | -------------------------------------------------------------------------------- /config/cable.yml: -------------------------------------------------------------------------------- 1 | development: 2 | adapter: async 3 | 4 | test: 5 | adapter: async 6 | 7 | production: 8 | adapter: redis 9 | url: redis://localhost:6379/1 10 | channel_prefix: landbnb_production 11 | -------------------------------------------------------------------------------- /app/models/booking.rb: -------------------------------------------------------------------------------- 1 | class Booking < ApplicationRecord 2 | belongs_to :user 3 | belongs_to :rental 4 | has_one :review 5 | 6 | validates :user, :rental, :start_date, :stop_date, 7 | :guests, presence: true 8 | end 9 | -------------------------------------------------------------------------------- /config/routes.rb: -------------------------------------------------------------------------------- 1 | Rails.application.routes.draw do 2 | if Rails.env.development? 3 | mount GraphiQL::Rails::Engine, at: "/graphiql", graphql_path: "/graphql" 4 | end 5 | 6 | post "/graphql", to: "graphql#execute" 7 | end 8 | -------------------------------------------------------------------------------- /app/graphql/types/auth_provider_email_input.rb: -------------------------------------------------------------------------------- 1 | Types::AuthProviderEmailInput = GraphQL::InputObjectType.define do 2 | name 'AUTH_PROVIDER_EMAIL' 3 | 4 | argument :email, !types.String 5 | argument :password, !types.String 6 | end 7 | -------------------------------------------------------------------------------- /config/initializers/application_controller_renderer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # ApplicationController.renderer.defaults.merge!( 4 | # http_host: 'example.org', 5 | # https: false 6 | # ) 7 | -------------------------------------------------------------------------------- /config/initializers/optics_agent.rb: -------------------------------------------------------------------------------- 1 | if ENV['OPTICS_API_KEY'] 2 | optics_agent = OpticsAgent::Agent.new 3 | optics_agent.configure { schema LandbnbSchema } 4 | Rails.application.config.middleware.use optics_agent.rack_middleware 5 | end 6 | -------------------------------------------------------------------------------- /config/initializers/filter_parameter_logging.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Configure sensitive parameters which will be filtered from the log file. 4 | Rails.application.config.filter_parameters += [:password] 5 | -------------------------------------------------------------------------------- /Rakefile: -------------------------------------------------------------------------------- 1 | # Add your own tasks in files placed in lib/tasks ending in .rake, 2 | # for example lib/tasks/capistrano.rake, and they will automatically be available to Rake. 3 | 4 | require_relative 'config/application' 5 | 6 | Rails.application.load_tasks 7 | -------------------------------------------------------------------------------- /bin/rake: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | require_relative '../config/boot' 8 | require 'rake' 9 | Rake.application.run 10 | -------------------------------------------------------------------------------- /app/models/user.rb: -------------------------------------------------------------------------------- 1 | class User < ApplicationRecord 2 | has_secure_password 3 | 4 | has_many :rentals 5 | has_many :bookings 6 | has_many :rentals 7 | 8 | validates :name, :password_digest, presence: true 9 | validates :email, presence: true, uniqueness: true 10 | end 11 | -------------------------------------------------------------------------------- /app/graphql/types/mutation_type.rb: -------------------------------------------------------------------------------- 1 | Types::MutationType = GraphQL::ObjectType.define do 2 | name "Mutation" 3 | 4 | field :signInUser, function: Mutations::SignInUser.new 5 | field :createUser, function: Mutations::CreateUser.new 6 | field :bookRental, function: Mutations::BookRental.new 7 | end 8 | -------------------------------------------------------------------------------- /app/models/rental.rb: -------------------------------------------------------------------------------- 1 | class Rental < ApplicationRecord 2 | belongs_to :user 3 | has_many :bookings 4 | has_many :reviews 5 | 6 | validates :user, :rental_type, :accommodates, :bathrooms, 7 | :bedrooms, :beds, :nightly_cost, :street1, :city, 8 | :country, presence: true 9 | end 10 | -------------------------------------------------------------------------------- /config/initializers/cookies_serializer.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Specify a serializer for the signed and encrypted cookie jars. 4 | # Valid options are :json, :marshal, and :hybrid. 5 | Rails.application.config.action_dispatch.cookies_serializer = :json 6 | -------------------------------------------------------------------------------- /bin/rails: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | begin 3 | load File.expand_path('../spring', __FILE__) 4 | rescue LoadError => e 5 | raise unless e.message.include?('spring') 6 | end 7 | APP_PATH = File.expand_path('../config/application', __dir__) 8 | require_relative '../config/boot' 9 | require 'rails/commands' 10 | -------------------------------------------------------------------------------- /app/views/layouts/mailer.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 8 | 9 | 10 | 11 | <%= yield %> 12 | 13 | 14 | -------------------------------------------------------------------------------- /app/graphql/record_loader.rb: -------------------------------------------------------------------------------- 1 | class RecordLoader < GraphQL::Batch::Loader 2 | def initialize(model) 3 | @model = model 4 | end 5 | 6 | def perform(ids) 7 | @model.where(id: ids).each { |record| fulfill(record.id, record) } 8 | ids.each { |id| fulfill(id, nil) unless fulfilled?(id) } 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /bin/yarn: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | VENDOR_PATH = File.expand_path('..', __dir__) 3 | Dir.chdir(VENDOR_PATH) do 4 | begin 5 | exec "yarnpkg #{ARGV.join(" ")}" 6 | rescue Errno::ENOENT 7 | $stderr.puts "Yarn executable was not detected in the system." 8 | $stderr.puts "Download Yarn at https://yarnpkg.com/en/docs/install" 9 | exit 1 10 | end 11 | end 12 | -------------------------------------------------------------------------------- /app/graphql/types/query_type.rb: -------------------------------------------------------------------------------- 1 | Types::QueryType = GraphQL::ObjectType.define do 2 | name "Query" 3 | 4 | field :rentals, !types[Types::RentalType] do 5 | argument :limit, types.Int, default_value: 20, prepare: -> (limit, ctx) { [limit, 30].min } 6 | resolve -> (obj, args, ctx) { 7 | Rental.limit(args[:limit]).order(id: :desc) 8 | } 9 | end 10 | end 11 | -------------------------------------------------------------------------------- /db/migrate/20170807142900_create_users.rb: -------------------------------------------------------------------------------- 1 | class CreateUsers < ActiveRecord::Migration[5.1] 2 | def change 3 | create_table :users do |t| 4 | t.string :name, null: false 5 | t.string :email, null: false 6 | t.string :password_digest, null: false 7 | 8 | t.timestamps 9 | end 10 | 11 | add_index :users, :email, unique: true 12 | end 13 | end 14 | -------------------------------------------------------------------------------- /app/graphql/landbnb_schema.rb: -------------------------------------------------------------------------------- 1 | LandbnbSchema = GraphQL::Schema.define do 2 | max_depth 4 3 | use GraphQL::Batch 4 | enable_preloading 5 | 6 | mutation(Types::MutationType) 7 | query(Types::QueryType) 8 | end 9 | 10 | LandbnbSchema.middleware << 11 | GraphQL::Schema::TimeoutMiddleware.new(max_seconds: 2) do |err, query| 12 | Rails.logger.info("GraphQL Timeout: #{query.query_string}") 13 | end 14 | -------------------------------------------------------------------------------- /app/views/layouts/application.html.erb: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | Landbnb 5 | <%= csrf_meta_tags %> 6 | 7 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %> 8 | <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %> 9 | 10 | 11 | 12 | <%= yield %> 13 | 14 | 15 | -------------------------------------------------------------------------------- /app/assets/javascripts/cable.js: -------------------------------------------------------------------------------- 1 | // Action Cable provides the framework to deal with WebSockets in Rails. 2 | // You can generate new channels where WebSocket features live using the `rails generate channel` command. 3 | // 4 | //= require action_cable 5 | //= require_self 6 | //= require_tree ./channels 7 | 8 | (function() { 9 | this.App || (this.App = {}); 10 | 11 | App.cable = ActionCable.createConsumer(); 12 | 13 | }).call(this); 14 | -------------------------------------------------------------------------------- /app/models/auth_token.rb: -------------------------------------------------------------------------------- 1 | class AuthToken 2 | def self.key 3 | Rails.application.secrets.secret_key_base 4 | end 5 | 6 | def self.token(user) 7 | payload = {user_id: user.id} 8 | JsonWebToken.sign(payload, key: key) 9 | end 10 | 11 | def self.verify(token) 12 | result = JsonWebToken.verify(token, key: key) 13 | return nil if result[:error] 14 | User.find_by(id: result[:ok][:user_id]) 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /config/initializers/backtrace_silencers.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # You can add backtrace silencers for libraries that you're using but don't wish to see in your backtraces. 4 | # Rails.backtrace_cleaner.add_silencer { |line| line =~ /my_noisy_library/ } 5 | 6 | # You can also remove all the silencers if you're trying to debug a problem that might stem from framework code. 7 | # Rails.backtrace_cleaner.remove_silencers! 8 | -------------------------------------------------------------------------------- /app/graphql/types/user_type.rb: -------------------------------------------------------------------------------- 1 | Types::UserType = GraphQL::ObjectType.define do 2 | name 'User' 3 | 4 | field :id, !types.ID 5 | field :email, !types.String 6 | field :name, !types.String 7 | 8 | field :rentals, !types[Types::RentalType] do 9 | preload :rentals 10 | resolve -> (obj, args, ctx) { obj.rentals } 11 | end 12 | field :bookings, !types[Types::BookingType] do 13 | preload :bookings 14 | resolve -> (obj, args, ctx) { obj.bookings } 15 | end 16 | end 17 | -------------------------------------------------------------------------------- /app/graphql/mutations/sign_in_user.rb: -------------------------------------------------------------------------------- 1 | class Mutations::SignInUser < GraphQL::Function 2 | argument :email, !Types::AuthProviderEmailInput 3 | 4 | type Types::AuthenticateType 5 | 6 | def call(obj, args, ctx) 7 | input = args[:email] 8 | return unless input 9 | 10 | user = User.find_by(email: input[:email]) 11 | return unless user 12 | return unless user.authenticate(input[:password]) 13 | 14 | OpenStruct.new({ 15 | token: AuthToken.token(user), 16 | user: user 17 | }) 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # See https://help.github.com/articles/ignoring-files for more about ignoring files. 2 | # 3 | # If you find yourself ignoring temporary files generated by your text editor 4 | # or operating system, you probably want to add a global ignore instead: 5 | # git config --global core.excludesfile '~/.gitignore_global' 6 | 7 | # Ignore bundler config. 8 | /.bundle 9 | 10 | # Ignore all logfiles and tempfiles. 11 | /log/* 12 | /tmp/* 13 | !/log/.keep 14 | !/tmp/.keep 15 | 16 | /node_modules 17 | /yarn-error.log 18 | 19 | .byebug_history 20 | .env 21 | -------------------------------------------------------------------------------- /config/initializers/wrap_parameters.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # This file contains settings for ActionController::ParamsWrapper which 4 | # is enabled by default. 5 | 6 | # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. 7 | ActiveSupport.on_load(:action_controller) do 8 | wrap_parameters format: [:json] 9 | end 10 | 11 | # To enable root element in JSON for ActiveRecord objects. 12 | # ActiveSupport.on_load(:active_record) do 13 | # self.include_root_in_json = true 14 | # end 15 | -------------------------------------------------------------------------------- /bin/spring: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | 3 | # This file loads spring without using Bundler, in order to be fast. 4 | # It gets overwritten when you run the `spring binstub` command. 5 | 6 | unless defined?(Spring) 7 | require 'rubygems' 8 | require 'bundler' 9 | 10 | lockfile = Bundler::LockfileParser.new(Bundler.default_lockfile.read) 11 | spring = lockfile.specs.detect { |spec| spec.name == "spring" } 12 | if spring 13 | Gem.use_paths Gem.dir, Bundler.bundle_path.to_s, *Gem.path 14 | gem 'spring', spring.version 15 | require 'spring/binstub' 16 | end 17 | end 18 | -------------------------------------------------------------------------------- /app/graphql/types/booking_type.rb: -------------------------------------------------------------------------------- 1 | Types::BookingType = GraphQL::ObjectType.define do 2 | name 'Booking' 3 | 4 | field :id, !types.ID 5 | field :start_date, !types.String 6 | field :stop_date, !types.String 7 | field :review_score, types.Int 8 | field :review_comments, types.String 9 | field :reviewed_at, types.String 10 | 11 | field :rental, Types::RentalType do 12 | preload :rental 13 | resolve -> (obj, args, context) { obj.rental } 14 | end 15 | field :guest, Types::UserType do 16 | preload :user 17 | resolve -> (obj, args, context) { obj.user } 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /db/migrate/20170807143003_create_bookings.rb: -------------------------------------------------------------------------------- 1 | class CreateBookings < ActiveRecord::Migration[5.1] 2 | def change 3 | create_table :bookings do |t| 4 | t.integer :user_id, null: false 5 | t.integer :rental_id, null: false 6 | t.date :start_date, null: false 7 | t.date :stop_date, null: false 8 | t.integer :guests, null: false 9 | t.integer :review_score 10 | t.text :review_comments 11 | t.timestamp :reviewed_at 12 | 13 | t.timestamps 14 | end 15 | 16 | add_index :bookings, :user_id 17 | add_index :bookings, :rental_id 18 | end 19 | end 20 | -------------------------------------------------------------------------------- /app/graphql/mutations/create_user.rb: -------------------------------------------------------------------------------- 1 | class Mutations::CreateUser < GraphQL::Function 2 | argument :name, !types.String 3 | argument :authProvider, !Types::AuthProviderSignupData 4 | 5 | type Types::AuthenticateType 6 | 7 | def call(_obj, args, _ctx) 8 | user = User.create!( 9 | name: args[:name], 10 | email: args[:authProvider][:email][:email], 11 | password: args[:authProvider][:email][:password] 12 | ) 13 | 14 | OpenStruct.new({ 15 | token: AuthToken.token(user), 16 | user: user 17 | }) 18 | rescue ActiveRecord::RecordInvalid => e 19 | GraphQL::ExecutionError.new("Invalid input: #{e.record.errors.full_messages.join(', ')}") 20 | end 21 | end 22 | -------------------------------------------------------------------------------- /config/initializers/assets.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Version of your assets, change this if you want to expire all your assets. 4 | Rails.application.config.assets.version = '1.0' 5 | 6 | # Add additional assets to the asset load path. 7 | # Rails.application.config.assets.paths << Emoji.images_path 8 | # Add Yarn node_modules folder to the asset load path. 9 | Rails.application.config.assets.paths << Rails.root.join('node_modules') 10 | 11 | # Precompile additional assets. 12 | # application.js, application.css, and all non-JS/CSS in the app/assets 13 | # folder are already added. 14 | # Rails.application.config.assets.precompile += %w( admin.js admin.css ) 15 | -------------------------------------------------------------------------------- /config/initializers/inflections.rb: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Add new inflection rules using the following format. Inflections 4 | # are locale specific, and you may define rules for as many different 5 | # locales as you wish. All of these examples are active by default: 6 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 7 | # inflect.plural /^(ox)$/i, '\1en' 8 | # inflect.singular /^(ox)en/i, '\1' 9 | # inflect.irregular 'person', 'people' 10 | # inflect.uncountable %w( fish sheep ) 11 | # end 12 | 13 | # These inflection rules are supported but not enabled by default: 14 | # ActiveSupport::Inflector.inflections(:en) do |inflect| 15 | # inflect.acronym 'RESTful' 16 | # end 17 | -------------------------------------------------------------------------------- /app/assets/javascripts/application.js: -------------------------------------------------------------------------------- 1 | // This is a manifest file that'll be compiled into application.js, which will include all the files 2 | // listed below. 3 | // 4 | // Any JavaScript/Coffee file within this directory, lib/assets/javascripts, or any plugin's 5 | // vendor/assets/javascripts directory can be referenced here using a relative path. 6 | // 7 | // It's not advisable to add code directly here, but if you do, it'll appear at the bottom of the 8 | // compiled file. JavaScript code in this file should be added after the last require_* statement. 9 | // 10 | // Read Sprockets README (https://github.com/rails/sprockets#sprockets-directives) for details 11 | // about supported directives. 12 | // 13 | //= require rails-ujs 14 | //= require turbolinks 15 | //= require_tree . 16 | -------------------------------------------------------------------------------- /app/assets/stylesheets/application.css: -------------------------------------------------------------------------------- 1 | /* 2 | * This is a manifest file that'll be compiled into application.css, which will include all the files 3 | * listed below. 4 | * 5 | * Any CSS and SCSS file within this directory, lib/assets/stylesheets, or any plugin's 6 | * vendor/assets/stylesheets directory can be referenced here using a relative path. 7 | * 8 | * You're free to add application-wide styles to this file and they'll appear at the bottom of the 9 | * compiled file so the styles you add here take precedence over styles defined in any other CSS/SCSS 10 | * files in this directory. Styles in this file should be added after the last require_* statement. 11 | * It is generally better to create a new file per style scope. 12 | * 13 | *= require_tree . 14 | *= require_self 15 | */ 16 | -------------------------------------------------------------------------------- /bin/update: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a way to update your development environment automatically. 15 | # Add necessary update steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | puts "\n== Updating database ==" 22 | system! 'bin/rails db:migrate' 23 | 24 | puts "\n== Removing old logs and tempfiles ==" 25 | system! 'bin/rails log:clear tmp:clear' 26 | 27 | puts "\n== Restarting application server ==" 28 | system! 'bin/rails restart' 29 | end 30 | -------------------------------------------------------------------------------- /db/migrate/20170807142908_create_rentals.rb: -------------------------------------------------------------------------------- 1 | class CreateRentals < ActiveRecord::Migration[5.1] 2 | def change 3 | create_table :rentals do |t| 4 | t.integer :user_id, null: false 5 | t.string :rental_type, null: false 6 | t.integer :accommodates, null: false 7 | t.integer :bathrooms, null: false 8 | t.integer :bedrooms, null: false 9 | t.integer :beds, null: false 10 | t.decimal :nightly_cost, null: false, precision: 8, scale: 2 11 | t.text :description 12 | t.decimal :latitude, precision: 10, scale: 6 13 | t.decimal :longitude, precision: 10, scale: 6 14 | t.string :street1, null: false 15 | t.string :street2 16 | t.string :city, null: false 17 | t.string :province 18 | t.string :country, null: false 19 | t.string :postal_code 20 | 21 | t.timestamps 22 | end 23 | 24 | add_index :rentals, :user_id 25 | end 26 | end 27 | -------------------------------------------------------------------------------- /app/graphql/types/rental_type.rb: -------------------------------------------------------------------------------- 1 | Types::RentalType = GraphQL::ObjectType.define do 2 | name 'Rental' 3 | 4 | field :id, !types.ID 5 | field :rental_type, !types.String 6 | field :accommodates, !types.Int 7 | field :bathrooms, !types.Int 8 | field :bedrooms, !types.Int 9 | field :beds, !types.Int 10 | field :nightly_cost, !types.Float 11 | field :description, types.String 12 | field :latitude, types.Float 13 | field :longitude, types.Float 14 | field :street1, !types.String 15 | field :street2, types.String 16 | field :city, !types.String 17 | field :province, types.String 18 | field :country, !types.String 19 | field :postal_code, types.String 20 | 21 | field :owner, Types::UserType do 22 | resolve -> (obj, args, context) { RecordLoader.for(User).load(obj.user_id) } 23 | end 24 | field :bookings, !types[Types::BookingType] do 25 | preload :bookings 26 | resolve -> (obj, args, ctx) { obj.bookings } 27 | end 28 | end 29 | -------------------------------------------------------------------------------- /app/graphql/mutations/book_rental.rb: -------------------------------------------------------------------------------- 1 | class Mutations::BookRental < GraphQL::Function 2 | argument :rental_id, !types.Int 3 | argument :start_date, !types.String 4 | argument :stop_date, !types.String 5 | argument :guests, !types.Int 6 | 7 | type Types::BookingType 8 | 9 | def call(_obj, args, ctx) 10 | if ctx[:current_user].blank? 11 | raise GraphQL::ExecutionError.new("Authentication required") 12 | end 13 | 14 | rental = Rental.find(args[:rental_id]) 15 | 16 | booking = rental.bookings.create!( 17 | user: ctx[:current_user], 18 | start_date: args[:start_date], 19 | stop_date: args[:stop_date], 20 | guests: args[:guests] 21 | ) 22 | 23 | booking 24 | rescue ActiveRecord::RecordNotFound => e 25 | GraphQL::ExecutionError.new("No Rental with ID #{args[:rental_id]} found.") 26 | rescue ActiveRecord::RecordInvalid => e 27 | GraphQL::ExecutionError.new("Invalid input: #{e.record.errors.full_messages.join(', ')}") 28 | end 29 | end 30 | -------------------------------------------------------------------------------- /config/locales/en.yml: -------------------------------------------------------------------------------- 1 | # Files in the config/locales directory are used for internationalization 2 | # and are automatically loaded by Rails. If you want to use locales other 3 | # than English, add the necessary files in this directory. 4 | # 5 | # To use the locales, use `I18n.t`: 6 | # 7 | # I18n.t 'hello' 8 | # 9 | # In views, this is aliased to just `t`: 10 | # 11 | # <%= t('hello') %> 12 | # 13 | # To use a different locale, set it with `I18n.locale`: 14 | # 15 | # I18n.locale = :es 16 | # 17 | # This would use the information in config/locales/es.yml. 18 | # 19 | # The following keys must be escaped otherwise they will not be retrieved by 20 | # the default I18n backend: 21 | # 22 | # true, false, on, off, yes, no 23 | # 24 | # Instead, surround them with single quotes. 25 | # 26 | # en: 27 | # 'true': 'foo' 28 | # 29 | # To learn more, please read the Rails Internationalization guide 30 | # available at http://guides.rubyonrails.org/i18n.html. 31 | 32 | en: 33 | hello: "Hello world" 34 | -------------------------------------------------------------------------------- /config/application.rb: -------------------------------------------------------------------------------- 1 | require_relative 'boot' 2 | 3 | require "rails" 4 | # Pick the frameworks you want: 5 | require "active_model/railtie" 6 | require "active_job/railtie" 7 | require "active_record/railtie" 8 | require "action_controller/railtie" 9 | require "action_mailer/railtie" 10 | require "action_view/railtie" 11 | require "action_cable/engine" 12 | require "sprockets/railtie" 13 | # require "rails/test_unit/railtie" 14 | 15 | # Require the gems listed in Gemfile, including any gems 16 | # you've limited to :test, :development, or :production. 17 | Bundler.require(*Rails.groups) 18 | 19 | module Landbnb 20 | class Application < Rails::Application 21 | # Initialize configuration defaults for originally generated Rails version. 22 | config.load_defaults 5.1 23 | 24 | # Settings in config/environments/* take precedence over those specified here. 25 | # Application configuration should go into files in config/initializers 26 | # -- all .rb files in that directory are automatically loaded. 27 | 28 | # Don't generate system test files. 29 | config.generators.system_tests = nil 30 | end 31 | end 32 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # Landbnb 2 | 3 | This is an example Rails application which implements a GraphQL API. 4 | 5 | ## Installation 6 | 7 | After cloning the repository, run the following commands: 8 | - `bundle install` 9 | - `bundle exec rails db:create` 10 | - `bundle exec rails db:migrate` 11 | - `bundle exec rake db:seed` 12 | 13 | The last command will provide you with some sample data to play around with. 14 | 15 | You also need to create a `.env` file in the root of the project that contains a `JWT_TOKEN` entry for your user. 16 | - Create a `.env` file in the root of the project. 17 | - `rails console` 18 | - `AuthToken.token(User.last)` 19 | - Use the token that is output and create a `JWT_TOKEN` entry in the `.env` file. 20 | 21 | ## Development 22 | 23 | Start the Rails app with `rails server` and you can visit http://localhost:3000/graphiql to explore the API locally. 24 | 25 | ## Requests requiring authentication 26 | 27 | Both the `createUser` and `signInUser` mutations return a `token` field. This is a JWT token which should be submitted in all subsequent requests in the format: 28 | 29 | `Authentication: bearer TOKEN_HERE` 30 | -------------------------------------------------------------------------------- /bin/setup: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env ruby 2 | require 'pathname' 3 | require 'fileutils' 4 | include FileUtils 5 | 6 | # path to your application root. 7 | APP_ROOT = Pathname.new File.expand_path('../../', __FILE__) 8 | 9 | def system!(*args) 10 | system(*args) || abort("\n== Command #{args} failed ==") 11 | end 12 | 13 | chdir APP_ROOT do 14 | # This script is a starting point to setup your application. 15 | # Add necessary setup steps to this file. 16 | 17 | puts '== Installing dependencies ==' 18 | system! 'gem install bundler --conservative' 19 | system('bundle check') || system!('bundle install') 20 | 21 | # Install JavaScript dependencies if using Yarn 22 | # system('bin/yarn') 23 | 24 | 25 | # puts "\n== Copying sample files ==" 26 | # unless File.exist?('config/database.yml') 27 | # cp 'config/database.yml.sample', 'config/database.yml' 28 | # end 29 | 30 | puts "\n== Preparing database ==" 31 | system! 'bin/rails db:setup' 32 | 33 | puts "\n== Removing old logs and tempfiles ==" 34 | system! 'bin/rails log:clear tmp:clear' 35 | 36 | puts "\n== Restarting application server ==" 37 | system! 'bin/rails restart' 38 | end 39 | -------------------------------------------------------------------------------- /spec/graphql/mutations/sign_in_user_spec.rb: -------------------------------------------------------------------------------- 1 | require 'rails_helper' 2 | 3 | describe Mutations::SignInUser do 4 | def perform(args = {}) 5 | described_class.new.call(nil, args, {current_user: nil}) 6 | end 7 | 8 | let!(:user) { 9 | User.create!(name: 'Test User', email: 'test@email.com', password: 'secret') 10 | } 11 | 12 | describe 'authenticates user' do 13 | it 'creates token when valid' do 14 | result = perform( 15 | email: { 16 | email: user.email, 17 | password: user.password 18 | } 19 | ) 20 | 21 | expect(result.token).to be_present 22 | expect(result.user).to eq(user) 23 | end 24 | 25 | it 'is nil when invalid email' do 26 | result = perform( 27 | email: { 28 | email: 'invalid@email.com', 29 | password: user.password 30 | } 31 | ) 32 | 33 | expect(result).to be_nil 34 | end 35 | 36 | it 'is nil when invalid password' do 37 | result = perform( 38 | email: { 39 | email: user.email, 40 | password: 'invalid' 41 | } 42 | ) 43 | 44 | expect(result).to be_nil 45 | end 46 | end 47 | end 48 | -------------------------------------------------------------------------------- /config/secrets.yml: -------------------------------------------------------------------------------- 1 | # Be sure to restart your server when you modify this file. 2 | 3 | # Your secret key is used for verifying the integrity of signed cookies. 4 | # If you change this key, all old signed cookies will become invalid! 5 | 6 | # Make sure the secret is at least 30 characters and all random, 7 | # no regular words or you'll be exposed to dictionary attacks. 8 | # You can use `rails secret` to generate a secure secret key. 9 | 10 | # Make sure the secrets in this file are kept private 11 | # if you're sharing your code publicly. 12 | 13 | # Shared secrets are available across all environments. 14 | 15 | # shared: 16 | # api_key: a1B2c3D4e5F6 17 | 18 | # Environmental secrets are only available for that specific environment. 19 | 20 | development: 21 | secret_key_base: 9f2acf73dafdb980fe37e404f6d147a5c3e1410bae6cf7d533070c5c700f6b1d245f90427fecf77922dc0855f5cb2b1619e9e00a07fb09401c24a63a120e7291 22 | 23 | test: 24 | secret_key_base: ab98be04b04cbf3138517c9290ed092e10ef536630a97ebb758d5bcbf9a066303e8b4f2cca404f6edbaa2ff206ac68d7f47915b21349522fad3669d34ff8a869 25 | 26 | # Do not keep production secrets in the unencrypted secrets file. 27 | # Instead, either read values from the environment. 28 | # Or, use `bin/rails secrets:setup` to configure encrypted secrets 29 | # and move the `production:` environment over there. 30 | 31 | production: 32 | secret_key_base: <%= ENV["SECRET_KEY_BASE"] %> 33 | -------------------------------------------------------------------------------- /app/controllers/graphql_controller.rb: -------------------------------------------------------------------------------- 1 | class GraphqlController < ApplicationController 2 | skip_before_action :verify_authenticity_token 3 | 4 | def execute 5 | variables = ensure_hash(params[:variables]) 6 | query = params[:query] 7 | operation_name = params[:operationName] 8 | context = { 9 | current_user: current_user 10 | } 11 | if ENV['OPTICS_API_KEY'] 12 | context.merge!( 13 | optics_agent: request.env[:optics_agent].with_document(query) 14 | ) 15 | end 16 | result = LandbnbSchema.execute(query, variables: variables, context: context, operation_name: operation_name) 17 | render json: result 18 | end 19 | 20 | private 21 | 22 | def current_user 23 | return nil if request.headers['Authorization'].blank? 24 | token = request.headers['Authorization'].split(' ').last 25 | return nil if token.blank? 26 | AuthToken.verify(token) 27 | end 28 | 29 | # Handle form data, JSON body, or a blank value 30 | def ensure_hash(ambiguous_param) 31 | case ambiguous_param 32 | when String 33 | if ambiguous_param.present? 34 | ensure_hash(JSON.parse(ambiguous_param)) 35 | else 36 | {} 37 | end 38 | when Hash, ActionController::Parameters 39 | ambiguous_param 40 | when nil 41 | {} 42 | else 43 | raise ArgumentError, "Unexpected parameter: #{ambiguous_param}" 44 | end 45 | end 46 | end 47 | -------------------------------------------------------------------------------- /public/500.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | We're sorry, but something went wrong (500) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

We're sorry, but something went wrong.

62 |
63 |

If you are the application owner check the logs for more information.

64 |
65 | 66 | 67 | -------------------------------------------------------------------------------- /config/environments/test.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # The test environment is used exclusively to run your application's 5 | # test suite. You never need to work with it otherwise. Remember that 6 | # your test database is "scratch space" for the test suite and is wiped 7 | # and recreated between test runs. Don't rely on the data there! 8 | config.cache_classes = true 9 | 10 | # Do not eager load code on boot. This avoids loading your whole application 11 | # just for the purpose of running a single test. If you are using a tool that 12 | # preloads Rails for running tests, you may have to set it to true. 13 | config.eager_load = false 14 | 15 | # Configure public file server for tests with Cache-Control for performance. 16 | config.public_file_server.enabled = true 17 | config.public_file_server.headers = { 18 | 'Cache-Control' => "public, max-age=#{1.hour.seconds.to_i}" 19 | } 20 | 21 | # Show full error reports and disable caching. 22 | config.consider_all_requests_local = true 23 | config.action_controller.perform_caching = false 24 | 25 | # Raise exceptions instead of rendering exception templates. 26 | config.action_dispatch.show_exceptions = false 27 | 28 | # Disable request forgery protection in test environment. 29 | config.action_controller.allow_forgery_protection = false 30 | config.action_mailer.perform_caching = false 31 | 32 | # Tell Action Mailer not to deliver emails to the real world. 33 | # The :test delivery method accumulates sent emails in the 34 | # ActionMailer::Base.deliveries array. 35 | config.action_mailer.delivery_method = :test 36 | 37 | # Print deprecation notices to the stderr. 38 | config.active_support.deprecation = :stderr 39 | 40 | # Raises error for missing translations 41 | # config.action_view.raise_on_missing_translations = true 42 | end 43 | -------------------------------------------------------------------------------- /db/seeds.rb: -------------------------------------------------------------------------------- 1 | # run with `bundle exec rails db:seed` 2 | 3 | # clear out existing data 4 | [User, Rental, Booking].each do |model| 5 | model.delete_all 6 | end 7 | 8 | # create some owners 9 | owners = Array(1..15).map do |n| 10 | User.create!( 11 | name: Faker::Name.name, 12 | email: "owner-#{n}@email.com", 13 | password: 'secret' 14 | ) 15 | end 16 | 17 | # create some renters 18 | renters = Array(1..15).map do |n| 19 | User.create!( 20 | name: Faker::Name.name, 21 | email: "renter-#{n}@email.com", 22 | password: 'secret' 23 | ) 24 | end 25 | 26 | # create some rental units + bookings 27 | Array(1..100).each do |n| 28 | rental = Rental.create!( 29 | user: owners.sample, 30 | rental_type: ['house', 'apartment'].sample, 31 | bathrooms: [1,2,3].sample, 32 | bedrooms: [1,2,3].sample, 33 | beds: [1,2,3].sample, 34 | accommodates: [1,2,3,4,5].sample, 35 | nightly_cost: [55.75, 100.25, 113].sample, 36 | description: "Very #{['scenic', 'beautiful','ugly'].sample} view.", 37 | latitude: Faker::Address.latitude, 38 | longitude: Faker::Address.longitude, 39 | street1: Faker::Address.street_address, 40 | city: Faker::Address.city, 41 | province: Faker::Address.state_abbr, 42 | country: Faker::Address.country_code, 43 | postal_code: Faker::Address.postcode 44 | ) 45 | 46 | num_bookings = Array(1..10).sample 47 | 48 | Array(1..num_bookings).each do |n| 49 | booking = Booking.create!( 50 | user: renters.sample, 51 | rental: rental, 52 | guests: [1,2,3].sample, 53 | start_date: n.days.from_now.to_date, 54 | stop_date: (n + 3).days.from_now.to_date 55 | ) 56 | 57 | if [true, false].sample 58 | booking.review_score = [1,2,3,4].sample 59 | booking.review_comments = "I chose a score of #{booking.review_score}" 60 | booking.reviewed_at = booking.stop_date.end_of_day 61 | booking.save! 62 | end 63 | end 64 | end 65 | -------------------------------------------------------------------------------- /public/422.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The change you wanted was rejected (422) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The change you wanted was rejected.

62 |

Maybe you tried to change something you didn't have access to.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /public/404.html: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | The page you were looking for doesn't exist (404) 5 | 6 | 55 | 56 | 57 | 58 | 59 |
60 |
61 |

The page you were looking for doesn't exist.

62 |

You may have mistyped the address or the page may have moved.

63 |
64 |

If you are the application owner check the logs for more information.

65 |
66 | 67 | 68 | -------------------------------------------------------------------------------- /config/environments/development.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # In the development environment your application's code is reloaded on 5 | # every request. This slows down response time but is perfect for development 6 | # since you don't have to restart the web server when you make code changes. 7 | config.cache_classes = false 8 | 9 | # Do not eager load code on boot. 10 | config.eager_load = false 11 | 12 | # Show full error reports. 13 | config.consider_all_requests_local = true 14 | 15 | # Enable/disable caching. By default caching is disabled. 16 | if Rails.root.join('tmp/caching-dev.txt').exist? 17 | config.action_controller.perform_caching = true 18 | 19 | config.cache_store = :memory_store 20 | config.public_file_server.headers = { 21 | 'Cache-Control' => "public, max-age=#{2.days.seconds.to_i}" 22 | } 23 | else 24 | config.action_controller.perform_caching = false 25 | 26 | config.cache_store = :null_store 27 | end 28 | 29 | # Don't care if the mailer can't send. 30 | config.action_mailer.raise_delivery_errors = false 31 | 32 | config.action_mailer.perform_caching = false 33 | 34 | # Print deprecation notices to the Rails logger. 35 | config.active_support.deprecation = :log 36 | 37 | # Raise an error on page load if there are pending migrations. 38 | config.active_record.migration_error = :page_load 39 | 40 | # Debug mode disables concatenation and preprocessing of assets. 41 | # This option may cause significant delays in view rendering with a large 42 | # number of complex assets. 43 | config.assets.debug = true 44 | 45 | # Suppress logger output for asset requests. 46 | config.assets.quiet = true 47 | 48 | # Raises error for missing translations 49 | # config.action_view.raise_on_missing_translations = true 50 | 51 | # Use an evented file watcher to asynchronously detect changes in source code, 52 | # routes, locales, etc. This feature depends on the listen gem. 53 | config.file_watcher = ActiveSupport::EventedFileUpdateChecker 54 | end 55 | -------------------------------------------------------------------------------- /Gemfile: -------------------------------------------------------------------------------- 1 | source 'https://rubygems.org' 2 | 3 | git_source(:github) do |repo_name| 4 | repo_name = "#{repo_name}/#{repo_name}" unless repo_name.include?("/") 5 | "https://github.com/#{repo_name}.git" 6 | end 7 | 8 | 9 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails' 10 | gem 'rails', '~> 5.1.3' 11 | # Use postgresql as the database for Active Record 12 | gem 'pg', '~> 0.18' 13 | # Use Puma as the app server 14 | gem 'puma', '~> 3.7' 15 | # Use SCSS for stylesheets 16 | gem 'sass-rails', '~> 5.0' 17 | # Use Uglifier as compressor for JavaScript assets 18 | gem 'uglifier', '>= 1.3.0' 19 | # See https://github.com/rails/execjs#readme for more supported runtimes 20 | # gem 'therubyracer', platforms: :ruby 21 | 22 | # Use CoffeeScript for .coffee assets and views 23 | gem 'coffee-rails', '~> 4.2' 24 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks 25 | gem 'turbolinks', '~> 5' 26 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder 27 | gem 'jbuilder', '~> 2.5' 28 | # Use Redis adapter to run Action Cable in production 29 | # gem 'redis', '~> 3.0' 30 | # Use ActiveModel has_secure_password 31 | # gem 'bcrypt', '~> 3.1.7' 32 | 33 | # Use Capistrano for deployment 34 | # gem 'capistrano-rails', group: :development 35 | 36 | gem 'graphql', '~> 1.6', '>= 1.6.6' 37 | gem 'graphql-batch', '~> 0.3.3' 38 | gem 'graphql-preload', '~> 1.0', '>= 1.0.3' 39 | gem 'optics-agent' 40 | 41 | gem 'bcrypt', '~> 3.1', '>= 3.1.11' 42 | gem 'json_web_token', '~> 0.3.5' 43 | 44 | group :development, :test do 45 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console 46 | gem 'byebug', platforms: [:mri, :mingw, :x64_mingw] 47 | gem 'rspec-rails', '~> 3.6' 48 | gem 'faker', '~> 1.8', '>= 1.8.4' 49 | end 50 | 51 | group :development do 52 | # Access an IRB console on exception pages or by using <%= console %> anywhere in the code. 53 | gem 'web-console', '>= 3.3.0' 54 | gem 'listen', '>= 3.0.5', '< 3.2' 55 | # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring 56 | gem 'spring' 57 | gem 'spring-watcher-listen', '~> 2.0.0' 58 | gem 'dotenv-rails', '~> 2.2', '>= 2.2.1' 59 | end 60 | 61 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem 62 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby] 63 | 64 | gem 'graphiql-rails', group: :development 65 | -------------------------------------------------------------------------------- /config/puma.rb: -------------------------------------------------------------------------------- 1 | # Puma can serve each request in a thread from an internal thread pool. 2 | # The `threads` method setting takes two numbers: a minimum and maximum. 3 | # Any libraries that use thread pools should be configured to match 4 | # the maximum value specified for Puma. Default is set to 5 threads for minimum 5 | # and maximum; this matches the default thread size of Active Record. 6 | # 7 | threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 } 8 | threads threads_count, threads_count 9 | 10 | # Specifies the `port` that Puma will listen on to receive requests; default is 3000. 11 | # 12 | port ENV.fetch("PORT") { 3000 } 13 | 14 | # Specifies the `environment` that Puma will run in. 15 | # 16 | environment ENV.fetch("RAILS_ENV") { "development" } 17 | 18 | # Specifies the number of `workers` to boot in clustered mode. 19 | # Workers are forked webserver processes. If using threads and workers together 20 | # the concurrency of the application would be max `threads` * `workers`. 21 | # Workers do not work on JRuby or Windows (both of which do not support 22 | # processes). 23 | # 24 | # workers ENV.fetch("WEB_CONCURRENCY") { 2 } 25 | 26 | # Use the `preload_app!` method when specifying a `workers` number. 27 | # This directive tells Puma to first boot the application and load code 28 | # before forking the application. This takes advantage of Copy On Write 29 | # process behavior so workers use less memory. If you use this option 30 | # you need to make sure to reconnect any threads in the `on_worker_boot` 31 | # block. 32 | # 33 | # preload_app! 34 | 35 | # If you are preloading your application and using Active Record, it's 36 | # recommended that you close any connections to the database before workers 37 | # are forked to prevent connection leakage. 38 | # 39 | # before_fork do 40 | # ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord) 41 | # end 42 | 43 | # The code in the `on_worker_boot` will be called if you are using 44 | # clustered mode by specifying a number of `workers`. After each worker 45 | # process is booted, this block will be run. If you are using the `preload_app!` 46 | # option, you will want to use this block to reconnect to any threads 47 | # or connections that may have been created at application boot, as Ruby 48 | # cannot share connections between processes. 49 | # 50 | # on_worker_boot do 51 | # ActiveRecord::Base.establish_connection if defined?(ActiveRecord) 52 | # end 53 | # 54 | 55 | # Allow puma to be restarted by `rails restart` command. 56 | plugin :tmp_restart 57 | -------------------------------------------------------------------------------- /db/schema.rb: -------------------------------------------------------------------------------- 1 | # This file is auto-generated from the current state of the database. Instead 2 | # of editing this file, please use the migrations feature of Active Record to 3 | # incrementally modify your database, and then regenerate this schema definition. 4 | # 5 | # Note that this schema.rb definition is the authoritative source for your 6 | # database schema. If you need to create the application database on another 7 | # system, you should be using db:schema:load, not running all the migrations 8 | # from scratch. The latter is a flawed and unsustainable approach (the more migrations 9 | # you'll amass, the slower it'll run and the greater likelihood for issues). 10 | # 11 | # It's strongly recommended that you check this file into your version control system. 12 | 13 | ActiveRecord::Schema.define(version: 20170807143003) do 14 | 15 | # These are extensions that must be enabled in order to support this database 16 | enable_extension "plpgsql" 17 | 18 | create_table "bookings", force: :cascade do |t| 19 | t.integer "user_id", null: false 20 | t.integer "rental_id", null: false 21 | t.date "start_date", null: false 22 | t.date "stop_date", null: false 23 | t.integer "guests", null: false 24 | t.integer "review_score" 25 | t.text "review_comments" 26 | t.datetime "reviewed_at" 27 | t.datetime "created_at", null: false 28 | t.datetime "updated_at", null: false 29 | t.index ["rental_id"], name: "index_bookings_on_rental_id" 30 | t.index ["user_id"], name: "index_bookings_on_user_id" 31 | end 32 | 33 | create_table "rentals", force: :cascade do |t| 34 | t.integer "user_id", null: false 35 | t.string "rental_type", null: false 36 | t.integer "accommodates", null: false 37 | t.integer "bathrooms", null: false 38 | t.integer "bedrooms", null: false 39 | t.integer "beds", null: false 40 | t.decimal "nightly_cost", precision: 8, scale: 2, null: false 41 | t.text "description" 42 | t.decimal "latitude", precision: 10, scale: 6 43 | t.decimal "longitude", precision: 10, scale: 6 44 | t.string "street1", null: false 45 | t.string "street2" 46 | t.string "city", null: false 47 | t.string "province" 48 | t.string "country", null: false 49 | t.string "postal_code" 50 | t.datetime "created_at", null: false 51 | t.datetime "updated_at", null: false 52 | t.index ["user_id"], name: "index_rentals_on_user_id" 53 | end 54 | 55 | create_table "users", force: :cascade do |t| 56 | t.string "name", null: false 57 | t.string "email", null: false 58 | t.string "password_digest", null: false 59 | t.datetime "created_at", null: false 60 | t.datetime "updated_at", null: false 61 | t.index ["email"], name: "index_users_on_email", unique: true 62 | end 63 | 64 | end 65 | -------------------------------------------------------------------------------- /spec/rails_helper.rb: -------------------------------------------------------------------------------- 1 | # This file is copied to spec/ when you run 'rails generate rspec:install' 2 | require 'spec_helper' 3 | ENV['RAILS_ENV'] ||= 'test' 4 | require File.expand_path('../../config/environment', __FILE__) 5 | # Prevent database truncation if the environment is production 6 | abort("The Rails environment is running in production mode!") if Rails.env.production? 7 | require 'rspec/rails' 8 | # Add additional requires below this line. Rails is not loaded until this point! 9 | 10 | # Requires supporting ruby files with custom matchers and macros, etc, in 11 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are 12 | # run as spec files by default. This means that files in spec/support that end 13 | # in _spec.rb will both be required and run as specs, causing the specs to be 14 | # run twice. It is recommended that you do not name files matching this glob to 15 | # end with _spec.rb. You can configure this pattern with the --pattern 16 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`. 17 | # 18 | # The following line is provided for convenience purposes. It has the downside 19 | # of increasing the boot-up time by auto-requiring all files in the support 20 | # directory. Alternatively, in the individual `*_spec.rb` files, manually 21 | # require only the support files necessary. 22 | # 23 | # Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f } 24 | 25 | # Checks for pending migration and applies them before tests are run. 26 | # If you are not using ActiveRecord, you can remove this line. 27 | ActiveRecord::Migration.maintain_test_schema! 28 | 29 | RSpec.configure do |config| 30 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures 31 | config.fixture_path = "#{::Rails.root}/spec/fixtures" 32 | 33 | # If you're not using ActiveRecord, or you'd prefer not to run each of your 34 | # examples within a transaction, remove the following line or assign false 35 | # instead of true. 36 | config.use_transactional_fixtures = true 37 | 38 | # RSpec Rails can automatically mix in different behaviours to your tests 39 | # based on their file location, for example enabling you to call `get` and 40 | # `post` in specs under `spec/controllers`. 41 | # 42 | # You can disable this behaviour by removing the line below, and instead 43 | # explicitly tag your specs with their type, e.g.: 44 | # 45 | # RSpec.describe UsersController, :type => :controller do 46 | # # ... 47 | # end 48 | # 49 | # The different available types are documented in the features, such as in 50 | # https://relishapp.com/rspec/rspec-rails/docs 51 | config.infer_spec_type_from_file_location! 52 | 53 | # Filter lines from Rails gems in backtraces. 54 | config.filter_rails_from_backtrace! 55 | # arbitrary gems may also be filtered via: 56 | # config.filter_gems_from_backtrace("gem name") 57 | end 58 | -------------------------------------------------------------------------------- /config/database.yml: -------------------------------------------------------------------------------- 1 | # PostgreSQL. Versions 9.1 and up are supported. 2 | # 3 | # Install the pg driver: 4 | # gem install pg 5 | # On OS X with Homebrew: 6 | # gem install pg -- --with-pg-config=/usr/local/bin/pg_config 7 | # On OS X with MacPorts: 8 | # gem install pg -- --with-pg-config=/opt/local/lib/postgresql84/bin/pg_config 9 | # On Windows: 10 | # gem install pg 11 | # Choose the win32 build. 12 | # Install PostgreSQL and put its /bin directory on your path. 13 | # 14 | # Configure Using Gemfile 15 | # gem 'pg' 16 | # 17 | default: &default 18 | adapter: postgresql 19 | encoding: unicode 20 | # For details on connection pooling, see Rails configuration guide 21 | # http://guides.rubyonrails.org/configuring.html#database-pooling 22 | pool: <%= ENV.fetch("RAILS_MAX_THREADS") { 5 } %> 23 | 24 | development: 25 | <<: *default 26 | database: landbnb_development 27 | 28 | # The specified database role being used to connect to postgres. 29 | # To create additional roles in postgres see `$ createuser --help`. 30 | # When left blank, postgres will use the default role. This is 31 | # the same name as the operating system user that initialized the database. 32 | #username: landbnb 33 | 34 | # The password associated with the postgres role (username). 35 | #password: 36 | 37 | # Connect on a TCP socket. Omitted by default since the client uses a 38 | # domain socket that doesn't need configuration. Windows does not have 39 | # domain sockets, so uncomment these lines. 40 | #host: localhost 41 | 42 | # The TCP port the server listens on. Defaults to 5432. 43 | # If your server runs on a different port number, change accordingly. 44 | #port: 5432 45 | 46 | # Schema search path. The server defaults to $user,public 47 | #schema_search_path: myapp,sharedapp,public 48 | 49 | # Minimum log levels, in increasing order: 50 | # debug5, debug4, debug3, debug2, debug1, 51 | # log, notice, warning, error, fatal, and panic 52 | # Defaults to warning. 53 | #min_messages: notice 54 | 55 | # Warning: The database defined as "test" will be erased and 56 | # re-generated from your development database when you run "rake". 57 | # Do not set this db to the same as development or production. 58 | test: 59 | <<: *default 60 | database: landbnb_test 61 | 62 | # As with config/secrets.yml, you never want to store sensitive information, 63 | # like your database password, in your source code. If your source code is 64 | # ever seen by anyone, they now have access to your database. 65 | # 66 | # Instead, provide the password as a unix environment variable when you boot 67 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database 68 | # for a full rundown on how to provide these environment variables in a 69 | # production deployment. 70 | # 71 | # On Heroku and other platform providers, you may have a full connection URL 72 | # available as an environment variable. For example: 73 | # 74 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase" 75 | # 76 | # You can use this database configuration with: 77 | # 78 | # production: 79 | # url: <%= ENV['DATABASE_URL'] %> 80 | # 81 | production: 82 | <<: *default 83 | database: landbnb_production 84 | username: landbnb 85 | password: <%= ENV['LANDBNB_DATABASE_PASSWORD'] %> 86 | -------------------------------------------------------------------------------- /config/environments/production.rb: -------------------------------------------------------------------------------- 1 | Rails.application.configure do 2 | # Settings specified here will take precedence over those in config/application.rb. 3 | 4 | # Code is not reloaded between requests. 5 | config.cache_classes = true 6 | 7 | # Eager load code on boot. This eager loads most of Rails and 8 | # your application in memory, allowing both threaded web servers 9 | # and those relying on copy on write to perform better. 10 | # Rake tasks automatically ignore this option for performance. 11 | config.eager_load = true 12 | 13 | # Full error reports are disabled and caching is turned on. 14 | config.consider_all_requests_local = false 15 | config.action_controller.perform_caching = true 16 | 17 | # Attempt to read encrypted secrets from `config/secrets.yml.enc`. 18 | # Requires an encryption key in `ENV["RAILS_MASTER_KEY"]` or 19 | # `config/secrets.yml.key`. 20 | config.read_encrypted_secrets = true 21 | 22 | # Disable serving static files from the `/public` folder by default since 23 | # Apache or NGINX already handles this. 24 | config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present? 25 | 26 | # Compress JavaScripts and CSS. 27 | config.assets.js_compressor = :uglifier 28 | # config.assets.css_compressor = :sass 29 | 30 | # Do not fallback to assets pipeline if a precompiled asset is missed. 31 | config.assets.compile = false 32 | 33 | # `config.assets.precompile` and `config.assets.version` have moved to config/initializers/assets.rb 34 | 35 | # Enable serving of images, stylesheets, and JavaScripts from an asset server. 36 | # config.action_controller.asset_host = 'http://assets.example.com' 37 | 38 | # Specifies the header that your server uses for sending files. 39 | # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache 40 | # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX 41 | 42 | # Mount Action Cable outside main process or domain 43 | # config.action_cable.mount_path = nil 44 | # config.action_cable.url = 'wss://example.com/cable' 45 | # config.action_cable.allowed_request_origins = [ 'http://example.com', /http:\/\/example.*/ ] 46 | 47 | # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies. 48 | # config.force_ssl = true 49 | 50 | # Use the lowest log level to ensure availability of diagnostic information 51 | # when problems arise. 52 | config.log_level = :debug 53 | 54 | # Prepend all log lines with the following tags. 55 | config.log_tags = [ :request_id ] 56 | 57 | # Use a different cache store in production. 58 | # config.cache_store = :mem_cache_store 59 | 60 | # Use a real queuing backend for Active Job (and separate queues per environment) 61 | # config.active_job.queue_adapter = :resque 62 | # config.active_job.queue_name_prefix = "landbnb_#{Rails.env}" 63 | config.action_mailer.perform_caching = false 64 | 65 | # Ignore bad email addresses and do not raise email delivery errors. 66 | # Set this to true and configure the email server for immediate delivery to raise delivery errors. 67 | # config.action_mailer.raise_delivery_errors = false 68 | 69 | # Enable locale fallbacks for I18n (makes lookups for any locale fall back to 70 | # the I18n.default_locale when a translation cannot be found). 71 | config.i18n.fallbacks = true 72 | 73 | # Send deprecation notices to registered listeners. 74 | config.active_support.deprecation = :notify 75 | 76 | # Use default logging formatter so that PID and timestamp are not suppressed. 77 | config.log_formatter = ::Logger::Formatter.new 78 | 79 | # Use a different logger for distributed setups. 80 | # require 'syslog/logger' 81 | # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name') 82 | 83 | if ENV["RAILS_LOG_TO_STDOUT"].present? 84 | logger = ActiveSupport::Logger.new(STDOUT) 85 | logger.formatter = config.log_formatter 86 | config.logger = ActiveSupport::TaggedLogging.new(logger) 87 | end 88 | 89 | # Do not dump schema after migrations. 90 | config.active_record.dump_schema_after_migration = false 91 | end 92 | -------------------------------------------------------------------------------- /spec/spec_helper.rb: -------------------------------------------------------------------------------- 1 | # This file was generated by the `rails generate rspec:install` command. Conventionally, all 2 | # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`. 3 | # The generated `.rspec` file contains `--require spec_helper` which will cause 4 | # this file to always be loaded, without a need to explicitly require it in any 5 | # files. 6 | # 7 | # Given that it is always loaded, you are encouraged to keep this file as 8 | # light-weight as possible. Requiring heavyweight dependencies from this file 9 | # will add to the boot time of your test suite on EVERY test run, even for an 10 | # individual file that may not need all of that loaded. Instead, consider making 11 | # a separate helper file that requires the additional dependencies and performs 12 | # the additional setup, and require it from the spec files that actually need 13 | # it. 14 | # 15 | # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration 16 | RSpec.configure do |config| 17 | # rspec-expectations config goes here. You can use an alternate 18 | # assertion/expectation library such as wrong or the stdlib/minitest 19 | # assertions if you prefer. 20 | config.expect_with :rspec do |expectations| 21 | # This option will default to `true` in RSpec 4. It makes the `description` 22 | # and `failure_message` of custom matchers include text for helper methods 23 | # defined using `chain`, e.g.: 24 | # be_bigger_than(2).and_smaller_than(4).description 25 | # # => "be bigger than 2 and smaller than 4" 26 | # ...rather than: 27 | # # => "be bigger than 2" 28 | expectations.include_chain_clauses_in_custom_matcher_descriptions = true 29 | end 30 | 31 | # rspec-mocks config goes here. You can use an alternate test double 32 | # library (such as bogus or mocha) by changing the `mock_with` option here. 33 | config.mock_with :rspec do |mocks| 34 | # Prevents you from mocking or stubbing a method that does not exist on 35 | # a real object. This is generally recommended, and will default to 36 | # `true` in RSpec 4. 37 | mocks.verify_partial_doubles = true 38 | end 39 | 40 | # This option will default to `:apply_to_host_groups` in RSpec 4 (and will 41 | # have no way to turn it off -- the option exists only for backwards 42 | # compatibility in RSpec 3). It causes shared context metadata to be 43 | # inherited by the metadata hash of host groups and examples, rather than 44 | # triggering implicit auto-inclusion in groups with matching metadata. 45 | config.shared_context_metadata_behavior = :apply_to_host_groups 46 | 47 | # The settings below are suggested to provide a good initial experience 48 | # with RSpec, but feel free to customize to your heart's content. 49 | =begin 50 | # This allows you to limit a spec run to individual examples or groups 51 | # you care about by tagging them with `:focus` metadata. When nothing 52 | # is tagged with `:focus`, all examples get run. RSpec also provides 53 | # aliases for `it`, `describe`, and `context` that include `:focus` 54 | # metadata: `fit`, `fdescribe` and `fcontext`, respectively. 55 | config.filter_run_when_matching :focus 56 | 57 | # Allows RSpec to persist some state between runs in order to support 58 | # the `--only-failures` and `--next-failure` CLI options. We recommend 59 | # you configure your source control system to ignore this file. 60 | config.example_status_persistence_file_path = "spec/examples.txt" 61 | 62 | # Limits the available syntax to the non-monkey patched syntax that is 63 | # recommended. For more details, see: 64 | # - http://rspec.info/blog/2012/06/rspecs-new-expectation-syntax/ 65 | # - http://www.teaisaweso.me/blog/2013/05/27/rspecs-new-message-expectation-syntax/ 66 | # - http://rspec.info/blog/2014/05/notable-changes-in-rspec-3/#zero-monkey-patching-mode 67 | config.disable_monkey_patching! 68 | 69 | # Many RSpec users commonly either run the entire suite or an individual 70 | # file, and it's useful to allow more verbose output when running an 71 | # individual spec file. 72 | if config.files_to_run.one? 73 | # Use the documentation formatter for detailed output, 74 | # unless a formatter has already been configured 75 | # (e.g. via a command-line flag). 76 | config.default_formatter = "doc" 77 | end 78 | 79 | # Print the 10 slowest examples and example groups at the 80 | # end of the spec run, to help surface which specs are running 81 | # particularly slow. 82 | config.profile_examples = 10 83 | 84 | # Run specs in random order to surface order dependencies. If you find an 85 | # order dependency and want to debug it, you can fix the order by providing 86 | # the seed, which is printed after each run. 87 | # --seed 1234 88 | config.order = :random 89 | 90 | # Seed global randomization in this process using the `--seed` CLI option. 91 | # Setting this allows you to use `--seed` to deterministically reproduce 92 | # test failures related to randomization by passing the same `--seed` value 93 | # as the one that triggered the failure. 94 | Kernel.srand config.seed 95 | =end 96 | end 97 | -------------------------------------------------------------------------------- /Gemfile.lock: -------------------------------------------------------------------------------- 1 | GEM 2 | remote: https://rubygems.org/ 3 | specs: 4 | actioncable (5.1.3) 5 | actionpack (= 5.1.3) 6 | nio4r (~> 2.0) 7 | websocket-driver (~> 0.6.1) 8 | actionmailer (5.1.3) 9 | actionpack (= 5.1.3) 10 | actionview (= 5.1.3) 11 | activejob (= 5.1.3) 12 | mail (~> 2.5, >= 2.5.4) 13 | rails-dom-testing (~> 2.0) 14 | actionpack (5.1.3) 15 | actionview (= 5.1.3) 16 | activesupport (= 5.1.3) 17 | rack (~> 2.0) 18 | rack-test (~> 0.6.3) 19 | rails-dom-testing (~> 2.0) 20 | rails-html-sanitizer (~> 1.0, >= 1.0.2) 21 | actionview (5.1.3) 22 | activesupport (= 5.1.3) 23 | builder (~> 3.1) 24 | erubi (~> 1.4) 25 | rails-dom-testing (~> 2.0) 26 | rails-html-sanitizer (~> 1.0, >= 1.0.3) 27 | activejob (5.1.3) 28 | activesupport (= 5.1.3) 29 | globalid (>= 0.3.6) 30 | activemodel (5.1.3) 31 | activesupport (= 5.1.3) 32 | activerecord (5.1.3) 33 | activemodel (= 5.1.3) 34 | activesupport (= 5.1.3) 35 | arel (~> 8.0) 36 | activesupport (5.1.3) 37 | concurrent-ruby (~> 1.0, >= 1.0.2) 38 | i18n (~> 0.7) 39 | minitest (~> 5.1) 40 | tzinfo (~> 1.1) 41 | arel (8.0.0) 42 | bcrypt (3.1.11) 43 | bindex (0.5.0) 44 | builder (3.2.3) 45 | byebug (9.0.6) 46 | coffee-rails (4.2.2) 47 | coffee-script (>= 2.2.0) 48 | railties (>= 4.0.0) 49 | coffee-script (2.4.1) 50 | coffee-script-source 51 | execjs 52 | coffee-script-source (1.12.2) 53 | concurrent-ruby (1.0.5) 54 | diff-lcs (1.3) 55 | dotenv (2.2.1) 56 | dotenv-rails (2.2.1) 57 | dotenv (= 2.2.1) 58 | railties (>= 3.2, < 5.2) 59 | erubi (1.6.1) 60 | execjs (2.7.0) 61 | faker (1.8.4) 62 | i18n (~> 0.5) 63 | faraday (0.12.2) 64 | multipart-post (>= 1.2, < 3) 65 | ffi (1.9.18) 66 | globalid (0.4.0) 67 | activesupport (>= 4.2.0) 68 | google-protobuf (3.3.0) 69 | graphiql-rails (1.4.2) 70 | rails 71 | graphql (1.6.6) 72 | graphql-batch (0.3.3) 73 | graphql (>= 0.8, < 2) 74 | promise.rb (~> 0.7.2) 75 | graphql-preload (1.0.3) 76 | activerecord (>= 3.2, < 6) 77 | graphql (>= 1.5, < 2) 78 | graphql-batch (~> 0.3) 79 | promise.rb (~> 0.7) 80 | hitimes (1.2.6) 81 | i18n (0.8.6) 82 | jbuilder (2.7.0) 83 | activesupport (>= 4.2.0) 84 | multi_json (>= 1.2) 85 | json (2.1.0) 86 | json_web_token (0.3.5) 87 | json (~> 2.1) 88 | listen (3.1.5) 89 | rb-fsevent (~> 0.9, >= 0.9.4) 90 | rb-inotify (~> 0.9, >= 0.9.7) 91 | ruby_dep (~> 1.2) 92 | loofah (2.0.3) 93 | nokogiri (>= 1.5.9) 94 | mail (2.6.6) 95 | mime-types (>= 1.16, < 4) 96 | method_source (0.8.2) 97 | mime-types (3.1) 98 | mime-types-data (~> 3.2015) 99 | mime-types-data (3.2016.0521) 100 | mini_portile2 (2.2.0) 101 | minitest (5.10.3) 102 | multi_json (1.12.1) 103 | multipart-post (2.0.0) 104 | net-http-persistent (2.9.4) 105 | nio4r (2.1.0) 106 | nokogiri (1.8.0) 107 | mini_portile2 (~> 2.2.0) 108 | optics-agent (0.5.4) 109 | faraday (~> 0.11) 110 | google-protobuf (~> 3.2) 111 | graphql (~> 1.1) 112 | hitimes (~> 1.2) 113 | net-http-persistent (~> 2.0) 114 | pg (0.21.0) 115 | promise.rb (0.7.3) 116 | puma (3.9.1) 117 | rack (2.0.3) 118 | rack-test (0.6.3) 119 | rack (>= 1.0) 120 | rails (5.1.3) 121 | actioncable (= 5.1.3) 122 | actionmailer (= 5.1.3) 123 | actionpack (= 5.1.3) 124 | actionview (= 5.1.3) 125 | activejob (= 5.1.3) 126 | activemodel (= 5.1.3) 127 | activerecord (= 5.1.3) 128 | activesupport (= 5.1.3) 129 | bundler (>= 1.3.0) 130 | railties (= 5.1.3) 131 | sprockets-rails (>= 2.0.0) 132 | rails-dom-testing (2.0.3) 133 | activesupport (>= 4.2.0) 134 | nokogiri (>= 1.6) 135 | rails-html-sanitizer (1.0.3) 136 | loofah (~> 2.0) 137 | railties (5.1.3) 138 | actionpack (= 5.1.3) 139 | activesupport (= 5.1.3) 140 | method_source 141 | rake (>= 0.8.7) 142 | thor (>= 0.18.1, < 2.0) 143 | rake (12.0.0) 144 | rb-fsevent (0.10.2) 145 | rb-inotify (0.9.10) 146 | ffi (>= 0.5.0, < 2) 147 | rspec-core (3.6.0) 148 | rspec-support (~> 3.6.0) 149 | rspec-expectations (3.6.0) 150 | diff-lcs (>= 1.2.0, < 2.0) 151 | rspec-support (~> 3.6.0) 152 | rspec-mocks (3.6.0) 153 | diff-lcs (>= 1.2.0, < 2.0) 154 | rspec-support (~> 3.6.0) 155 | rspec-rails (3.6.0) 156 | actionpack (>= 3.0) 157 | activesupport (>= 3.0) 158 | railties (>= 3.0) 159 | rspec-core (~> 3.6.0) 160 | rspec-expectations (~> 3.6.0) 161 | rspec-mocks (~> 3.6.0) 162 | rspec-support (~> 3.6.0) 163 | rspec-support (3.6.0) 164 | ruby_dep (1.5.0) 165 | sass (3.5.1) 166 | sass-listen (~> 4.0.0) 167 | sass-listen (4.0.0) 168 | rb-fsevent (~> 0.9, >= 0.9.4) 169 | rb-inotify (~> 0.9, >= 0.9.7) 170 | sass-rails (5.0.6) 171 | railties (>= 4.0.0, < 6) 172 | sass (~> 3.1) 173 | sprockets (>= 2.8, < 4.0) 174 | sprockets-rails (>= 2.0, < 4.0) 175 | tilt (>= 1.1, < 3) 176 | spring (2.0.2) 177 | activesupport (>= 4.2) 178 | spring-watcher-listen (2.0.1) 179 | listen (>= 2.7, < 4.0) 180 | spring (>= 1.2, < 3.0) 181 | sprockets (3.7.1) 182 | concurrent-ruby (~> 1.0) 183 | rack (> 1, < 3) 184 | sprockets-rails (3.2.0) 185 | actionpack (>= 4.0) 186 | activesupport (>= 4.0) 187 | sprockets (>= 3.0.0) 188 | thor (0.19.4) 189 | thread_safe (0.3.6) 190 | tilt (2.0.8) 191 | turbolinks (5.0.1) 192 | turbolinks-source (~> 5) 193 | turbolinks-source (5.0.3) 194 | tzinfo (1.2.3) 195 | thread_safe (~> 0.1) 196 | uglifier (3.2.0) 197 | execjs (>= 0.3.0, < 3) 198 | web-console (3.5.1) 199 | actionview (>= 5.0) 200 | activemodel (>= 5.0) 201 | bindex (>= 0.4.0) 202 | railties (>= 5.0) 203 | websocket-driver (0.6.5) 204 | websocket-extensions (>= 0.1.0) 205 | websocket-extensions (0.1.2) 206 | 207 | PLATFORMS 208 | ruby 209 | 210 | DEPENDENCIES 211 | bcrypt (~> 3.1, >= 3.1.11) 212 | byebug 213 | coffee-rails (~> 4.2) 214 | dotenv-rails (~> 2.2, >= 2.2.1) 215 | faker (~> 1.8, >= 1.8.4) 216 | graphiql-rails 217 | graphql (~> 1.6, >= 1.6.6) 218 | graphql-batch (~> 0.3.3) 219 | graphql-preload (~> 1.0, >= 1.0.3) 220 | jbuilder (~> 2.5) 221 | json_web_token (~> 0.3.5) 222 | listen (>= 3.0.5, < 3.2) 223 | optics-agent 224 | pg (~> 0.18) 225 | puma (~> 3.7) 226 | rails (~> 5.1.3) 227 | rspec-rails (~> 3.6) 228 | sass-rails (~> 5.0) 229 | spring 230 | spring-watcher-listen (~> 2.0.0) 231 | turbolinks (~> 5) 232 | tzinfo-data 233 | uglifier (>= 1.3.0) 234 | web-console (>= 3.3.0) 235 | 236 | BUNDLED WITH 237 | 1.14.3 238 | --------------------------------------------------------------------------------