Git Product home page Git Product logo

rails-challenge's Introduction

Breazy Rails Challenge

Setup

  • Fork this repository
  • Make sure that Ruby, Rails, and SQLite3 are installed on your machine. This might be helpful if you don't create new apps everyday https://guides.rubyonrails.org/getting_started.html
  • Run bundle install to install gems
  • Setup database rake db:setup
  • Run the app rails server or an interactive console rails console to test that your app is running.

Premise:

  • E-commerce sites often follow a similar data format. I've already created models for some of the more common resources. These are the objects that are already modeled and included in the schema.
  • A customer is someone making a purchase.
  • A product is a product for sale.
  • A variant is a version of a specific product. For example if the product was "Jean Jacket" the variants might be "Dark Blue" and "Light Blue", although variant usage is not limited to color.
  • A collection contains a group of similar products

Note:

  • Please use RSpec for the test, but otherwise use any libraries you prefer.
  • We encourage writing the tests first! If you are comfortable with TDD, do Step 3 before Step 2.

Step 1

Create a model for a customer order.

It should store these attributes.
  • Date created
  • Reference/relationship to the customer who is placing the order.
  • Reference to each variant ordered and the quantity ordered of each variant. (HINT: Might be helpful to create a second model here)
  • Total cost of all variants included in the order. (Should not change when the price of an included variant is changed)
  • Current order status ['pending', 'processing', 'fulfilled', 'delivered', 'canceled']. This field should default to pending.

Step 2

Create an endpoint to create orders. This endpoint enables the creation of an order based on a set of required parameters(customer_id, list of variant_ids and quantities ordered)

Requirements
  • Creating an order returns a 400 response if the request doesn't contain required parameters
  • Creating an order returns a 404 response if any of the customer or variant ids are invalid.
  • Creating an order returns a 422 response if there is not enough stock for any of the variants contained in the order.
  • Creating an order succeeds if none of the previous error scenarios occur.

Step 3

Write an RSpec test to verify that order creation endpoint behaves as described above.

Step 4

Create an endpoint to display a single order resource at the /orders/{#id}.json endpoint.

  • Response should contain all order fields, and additionally include variant id, name, price, and quantity ordered for each variant included in the order.

rails-challenge's People

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.