Coder Social home page Coder Social logo

first_circle_test's Introduction

README

This assessment is created with Ruby 3 and Rails 6.1.

Database creation and initialization

Seed files are created to populate initial data for testing purposes

rails db:create db:migrate db:seed

How to run the test suite with RSpec

rspec spec/

Design Considerations

  1. The code was designed to record computed discount amounts instead of subtracting it from the regular price of products. Considering that a storefront needs this data to:
  • Generate reports for total discount given to customers
  • Record sales discount entry for accounting purposes.
  • Needed data to come up with the Cost of Goods Sold in order for the store front to know their income for a processed order.
  1. 'gem money-rails' was used to handle all money calculations

  2. Service Objects area created to implement the complex discounting rules and calculation of discount amount.

Discount Rules

The following models area created to represent the different discounting rules.

Bulk Discount

Enable bulk discount rules for products. When customers reach a certain minimum purchase quantity, a bulk discount rule will effect on their purchase.

To run the test for this rule:

rspec spec/services/checkout/discounts/apply_bulk_discount_spec.rb

Freebie

A free item can be bundled to a product during a purchase.

To run the test for this rule:

rspec spec/services/checkout/discounts/apply_freebie_spec.rb

X for Y Discount

Example. 3 for 2 deal on Apple TVs.

To run the test for this rule:

rspec spec/services/checkout/discounts/apply_x_for_y_discount_spec.rb

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.