Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Rails Capstone: Final Version #5

Closed
wants to merge 33 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
33 commits
Select commit Hold shift + click to select a range
8012527
Update README.md
ab-noori Sep 23, 2023
e94b154
Update README.md
ab-noori Sep 23, 2023
ee8126c
Add schema ERD
ab-noori Sep 23, 2023
64857df
Update README.md
ab-noori Sep 23, 2023
5f4f1be
Update README.md
ab-noori Sep 23, 2023
bf41dbe
Update README.md
ab-noori Sep 23, 2023
af196f5
Update README.md
ab-noori Sep 23, 2023
83bb9ab
Add the project screen shot
ab-noori Sep 23, 2023
a8d9ce8
Update README.md
ab-noori Sep 23, 2023
7a7c90e
Update README.md
ab-noori Sep 23, 2023
c10d8d6
Update README.md
ab-noori Sep 23, 2023
cd1e540
Delete app/assets/images/Finance-Tracker login.PNG
ab-noori Sep 23, 2023
701be9b
Add files via upload
ab-noori Sep 23, 2023
cdfd57d
Update README.md
ab-noori Sep 23, 2023
54c2595
Update README.md
ab-noori Sep 23, 2023
75b3ecb
Update README.md
ab-noori Sep 23, 2023
d002da4
Update README.md
ab-noori Sep 23, 2023
d17c04b
Update README.md
ab-noori Sep 23, 2023
681ff47
Update README.md
ab-noori Sep 23, 2023
7d0d439
Update README.md
ab-noori Sep 23, 2023
722d66f
Update README.md
ab-noori Sep 23, 2023
1a4e78c
Add validation to the category model.
ab-noori Sep 23, 2023
d393696
Add validation to the expense model
ab-noori Sep 23, 2023
02e525b
Add and install testing gems.
ab-noori Sep 23, 2023
2a9bb4b
Set up factoryBot for generating test data.
ab-noori Sep 23, 2023
d18283d
Add Unit test files for models.
ab-noori Sep 23, 2023
4150359
Add integration test files for controllers.
ab-noori Sep 23, 2023
edf1f91
Add rspec
ab-noori Sep 23, 2023
b1d4a5a
Fix all the rubocop offenses.
ab-noori Sep 23, 2023
106e00a
Merge pull request #6 from ab-noori/unit-integration-tests
ab-noori Sep 23, 2023
a72c15c
Update README.md
ab-noori Sep 23, 2023
52ecebb
Update README.md
ab-noori Sep 23, 2023
03a8452
Update README.md
ab-noori Sep 23, 2023
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .rspec
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
--require spec_helper
3 changes: 3 additions & 0 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -57,6 +57,8 @@ gem 'bootsnap', require: false
group :development, :test do
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
gem 'debug', platforms: %i[mri mingw x64_mingw]
gem 'factory_bot_rails'
gem 'rspec-rails'
end

group :development do
Expand All @@ -73,5 +75,6 @@ end
group :test do
# Use system testing [https://guides.rubyonrails.org/testing.html#system-testing]
gem 'capybara'
gem 'rails-controller-testing'
gem 'selenium-webdriver'
end
30 changes: 30 additions & 0 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,13 @@ GEM
railties (>= 4.1.0)
responders
warden (~> 1.2.3)
diff-lcs (1.5.0)
erubi (1.12.0)
factory_bot (6.2.1)
activesupport (>= 5.0.0)
factory_bot_rails (6.2.0)
factory_bot (~> 6.2.0)
railties (>= 5.0.0)
globalid (1.2.1)
activesupport (>= 6.1)
i18n (1.14.1)
Expand Down Expand Up @@ -168,6 +174,10 @@ GEM
activesupport (= 7.0.8)
bundler (>= 1.15.0)
railties (= 7.0.8)
rails-controller-testing (1.0.5)
actionpack (>= 5.0.1.rc1)
actionview (>= 5.0.1.rc1)
activesupport (>= 5.0.1.rc1)
rails-dom-testing (2.2.0)
activesupport (>= 5.0.0)
minitest
Expand All @@ -193,6 +203,23 @@ GEM
actionpack (>= 5.2)
railties (>= 5.2)
rexml (3.2.6)
rspec-core (3.12.2)
rspec-support (~> 3.12.0)
rspec-expectations (3.12.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-mocks (3.12.6)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.12.0)
rspec-rails (6.0.3)
actionpack (>= 6.1)
activesupport (>= 6.1)
railties (>= 6.1)
rspec-core (~> 3.12)
rspec-expectations (~> 3.12)
rspec-mocks (~> 3.12)
rspec-support (~> 3.12)
rspec-support (3.12.1)
rubocop (1.56.3)
base64 (~> 0.1.1)
json (~> 2.3)
Expand Down Expand Up @@ -257,11 +284,14 @@ DEPENDENCIES
capybara
debug
devise
factory_bot_rails
importmap-rails
jbuilder
pg (~> 1.1)
puma (~> 5.0)
rails (~> 7.0.8)
rails-controller-testing
rspec-rails
rubocop (>= 1.0, < 2.0)
selenium-webdriver
sprockets-rails
Expand Down
203 changes: 190 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,24 +1,201 @@
# README
![](https://img.shields.io/badge/Microverse-blueviolet)

This README would normally document whatever steps are necessary to get the
application up and running.
> # Finance Tracker

Things you may want to cover:
| Project Login Page |
|---------------------------------------|
|<div align="center" width="auto"><img alt="Finance-Tracker login" src="app/assets/images/Finance-Tracker login.PNG"/></div>|

* Ruby version

* System dependencies

* Configuration
<a name="readme-top"></a>

* Database creation
<!-- TABLE OF CONTENTS -->

* Database initialization
# 📗 Table of Contents

* How to run the test suite
- [📖 About the Project](#about-project)
- [🛠 Built With](#built-with)
- [Tech Stack](#tech-stack)
- [Key Features](#key-features)
- [🚀 Live Demo](#live-demo)
- [💻 Getting Started](#getting-started)
- [Setup](#setup)
- [Prerequisites](#prerequisites)
- [Install](#install)
- [Usage](#usage)
- [Run tests](#run-tests)
- [👥 Authors](#authors)
- [🔭 Future Features](#future-features)
- [🤝 Contributing](#contributing)
- [⭐️ Show your support](#support)
- [🙏 Acknowledgements](#acknowledgements)
- [📝 License](#license)

* Services (job queues, cache servers, search engines, etc.)
<!-- PROJECT DESCRIPTION -->

* Deployment instructions
# 📖 [Finance Tracker] <a name="about-project"></a>

> **[Finance-Tracker]** The Ruby on Rails Budget-app project is aimed at creating a mobile web application that enables budget management, including user registration and login for data privacy, the introduction of new transactions linked to categories, and the display of expenditures per category.
## 🛠 Built With <a name="built-with"></a>

### Tech Stack <a name="tech-stack"></a>

<details>
<summary>Client</summary>
<ul>
<li><a href="https://www.w3schools.com/html/default.asp">HTML</a></li>
<li><a href="https://www.w3schools.com/css/default.asp">CSS</a></li>
<li><a href="https://getbootstrap.com/">Bootstrap</a></li>
</ul>
</details>

<details>
<summary>Server</summary>
<ul>
<li><a href="https://www.ruby-lang.org/en/">Ruby</a></li>
<li><a href="https://guides.rubyonrails.org/">Ruby on Rails</a></li>
</ul>
</details>

<details>
<summary>Database</summary>
<ul>
<li><a href="https://www.postgresql.org/">PostgreSQL</a></li>
</ul>
</details>

<!-- Features -->

### Key Features <a name="key-features"></a>

- **[Splash screen]**
- **[Sign up and log in pages]**
- **[Home page (categories page)]**
- **[Details page (transactions page)]**
- **["Add a new category" page]**
- **["Add a new transaction" page]**

| Implemented Schema's ERD |
|---------------------------------------|
|<img width="auto" alt="erd_diagram" src="app/assets/images/erd_diagram.png">|

<p align="right">(<a href="#readme-top">back to top</a>)</p>

## 🚀 Live Demo & Project intro <a name="live-demo"></a>
- [Live Demo on Render](https://finance-tracker-kxhn.onrender.com/)
- [Introduction to the project](https://www.loom.com/share/928b45d5bd4c45d4bc95497e9ccc442f?sid=4e1fcb03-dfd3-4891-b610-0ff3c4545693)

> In this video, I introduce you to the Ruby On Rails capstone project, which is a budget application called the finance tracker. I walk you through the login page, the home page, and the transaction page, explaining the features and functionalities of each. I also demonstrate how to create a new category and add a new transaction. Finally, I show you the mobile version of the application. Watch this video to get an overview of the project and its key components.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- GETTING STARTED -->

## 💻 Getting Started <a name="getting-started"></a>

To get a local copy up and running, follow these steps.

### Prerequisites

In order to run this project you need:
- [Ruby on Rails](https://rubyonrails.org/) installed and running. To get more information, read the [installation guide](https://guides.rubyonrails.org/).

- [PostgreSQL](https://www.postgresql.org/) installed and running

<p align="right">(<a href="#readme-top">back to top</a>)</p>

##

### Setup

Clone this repository to your desired folder:

```sh
cd my-folder
https://github.com/ab-noori/Finance-Tracker.git
```
<p align="right">(<a href="#readme-top">back to top</a>)</p>

### Install

Install this project with:

```sh
bundle install
rails db:create
rails db:migrate
```
<p align="right">(<a href="#readme-top">back to top</a>)</p>

### Usage

To run the project, execute the following command:

```sh
rails server
```
<p align="right">(<a href="#readme-top">back to top</a>)</p>

### Run tests

To run tests, run the following command:

```sh
rspec spec
```
<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- AUTHORS -->

## 👥 Authors <a name="authors"></a>

👤 **Abdul Ali Noori**

- GitHub: [@ab-noori](https://github.com/ab-noori)
- Twitter: [@AbdulAliNoori4](https://twitter.com/AbdulAliNoori4)
- LinkedIn: [abdulali-noori](https://www.linkedin.com/in/abdulali-noori)

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- FUTURE FEATURES -->

## 🔭 Future Features <a name="future-features"></a>
- [ ] **[Applying the edit and delete options for categories]**
- [ ] **[Optimizing the project style for longer screen sizes]**

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- CONTRIBUTING -->

## 🤝 Contributing <a name="contributing"></a>

Contributions, issues, and feature requests are welcome!

Feel free to check the [issues page](https://github.com/ab-noori/Finance-Tracker/issues/new).

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- SUPPORT -->

## ⭐️ Show your support <a name="support"></a>

If you like this project, give it a star.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

<!-- ACKNOWLEDGEMENTS -->

## 🙏 Acknowledgments <a name="acknowledgements"></a>

First, I would like to thank Microverse and my coding partners, and then I would like to give special credit to the creator of the design ([Gregoire Vella on Behance](https://www.behance.net/gregoirevella)) that I have used in my project.

<p align="right">(<a href="#readme-top">back to top</a>)</p>


## 📝 License <a name="license"></a>

This project is [MIT](./LICENSE) licensed.

<p align="right">(<a href="#readme-top">back to top</a>)</p>

* ...
Binary file added app/assets/images/Finance-Tracker login.PNG
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added app/assets/images/erd_diagram.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
2 changes: 2 additions & 0 deletions app/models/category.rb
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,6 @@ class Category < ApplicationRecord
has_many :expense_category_associations
has_one_attached :icon, dependent: :destroy
has_many :expenses, through: :expense_category_associations

validates :name, presence: true
end
3 changes: 3 additions & 0 deletions app/models/expense.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,4 +2,7 @@ class Expense < ApplicationRecord
belongs_to :user
has_many :expense_category_associations
has_many :categories, through: :expense_category_associations

validates :name, presence: true
validates :amount, presence: true, numericality: { greater_than: 0 }
end
8 changes: 8 additions & 0 deletions spec/factories/categories.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
# spec/factories/categories.rb

FactoryBot.define do
factory :category, class: Category do
name { 'Sample Category' }
association :user, factory: :user
end
end
9 changes: 9 additions & 0 deletions spec/factories/expenses.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
# spec/factories/expenses.rb

FactoryBot.define do
factory :expense, class: Expense do
name { 'Sample Expense' }
amount { 50.0 }
association :user, factory: :user
end
end
10 changes: 10 additions & 0 deletions spec/factories/users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
# In spec/factories/users.rb

FactoryBot.define do
factory :user do
email { '[email protected]' }
password { 'password' }
name { 'Example User' }
role { 'User' }
end
end
28 changes: 28 additions & 0 deletions spec/models/category_spec.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
require 'rails_helper'

RSpec.describe Category, type: :model do
context 'validations' do
it 'is valid with a name' do
category = FactoryBot.create(:category)
expect(category).to be_valid
end

it 'is invalid without a name' do
category = Category.new
expect(category).to_not be_valid
expect(category.errors[:name]).to include("can't be blank")
end
end

context 'associations' do
it 'belongs to a user' do
association = Category.reflect_on_association(:user)
expect(association.macro).to eq(:belongs_to)
end

it 'has many expenses' do
association = Category.reflect_on_association(:expenses)
expect(association.macro).to eq(:has_many)
end
end
end
Loading
Loading