3 |
--------------------------------------------------------------------------------
/app/channels/application_cable/channel.rb:
--------------------------------------------------------------------------------
1 | module ApplicationCable
2 | class Channel < ActionCable::Channel::Base
3 | end
4 | end
5 |
--------------------------------------------------------------------------------
/app/views/cats/adopt.html.erb:
--------------------------------------------------------------------------------
1 | ¡Muchas gracias por tu interés en <%= @cat.name %>! Muy pronto nos pondremos en contacto contigo por e-mail.
--------------------------------------------------------------------------------
/config/initializers/high_voltage.rb:
--------------------------------------------------------------------------------
1 | HighVoltage.configure do |config|
2 | config.route_drawer = HighVoltage::RouteDrawers::Root
3 | end
--------------------------------------------------------------------------------
/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/models/assignment.rb:
--------------------------------------------------------------------------------
1 | class Assignment < ApplicationRecord
2 | belongs_to :colony
3 | belongs_to :task
4 |
5 | has_many :turns
6 | end
7 |
--------------------------------------------------------------------------------
/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.exe
2 | ENV['BUNDLE_GEMFILE'] ||= File.expand_path('../Gemfile', __dir__)
3 | load Gem.bin_path('bundler', 'bundle')
4 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/bin/rails:
--------------------------------------------------------------------------------
1 | #!/usr/bin/env ruby.exe
2 | APP_PATH = File.expand_path('../config/application', __dir__)
3 | require_relative '../config/boot'
4 | require 'rails/commands'
5 |
--------------------------------------------------------------------------------
/config/environment.rb:
--------------------------------------------------------------------------------
1 | # Load the Rails application.
2 | require_relative 'application'
3 |
4 | # Initialize the Rails application.
5 | Rails.application.initialize!
6 |
--------------------------------------------------------------------------------
/app/models/adoption.rb:
--------------------------------------------------------------------------------
1 | class Adoption < ApplicationRecord
2 | belongs_to :cat
3 | belongs_to :user
4 |
5 | validates :date, presence: true, on: :update
6 |
7 | end
8 |
--------------------------------------------------------------------------------
/app/views/devise/mailer/password_change.html.erb:
--------------------------------------------------------------------------------
1 |
Hello <%= @resource.email %>!
2 |
3 |
We're contacting you to notify you that your password has been changed.
4 |
--------------------------------------------------------------------------------
/spec/models/adoption_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe Adoption, type: :model do
4 | it { should belong_to :cat }
5 | it { should belong_to :user }
6 | end
7 |
--------------------------------------------------------------------------------
/spec/models/turns_user_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe TurnsUser, type: :model do
4 | it { should belong_to :turn }
5 | it { should belong_to :user }
6 | end
7 |
--------------------------------------------------------------------------------
/db/migrate/20180523163003_add_colony_id_to_cats.rb:
--------------------------------------------------------------------------------
1 | class AddColonyIdToCats < ActiveRecord::Migration[5.1]
2 | def change
3 | add_column :cats, :colony_id, :integer
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20180821192912_add_saved_state_to_cats.rb:
--------------------------------------------------------------------------------
1 | class AddSavedStateToCats < ActiveRecord::Migration[5.1]
2 | def change
3 | add_column :cats, :saved_state, :string
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/spec/models/colonies_user_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe ColoniesUser, type: :model do
4 | it { should belong_to :user }
5 | it { should belong_to :colony }
6 | end
7 |
--------------------------------------------------------------------------------
/.idea/vcs.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/.idea/misc.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/app/models/posession.rb:
--------------------------------------------------------------------------------
1 | class Posession < ApplicationRecord
2 | belongs_to :product
3 | belongs_to :user
4 |
5 | validates :date, presence: true
6 | validates_with PosessionValidator
7 | end
8 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/db/migrate/20180523163043_add_location_id_to_colony.rb:
--------------------------------------------------------------------------------
1 | class AddLocationIdToColony < ActiveRecord::Migration[5.1]
2 | def change
3 | add_column :colonies, :location_id, :integer
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/cats.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the cats controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/turns.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the turns controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/views/tasks/show.html.erb:
--------------------------------------------------------------------------------
1 |
<%= @task.name %>
2 |
<%= @task.description %>
3 |
4 | <%= link_to "edit", edit_task_path(@task.id) %>
5 | <%= link_to "destroy", task_path(@task.id), method: :delete %>
--------------------------------------------------------------------------------
/db/migrate/20180523162548_add_fk_to_treatment_entries.rb:
--------------------------------------------------------------------------------
1 | class AddFkToTreatmentEntries < ActiveRecord::Migration[5.1]
2 | def change
3 | add_column :treatment_entries, :suffering_id, :integer
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/db/migrate/20181113205713_rename_birthay_field_in_cats.rb:
--------------------------------------------------------------------------------
1 | class RenameBirthayFieldInCats < ActiveRecord::Migration[5.1]
2 | def change
3 | rename_column :cats, :birthdate_date, :birthday_date
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/pages.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the pages controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
5 |
--------------------------------------------------------------------------------
/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: conexion_felina_production
11 |
--------------------------------------------------------------------------------
/spec/models/assignment_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe Assignment, type: :model do
4 | it { should belong_to :task }
5 | it { should belong_to :colony }
6 | it { should have_many :turns }
7 | end
8 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/illnesses.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the illnesses controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/locations.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the locations controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/sufferings.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the sufferings controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/views/illnesses/index.html.erb:
--------------------------------------------------------------------------------
1 |
Illnesses
2 |
3 | <%= link_to "create", new_illness_path %>
4 |
5 | <% @illnesses.each do | illness | %>
6 | <%= link_to illness.name, illness_path( illness.id ) %>
7 | <% end %>
--------------------------------------------------------------------------------
/db/migrate/20181211220509_remove_location_table.rb:
--------------------------------------------------------------------------------
1 | class RemoveLocationTable < ActiveRecord::Migration[5.2]
2 | def change
3 | add_column :colonies, :location, :string
4 | drop_table :locations
5 | end
6 |
7 |
8 | end
9 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/task_user_wizard.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the task_user_wizard controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/assets/stylesheets/treatment_entries.scss:
--------------------------------------------------------------------------------
1 | // Place all the styles related to the treatment_entry controller here.
2 | // They will automatically be included in application.css.
3 | // You can use Sass (SCSS) here: http://sass-lang.com/
4 |
--------------------------------------------------------------------------------
/app/controllers/pages_controller.rb:
--------------------------------------------------------------------------------
1 | class PagesController < ApplicationController
2 | def home; end
3 |
4 | def collaborate; end
5 |
6 | def about; end
7 |
8 | def principles; end
9 |
10 | def league; end
11 | end
12 |
--------------------------------------------------------------------------------
/db/migrate/20180523162055_add_fk_to_sufferings.rb:
--------------------------------------------------------------------------------
1 | class AddFkToSufferings < ActiveRecord::Migration[5.1]
2 | def change
3 | add_column :sufferings, :cat_id, :integer
4 | add_column :sufferings, :illness_id, :integer
5 | end
6 | end
7 |
--------------------------------------------------------------------------------
/db/migrate/20181208195116_add_dischargement_date_to_sufferings_table.rb:
--------------------------------------------------------------------------------
1 | class AddDischargementDateToSufferingsTable < ActiveRecord::Migration[5.2]
2 | def change
3 | add_column :sufferings, :dischargement_date, :datetime
4 | end
5 | end
6 |
--------------------------------------------------------------------------------
/app/models/turn.rb:
--------------------------------------------------------------------------------
1 | class Turn < ApplicationRecord
2 | validates :start_date, presence: true
3 | validates :end_date, presence: true
4 | validates_with TurnValidator
5 |
6 | belongs_to :assignment
7 | has_and_belongs_to_many :users
8 | end
9 |
--------------------------------------------------------------------------------
/spec/models/suffering_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe Suffering, type: :model do
4 |
5 | it {should have_many :treatment_entries}
6 | it {should belong_to :cat}
7 | it {should belong_to :illness}
8 |
9 | end
10 |
--------------------------------------------------------------------------------
/app/assets/javascripts/cats.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/pages.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/turns.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/views/colonies/index.html.erb:
--------------------------------------------------------------------------------
1 |
Colonies
2 |
3 | <%= link_to "create", new_colony_path %>
4 |
5 | <% @colonies.each do | colony | %>
6 | <%= link_to colony.name, colony_path( colony.id ) %>
7 | <%= colony.bio %>
8 | <% end %>
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/app/assets/javascripts/illnesses.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/locations.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/sufferings.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/spec/models/cat_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe Cat, type: :model do
4 | it { should have_many :sufferings}
5 | it { should belong_to :colony }
6 | it { should have_one :adoption }
7 | it { should have_many :sponsors }
8 | end
9 |
--------------------------------------------------------------------------------
/app/assets/javascripts/task_user_wizard.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/app/assets/javascripts/treatment_entries.coffee:
--------------------------------------------------------------------------------
1 | # Place all the behaviors and hooks related to the matching controller here.
2 | # All this logic will automatically be available in application.js.
3 | # You can use CoffeeScript in this file: http://coffeescript.org/
4 |
--------------------------------------------------------------------------------
/db/migrate/20180516155412_create_colonies.rb:
--------------------------------------------------------------------------------
1 | class CreateColonies < ActiveRecord::Migration[5.1]
2 | def change
3 | create_table :colonies do |t|
4 | t.string :name
5 | t.text :bio
6 |
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/db/migrate/20180516160028_create_tasks.rb:
--------------------------------------------------------------------------------
1 | class CreateTasks < ActiveRecord::Migration[5.1]
2 | def change
3 | create_table :tasks do |t|
4 | t.string :name
5 | t.text :description
6 |
7 | t.timestamps
8 | end
9 | end
10 | end
11 |
--------------------------------------------------------------------------------
/docs/_coverpage.md:
--------------------------------------------------------------------------------
1 | 
2 |
3 | # covi project
4 |
5 | > A web application for managing cat colonies.
6 |
7 | [GitHub](https://github.com/infusionvlc/ConexionFelina)
8 | [Get Started](#covi-project)
9 |
10 | 
11 |
--------------------------------------------------------------------------------
/app/views/cats/build/add_origin.html.erb:
--------------------------------------------------------------------------------
1 |
14 | <% end %>
15 |
16 | <%= render "devise/shared/links" %>
17 |
--------------------------------------------------------------------------------
/docs/pundit.md:
--------------------------------------------------------------------------------
1 | # User Authorization
2 |
3 | In our application there are three different types of user roles:
4 | * **Basic** users: they are allowed to browse most of cats info,
5 | adopt or sponsor a cat, and enroll as a volunteer.
6 | * **Volunteers**: they are able to do all basic users actions.
7 | Additionally, they may join a colony or create a new one to manage
8 | tasks, cats illnesses, sponsorships and adoptions.
9 | * **Admins**: they have full access over all colonies information,
10 | excluding all private information from users.
11 |
12 | User policies are managed with [Pundit gem](https://github.com/varvet/pundit)
13 | and are located under `app/policies`.
--------------------------------------------------------------------------------
/app/views/assignments/index.html.erb:
--------------------------------------------------------------------------------
1 |
23 | <% end %>
24 |
25 | <%= render "devise/shared/links" %>
26 |
--------------------------------------------------------------------------------
/docs/design.md:
--------------------------------------------------------------------------------
1 | # UI/UX Specs
2 |
3 | User experience and usability is a must for this project. Volunteers who are
4 | part of cat colonies usually don't have too much time nor resources for
5 | managing the cats' info, so the interface is intended to be really clear and
6 | straightforward. 🖐️
7 |
8 | If you find any issue, don't hesitate to
9 | [send us a message](mailto:hola@infusionvlc.com)or open up a new issue in our
10 | [GitHub repo](https://github.com/infusionvlc/ConexionFelina). :mag:
11 |
12 | ## UI mock-ups
13 |
14 | All application mockups can be found in our
15 | [Figma document](https://www.figma.com/file/PuezufmBksh475JS5nvBsSkx/ConexionFelina?node-id=0%3A1).
16 | This file intends to be our app's design ground truth and must be followed when
17 | developing any component or feature. If you find any mistake or have any
18 | suggestion, please open up a new issue
19 | [GitHub repo](https://github.com/infusionvlc/ConexionFelina) :warning:
20 |
21 | 
--------------------------------------------------------------------------------
/spec/models/user_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe User, type: :model do
4 | it { should have_and_belong_to_many :colonies}
5 | it { should have_and_belong_to_many :turns}
6 | it { should have_many :sponsors}
7 | it { should have_many :adoptions}
8 | it { should have_many :donations}
9 | it { should have_many :posessions}
10 |
11 | context 'validations' do
12 | it { should validate_presence_of(:username) }
13 | it { should validate_presence_of(:email) }
14 | it { should validate_presence_of(:role) }
15 | it { should validate_presence_of(:purrs) }
16 | it { should validate_numericality_of(:purrs).only_integer }
17 | it { should validate_numericality_of(:purrs).is_greater_than_or_equal_to 0 }
18 | it { should validate_length_of(:username).is_at_most(20) }
19 | it { should validate_length_of(:bio).is_at_most(512) }
20 | it { should validate_uniqueness_of(:email).case_insensitive }
21 | it { should validate_uniqueness_of(:username) }
22 | end
23 | end
24 |
--------------------------------------------------------------------------------
/app/controllers/locations_controller.rb:
--------------------------------------------------------------------------------
1 | class LocationsController < ApplicationController
2 | def index
3 | @locations = Location.all
4 | end
5 |
6 | def new
7 | @location = Location.new
8 | end
9 |
10 | def edit
11 | @location = Location.find( params[ :id ])
12 | end
13 |
14 | def create
15 | @location = Location.new( location_params )
16 | @location.save
17 | redirect_to( locations_path )
18 | end
19 |
20 | def update
21 | @location = Location.find( params[ :id ])
22 | @location.update(location_params)
23 | redirect_to( locations_path )
24 | end
25 |
26 | def show
27 | @location = Location.find( params[ :id ])
28 | end
29 |
30 | def destroy
31 | @location = Location.find(params[:id])
32 | @location.destroy
33 | redirect_to(locations_path)
34 | end
35 |
36 | private
37 |
38 | def location_params
39 | params.require(:location).permit(:name, :description, :address, :longitude, :latitude)
40 | end
41 | end
42 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/docs/beginners.md:
--------------------------------------------------------------------------------
1 | # Beginners Guide
2 |
3 | If you have any questions, don't hesitate to contact the team via mail or open up an issue. :wink:
4 |
5 | ## How to properly submit a PR
6 | 1. Fork and clone the repo to your computer. If you haven't done it yet, set up the upstream remote `git remote add upstream https://github.com/infusionvlc/ConexionFelina`
7 | 3. **Make sure you're on the master branch (`git checkout master`) and you are up to date with `git status`**. If not:
8 | `git pull upstream master`
9 | 4. Create a separate branch with the name of the issue you are going to work in with `git checkout -b `
10 | 5. Commit your changes.
11 | 6. Push the working branch to your remote fork.
12 | 7. Make a PR on the upstream master branch with "closes #XX" at it's title to automatically close the issue. **Do not merge it with the master branch on your fork**.
13 | 8. If there is anything that needs to be changed it will be commented on the PR.
14 | 9. When everything is okay your PR will be merged!
15 |
--------------------------------------------------------------------------------
/app/views/sufferings/index.html.erb:
--------------------------------------------------------------------------------
1 |
24 | <% end %>
25 |
--------------------------------------------------------------------------------
/docs/mission.md:
--------------------------------------------------------------------------------
1 | # Mission & principles
2 |
3 | ## Mission
4 |
5 | This project is part of [INFUSIÓN](www.infusionvlc.com). In case you don't know
6 | what **INFUSIÓN** is, it's a **community** based in **València (Spain)** in
7 | which everyone is encouraged to participate, share their knowledge and learn
8 | from others. Our goal is to get **technology** closer to people, regardless of
9 | their previous knowledge, through meetups and projects.
10 |
11 | We believe that diversity is a source of wealth in all areas and that is why we
12 | want to **welcome all people**, whatever their, gender, age, experience, origin,
13 | etc. 👱🧔🏽👨🌾👵 Therefore, everyone involved in the community must comply with
14 | our code of conduct. 🖐️
15 |
16 |
17 | ## Principles
18 |
19 | Our main goal is to build up a project that has a real purpose and impacts on
20 | society. During this process, we encourage every contributor's **learning**
21 | process, proactivity and **social skills**. We do our best to learn about
22 | coding **best practices**, team **organization** and web development while
23 | having fun.
--------------------------------------------------------------------------------
/spec/validators/donation_validator_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe DonationValidator do
4 | def mock_relationships(donation)
5 | donation.user = mock_model("User")
6 | end
7 |
8 | context "given a donation with its date earlier than today" do
9 | it "must be valid" do
10 | valid_donation = Donation.new(amount: 1, date: Date.yesterday)
11 | mock_relationships(valid_donation)
12 |
13 | expect(valid_donation).to be_valid
14 | end
15 | end
16 |
17 | context "given a donation with its date equal to today" do
18 | it "must be valid" do
19 | valid_donation = Donation.new(amount: 1, date: Date.today)
20 | mock_relationships(valid_donation)
21 |
22 | expect(valid_donation).to be_valid
23 | end
24 | end
25 |
26 | context "given a donation with it date later than today" do
27 | it "must be invalid" do
28 | invalid_donation = Donation.new(amount: 1, date: Date.tomorrow)
29 | mock_relationships(invalid_donation)
30 |
31 | expect(invalid_donation).to_not be_valid
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/app/models/user.rb:
--------------------------------------------------------------------------------
1 | class User < ApplicationRecord
2 | # Include default devise modules. Others available are:
3 | # :confirmable, :lockable, :timeoutable and :omniauthable
4 | devise :database_authenticatable, :registerable,
5 | :recoverable, :rememberable, :trackable, :validatable
6 |
7 | MAXIMUM_USERNAME_LENGTH = 20
8 | MAXIMUM_BIO_LENGTH = 512
9 | MINIMUM_PURR_VALUE = 0
10 |
11 | enum role: [ :admin, :volunteer, :basic]
12 |
13 | has_and_belongs_to_many :colonies
14 | has_and_belongs_to_many :turns
15 | has_many :posessions
16 | has_many :donations
17 | has_many :adoptions
18 | has_many :cats, through: :adoptions
19 | has_many :sponsors
20 | has_many :cats, through: :sponsors
21 |
22 | validates :username, :email, :role, :purrs, presence: true
23 | validates :username, length: { maximum: MAXIMUM_USERNAME_LENGTH }
24 | validates :bio, length: { maximum: MAXIMUM_BIO_LENGTH }
25 | validates :purrs, numericality: { only_integer: true, greater_than_or_equal_to: MINIMUM_PURR_VALUE }
26 | validates :email, uniqueness: true
27 | validates :username, uniqueness: true
28 | end
29 |
--------------------------------------------------------------------------------
/app/views/cats/build/_suffering_fields.html.erb:
--------------------------------------------------------------------------------
1 |
23 | <%= link_to_remove_association f, {class:'btn btn-danger', aria: {label:"#{I18n.t 'main.remove'}"}} do %>Remove<% end %>
24 |
25 |
26 |
27 |
--------------------------------------------------------------------------------
/spec/validators/posession_validator_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | RSpec.describe PosessionValidator do
4 | def mock_relationships(posession)
5 | posession.user = mock_model("User")
6 | posession.product = mock_model("Product")
7 | end
8 |
9 | context 'given a posession with a date earlier than today' do
10 | it 'must be valid' do
11 | valid_posession = Posession.new(date: Date.yesterday)
12 |
13 | mock_relationships(valid_posession)
14 | expect(valid_posession).to be_valid
15 | end
16 | end
17 |
18 | context 'given a posession with a date later than today' do
19 | it 'must be invalid' do
20 | invalid_posession = Posession.new(date: Date.today)
21 |
22 | mock_relationships(invalid_posession)
23 | expect(invalid_posession).to_not be_valid
24 | end
25 | end
26 |
27 | context 'given a posession with a date being nil' do
28 | it 'must be invalid' do
29 | invalid_posession = Posession.new(date: Date.today)
30 |
31 | mock_relationships(invalid_posession)
32 | expect(invalid_posession).to_not be_valid
33 | end
34 | end
35 | end
--------------------------------------------------------------------------------
/app/views/cats/new.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
14 |
15 | ## Typography
16 |
17 | Our main typefaces used throughout the web application are:
18 |
19 | - Raleway: used for all titles and body content.
20 | - Zilla slab: used for special titles that need to bring users attention.
21 |
22 | ## Color palette
23 |
24 | 
25 |
26 | ## Covi
27 |
28 | Covi is the main character in the project. He's a super heroe that takes care of the city gardens and protects citizens - with his friends help - from plagues.
29 |
30 |
30 | <%= f.label :current_password %> (we need your current password to confirm your changes)
31 | <%= f.password_field :current_password, autocomplete: "off" %>
32 |
33 |
34 |
35 | <%= f.submit "Update" %>
36 |
37 | <% end %>
38 |
39 |
Cancel my account
40 |
41 |
Unhappy? <%= button_to "Cancel my account", registration_path(resource_name), data: { confirm: "Are you sure?" }, method: :delete %>
42 |
43 | <%= link_to "Back", :back %>
44 |
--------------------------------------------------------------------------------
/docs/home.md:
--------------------------------------------------------------------------------
1 | # Covi Project
2 |
3 | Hey! :wave: Welcome to the **official Covi Project docs**. :books:
4 |
5 | This project aims to introduce people to the situation of cats from
6 | cat colonies 🐱❤️
7 |
8 | This is an application to make easier the work of the volunteers who take care
9 | of street cats, built with all the contributions our collaborators have done
10 | with a lot of effort and with a lot of love. ❤️
11 |
12 | We believe that diversity is a source of wealth in all areas and that is why
13 | we want to **welcome all people**, whatever their, gender, age, experience,
14 | origin, etc. 👱🧔🏽👨🌾👵 Therefore, everyone involved in the community must
15 | comply with our [code of conduct](www.infusionvlc.com/rules). 🖐️
16 |
17 | ## How to Contribute
18 |
19 | Our team is made up of people with very different experiences: developer,
20 | designers and translators. Any help is always welcome and we're always
21 | looking for more people to participate in all our projects.
22 |
23 | You can [send us a message](mailto:hola@infusionvlc.com) and tell us a bit
24 | about yourself and what you want to help us out with. We will send you an
25 | invitation to our team's slack space.
26 |
27 | ## Open Collective
28 |
29 | Many thanks to all the sponsors and sponsors who contribute your bit to
30 | the community! You can also join and help us continue to make use of these projects.
31 |
32 |
33 |
34 | 
35 |
36 |
--------------------------------------------------------------------------------
/docs/installation.md:
--------------------------------------------------------------------------------
1 | # Setting up the development environment
2 |
3 | Hey! :wave: We are so glad you want to help us shape a better future for
4 | street cats. Here you'll find some notes on how to install the web application
5 | on your computer. Let's get started! :rocket:
6 |
7 | ## Installing Ruby on Rails
8 | Please, follow along the instructions for yor OS (**INSTALL POSTGRESQL**)
9 |
10 | https://gorails.com/setup/
11 |
12 | ## Cloning the repo locally
13 | Create a fork of this repo and clone it into your PC:
14 | `git clone https://github.com/your_user/ConexionFelina.git`
15 |
16 | ## Installing bundled gems
17 | Run `bundle install` inside the 'ConexionFelina' app directory.
18 |
19 | ## First run
20 | 1. `rails db:create`
21 | 2. `rails db:migrate`
22 | 3. `rails db:seed`
23 |
24 | If you want to migrate and populate the test database too you should
25 | add `RAILS_ENV=TEST` at the end of the 2º and 3º commands and execute them.
26 |
27 | `rails s`
28 |
29 |
30 | ## Configuring postgresql on linux (ubuntu)
31 | 1. Run `sudo -u postgres createuser --interactive`
32 | Use as username your OS account name
33 | Type "y" to be superuser
34 | 2. Run `sudo -u [your OS account name] createdb conexion_felina_test`
35 |
36 | ## Configuring postgreSQL on Mac OS
37 | 1. `createuser -s -r postgres`
38 |
39 | ## Front-end development Environment
40 |
41 | ### Installing the required tools
42 | - To install Node.js
43 |
44 | `brew install node`
45 |
46 | - To install Yarn
47 |
48 | `brew install yarn`
49 |
50 | - To install Storybook and other dependencies
51 |
52 | `npm install`
53 |
54 | `yarn install`
55 |
56 | Please, checkout our [conventions guidelines](conventions.md) to know more
57 | about our code quality specs and how to run tests.
--------------------------------------------------------------------------------
/app/controllers/treatment_entries_controller.rb:
--------------------------------------------------------------------------------
1 | class TreatmentEntriesController < ApplicationController
2 | def index
3 | suffering_id = params[:suffering_id]
4 | @treatment_entries = TreatmentEntry.where(suffering_id: suffering_id)
5 | end
6 |
7 | def show
8 | treatment_entry_id = params[:id]
9 | @treatment_entry = TreatmentEntry.find(treatment_entry_id)
10 | authorize @treatment_entry
11 | end
12 |
13 | def new
14 | @treatment_entry = TreatmentEntry.new
15 | authorize @treatment_entry
16 | end
17 |
18 | def create
19 | @treatment_entry = TreatmentEntry.new(treatment_entry_params)
20 | @treatment_entry.suffering_id = params[:suffering_id]
21 | authorize @treatment_entry
22 | @treatment_entry.save
23 | redirect_to suffering_path(@treatment_entry.suffering_id)
24 | end
25 |
26 | def edit
27 | @treatment_entry = TreatmentEntry.find(params[:id])
28 | authorize @treatment_entry
29 | end
30 |
31 | def update
32 | @treatment_entry = TreatmentEntry.find(params[:id])
33 | authorize @treatment_entry
34 | @treatment_entry.update(treatment_entry_params)
35 | redirect_to treatment_entries_path(suffering_id: @treatment_entry.suffering_id)
36 | end
37 |
38 | def destroy
39 | @treatment_entry = TreatmentEntry.find(params[:id])
40 | authorize @treatment_entry
41 | @treatment_entry.destroy
42 | redirect_to treatment_entries_path(suffering_id: @treatment_entry.suffering_id)
43 | end
44 |
45 | private
46 |
47 | def user_not_autorized
48 | flash[:alert] = 'You are not autorized to perform this action'
49 | redirect_to treatment_entry_path
50 | end
51 |
52 | def treatment_entry_params
53 | params.require(:treatment_entry).permit(:date, :treatment, :notes, :suffering_id)
54 | end
55 | end
56 |
--------------------------------------------------------------------------------
/docs/learning.md:
--------------------------------------------------------------------------------
1 | # Learning Resources
2 |
3 | Here you can find some useful resources for learning about coding, team-work and testing.
4 | Feel free to open up a PR with your additions :wink:
5 |
6 | ## Git
7 | * [Git handbook](https://guides.github.com/introduction/git-handbook/)
8 | * [Learn Git branching](https://learngitbranching.js.org/)
9 | * [Git cheatsheets](https://services.github.com/on-demand/resources/cheatsheets/)
10 |
11 | ## Team building & communities
12 | * [10 ways to improve your pairing experience](https://www.thoughtworks.com/insights/blog/10-ways-improve-your-pairing-experience)
13 | * [10 commandments of code reviews](https://techbeacon.com/10-commandments-navigating-code-reviews)
14 |
15 | ## Translations
16 | * [Rails internationalization guides](https://guides.rubyonrails.org/i18n.html)
17 |
18 | ## Software Engineering
19 | * [Refactoring by Source Making](https://sourcemaking.com/refactoring)
20 | * [Design patterns by Source Making](https://sourcemaking.com/design_patterns)
21 | * [Clean Code exercises by Upcase](https://thoughtbot.com/upcase/clean-code)
22 |
23 | ## Back-end: Ruby on Rails
24 | * [Rails guides](https://guides.rubyonrails.org/index.html)
25 | * [HTTP, MVC and routes](https://medium.com/the-renaissance-developer/ruby-on-rails-http-mvc-and-routes-f02215a46a84)
26 | * [Rails testing](https://hackernoon.com/your-guide-to-testing-in-ruby-on-rails-5-c8bd122e38ad)
27 | * [Rspec best practices](https://jacopretorius.net/2013/11/rspec-best-practices.html)
28 | * [Better Specs](http://www.betterspecs.org/)
29 |
30 | ## Front-end: React, JS
31 | * [Getting started with React](https://reactjs.org/docs/getting-started.html)
32 | * [Storybook introduction](https://storybook.js.org/basics/introduction/)
33 | * [W3Schools guide on Javascript](https://www.w3schools.com/js/)
34 |
--------------------------------------------------------------------------------
/.idea/ConexionFelina.iml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/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/migrate/20180620160551_add_devise_to_users.rb:
--------------------------------------------------------------------------------
1 | # frozen_string_literal: true
2 |
3 | class AddDeviseToUsers < ActiveRecord::Migration[5.1]
4 | def self.up
5 | change_table :users do |t|
6 | ## Database authenticatable
7 | t.string :email, null: false, default: ""
8 | t.string :encrypted_password, null: false, default: ""
9 |
10 | ## Recoverable
11 | t.string :reset_password_token
12 | t.datetime :reset_password_sent_at
13 |
14 | ## Rememberable
15 | t.datetime :remember_created_at
16 |
17 | ## Trackable
18 | t.integer :sign_in_count, default: 0, null: false
19 | t.datetime :current_sign_in_at
20 | t.datetime :last_sign_in_at
21 | t.inet :current_sign_in_ip
22 | t.inet :last_sign_in_ip
23 |
24 | ## Confirmable
25 | # t.string :confirmation_token
26 | # t.datetime :confirmed_at
27 | # t.datetime :confirmation_sent_at
28 | # t.string :unconfirmed_email # Only if using reconfirmable
29 |
30 | ## Lockable
31 | # t.integer :failed_attempts, default: 0, null: false # Only if lock strategy is :failed_attempts
32 | # t.string :unlock_token # Only if unlock strategy is :email or :both
33 | # t.datetime :locked_at
34 |
35 |
36 | # Uncomment below if timestamps were not included in your original model.
37 | # t.timestamps null: false
38 | end
39 |
40 | add_index :users, :email, unique: true
41 | add_index :users, :reset_password_token, unique: true
42 | # add_index :users, :confirmation_token, unique: true
43 | # add_index :users, :unlock_token, unique: true
44 | end
45 |
46 | def self.down
47 | # By default, we don't want to make any assumption about how to roll back a migration when your
48 | # model already existed. Please edit below which fields you would like to remove in this migration.
49 | raise ActiveRecord::IrreversibleMigration
50 | end
51 | end
52 |
--------------------------------------------------------------------------------
/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/favicon.json:
--------------------------------------------------------------------------------
1 |
2 |
3 | {
4 | "master_picture": "public/logo.png",
5 | "favicon_design": {
6 | "ios": {
7 | "picture_aspect": "background_and_margin",
8 | "background_color": "#ffffff",
9 | "margin": "14%",
10 | "assets": {
11 | "ios6_and_prior_icons": false,
12 | "ios7_and_later_icons": false,
13 | "precomposed_icons": false,
14 | "declare_only_default_icon": true
15 | }
16 | },
17 | "desktop_browser": [
18 |
19 | ],
20 | "windows": {
21 | "picture_aspect": "no_change",
22 | "background_color": "#2d89ef",
23 | "on_conflict": "override",
24 | "assets": {
25 | "windows_80_ie_10_tile": false,
26 | "windows_10_ie_11_edge_tiles": {
27 | "small": false,
28 | "medium": true,
29 | "big": false,
30 | "rectangle": false
31 | }
32 | }
33 | },
34 | "android_chrome": {
35 | "picture_aspect": "no_change",
36 | "theme_color": "#ffffff",
37 | "manifest": {
38 | "display": "standalone",
39 | "orientation": "not_set",
40 | "on_conflict": "override",
41 | "declared": true
42 | },
43 | "assets": {
44 | "legacy_icon": false,
45 | "low_resolution_icons": false
46 | }
47 | },
48 | "safari_pinned_tab": {
49 | "picture_aspect": "black_and_white",
50 | "threshold": 58.59375,
51 | "theme_color": "#5bbad5"
52 | }
53 | },
54 | "settings": {
55 | "scaling_algorithm": "Mitchell",
56 | "error_on_image_too_small": false,
57 | "readme_file": false,
58 | "html_code_file": false,
59 | "use_path_as_is": false
60 | }
61 | }
62 |
63 |
--------------------------------------------------------------------------------
/app/controllers/cats_controller.rb:
--------------------------------------------------------------------------------
1 | class CatsController < ApplicationController
2 | def show
3 | cat_id = params[:id]
4 | @cat = Cat.find(cat_id)
5 | end
6 |
7 | def index
8 | @cats = Cat.all.where(saved_state: 'active')
9 | end
10 |
11 | def new
12 | @cat = Cat.new
13 | authorize @cat
14 | @cat.save
15 | redirect_to cat_build_path(:add_basic_info, cat_id: @cat.id)
16 | end
17 |
18 | def create
19 | @cat = Cat.create(cat_params)
20 | authorize @cat
21 | @cat.save
22 | redirect_to cat_path(@cat)
23 | end
24 |
25 | def edit
26 | @cat = Cat.find(params[:id])
27 | authorize @cat
28 | end
29 |
30 | def update
31 | @cat = Cat.find(params[:id])
32 | authorize @cat
33 | @cat.update(cat_params)
34 | redirect_to cat_path(@cat)
35 | end
36 |
37 | def destroy
38 | @cat = Cat.find(params[:id])
39 | authorize @cat
40 | @cat.destroy
41 | redirect_to cats_path
42 | end
43 |
44 | def adopt
45 | @cat = Cat.find(params[:id])
46 | authorize @cat
47 | Adoption.create(cat_id: @cat.id, user_id: current_user.id)
48 | end
49 |
50 | def new_sponsor
51 | @cat = Cat.find(params[:id])
52 | authorize @cat
53 | end
54 |
55 | def sponsor
56 | cat = Cat.find(params[:id])
57 | renovate = params[:renovate] || false
58 |
59 | authorize cat
60 |
61 | Sponsor.create(amount: params[:amount], renovate: renovate,
62 | last_payment_date: Date.today, start_date: Date.today, user: current_user, cat: cat)
63 |
64 | redirect_to cats_path
65 | end
66 |
67 | private
68 |
69 | def cat_params
70 | params.require(:cat).permit(:name, :bio, :birthday_date, :gender,
71 | :sterilized, :abandoned_date, :document, :colony_id, :saved_state,
72 | sufferings_attributes: [:id, :illness_id, :cat_id, :diagnosis_date, :notes, :chronic, :status, :_destroy])
73 | end
74 |
75 | def user_not_autorized
76 | flash[:alert] = "You are not autorized to perform this action"
77 | redirect_to cats_path
78 | end
79 | end
80 |
--------------------------------------------------------------------------------
/public/top.svg:
--------------------------------------------------------------------------------
1 |
2 |
--------------------------------------------------------------------------------
/app/views/layouts/pages.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | Conexión Felina
5 | <%= csrf_meta_tags %>
6 |
7 |
8 | <%= stylesheet_link_tag 'application', media: 'all', 'data-turbolinks-track': 'reload' %>
9 | <%= javascript_include_tag 'application', 'data-turbolinks-track': 'reload' %>
10 |
11 |
12 |
13 |
14 |
15 |
42 | <%= yield %>
43 |
47 |
48 |
--------------------------------------------------------------------------------
/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 | config.action_mailer.default_url_options = { host: 'localhost', port: 3000 }
52 |
53 | # Use an evented file watcher to asynchronously detect changes in source code,
54 | # routes, locales, etc. This feature depends on the listen gem.
55 | # config.file_watcher = ActiveSupport::EventedFileUpdateChecker
56 | end
57 |
--------------------------------------------------------------------------------
/spec/validators/treatment_entry_validator_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe TreatmentEntryValidator do
4 | def mock_relationships(treatment_entry)
5 | treatment_entry.suffering = mock_model("Suffering")
6 | end
7 |
8 | context "given a suffering with its last date earlier " do
9 | it "must be valid" do
10 | valid_treatment_entry = TreatmentEntry.new(date: Date.new(2001, 2, 3), treatment: 1)
11 | mock_relationships(valid_treatment_entry)
12 |
13 | expect(valid_treatment_entry).to be_valid
14 | end
15 | end
16 |
17 | context "given a date later than today or today" do
18 | it "must be invalid" do
19 | invalid_treatment_entry = TreatmentEntry.new(date: Date.tomorrow, treatment: 1)
20 | mock_relationships(invalid_treatment_entry)
21 |
22 | expect(invalid_treatment_entry).to_not be_valid
23 | end
24 | end
25 |
26 | context "given a notes with an amount bigger than 1024 " do
27 | it "must be invalid" do
28 | invalid_treatment_entry = TreatmentEntry.new(date: Date.yesterday, treatment: 1, notes: "morbi tristique senectus et netus et malesuada fames ac turpis egestas integer eget aliquet nibh praesent tristique magna sit amet purus gravida quis blandit turpis cursus in hac habitasse platea dictumst quisque sagittis purus sit amet volutpat consequat mauris nunc congue nisi vitae suscipit tellus mauris a diam maecenas sed enim ut sem viverra aliquet eget sit amet tellus cras adipiscing enim eu turpis egestas pretium aenean pharetra magna ac placerat vestibulum lectus mauris ultrices eros in cursus turpis massa tincidunt dui ut ornare lectus sit amet est placerat in egestas erat imperdiet sed euismod nisi porta lorem mollis aliquam ut porttitor leo a diam sollicitudin tempor id eu nisl nunc mi ipsum faucibus vitae aliquet nec ullamcorper sit amet risus nullam eget felis eget nunc lobortis mattis aliquam faucibus purus in massa tempor nec feugiat nisl pretium fusce id velit ut tortor pretium viverra suspendisse potenti nullam ac tortor vitae purus faucibus ornare suspendisse sed nisi lacus sed viverra tellus in hac habitasse platea dictumst")
29 | mock_relationships(invalid_treatment_entry)
30 |
31 | expect(invalid_treatment_entry).to_not be_valid
32 | end
33 | end
34 | end
35 |
--------------------------------------------------------------------------------
/app/views/cats/edit.html.erb:
--------------------------------------------------------------------------------
1 |
2 |
59 | <%= link_to_add_association f, :sufferings, class:'btn btn-primary' do %>Add<% end %>
60 |
61 |
62 |
63 |
64 | <%= f.submit %>
65 |
66 | <% end %>
--------------------------------------------------------------------------------
/.circleci/config.yml:
--------------------------------------------------------------------------------
1 | # Ruby CircleCI 2.0 configuration file
2 | #
3 | # Check https://circleci.com/docs/2.0/language-ruby/ for more details
4 | #
5 | version: 2
6 | jobs:
7 | build:
8 | environment:
9 | CC_TEST_REPORTER_ID: bb3d2bcc9ffe079c10061804fc1baf70959b2d1ac5294791085d6e64f44f18a7
10 | docker:
11 | - image: circleci/ruby:2.4.1-node-browsers
12 | environment:
13 | DATABASE_URL: "postgres://conexion_felina@localhost/conexion_felina-test"
14 | PGHOST: 127.0.0.1
15 | PGUSER: root
16 | RAILS_ENV: test
17 | RACK_ENV: test
18 | - image: postgres:9.5-alpine
19 | environment:
20 | POSTGRES_USER: conexion_felina
21 | POSTGRES_DB: conexion_felina-test
22 |
23 | working_directory: ~/conexion_felina
24 |
25 | steps:
26 | - checkout
27 |
28 | # Download and cache dependencies
29 | - restore_cache:
30 | keys:
31 | - v1-dependencies-{{ checksum "Gemfile.lock" }}
32 | # fallback to using the latest cache if no exact match is found
33 | - v1-dependencies-
34 |
35 | - run:
36 | name: install dependencies
37 | command: |
38 | bundle install --jobs=4 --retry=3 --path vendor/bundle
39 |
40 | - save_cache:
41 | paths:
42 | - ./vendor/bundle
43 | key: v1-dependencies-{{ checksum "Gemfile.lock" }}
44 |
45 | # Database setup
46 | - run:
47 | name: setup db
48 | command: |
49 | bundle exec rake db:create
50 | bundle exec rake db:migrate
51 | bundle exec rake db:schema:load
52 |
53 | # setup code climate coverage reporter
54 | - run:
55 | name: Setup Code Climate test-reporter
56 | command: |
57 | curl -L https://codeclimate.com/downloads/test-reporter/test-reporter-latest-linux-amd64 > ./cc-test-reporter
58 | chmod +x ./cc-test-reporter
59 |
60 |
61 | # run tests!
62 | - run:
63 | name: run tests
64 | command: |
65 | bundle exec rails db:seed RAILS_ENV=test
66 | ./cc-test-reporter before-build
67 | rspec
68 | ./cc-test-reporter after-build --exit-code $?
69 |
70 | deployment:
71 | staging:
72 | branch: master
73 | heroku:
74 | appname: conexionfelina
--------------------------------------------------------------------------------
/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 | # Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
9 | gem 'rails', '~> 5.2.3'
10 | # Use postgresql as the database for Active Record
11 | gem 'pg', '>= 0.18', '< 2.0'
12 | # Use Puma as the app server
13 | gem 'puma', '~> 3.7'
14 | # Use SCSS for stylesheets
15 | gem 'sass-rails', '~> 5.0'
16 | # Use Uglifier as compressor for JavaScript assets
17 | gem 'uglifier', '>= 1.3.0'
18 | # See https://github.com/rails/execjs#readme for more supported runtimes
19 | # gem 'therubyracer', platforms: :ruby
20 | gem 'sprockets'
21 | # Use CoffeeScript for .coffee assets and views
22 | gem 'coffee-rails', '~> 4.2'
23 | # Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
24 | gem 'turbolinks', '~> 5'
25 | # Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
26 | gem 'jbuilder', '~> 2.8'
27 | # Use Redis adapter to run Action Cable in production
28 | # gem 'redis', '~> 4.0'
29 | # Use ActiveModel has_secure_password
30 | # gem 'bcrypt', '~> 3.1.7'
31 |
32 | # Use Capistrano for deployment
33 | # gem 'capistrano-rails', group: :development
34 |
35 | gem 'bootstrap', '~> 4.1.0'
36 | gem 'jquery-rails'
37 |
38 | gem 'high_voltage'
39 |
40 | gem 'devise'
41 | gem 'pundit'
42 |
43 | gem 'cocoon'
44 | gem 'wicked'
45 |
46 | group :development, :test do
47 | # Call 'byebug' anywhere in the code to stop execution and get a debugger console
48 | gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
49 | # Adds support for Capybara system testing and selenium driver
50 | gem 'capybara', '~> 3.12'
51 | gem 'selenium-webdriver'
52 | gem 'factory_bot_rails'
53 | gem 'rubocop'
54 | end
55 |
56 | group :development do
57 | # Access an IRB console on exception pages or by using <%= console %> anywhere in the code.
58 | gem 'rails_real_favicon'
59 | gem 'web-console', '>= 3.3.0'
60 | end
61 |
62 | group :test do
63 | gem 'rspec-activemodel-mocks'
64 | gem 'rspec-rails', '~> 3.8'
65 |
66 | gem 'simplecov'
67 | gem 'simplecov-console'
68 |
69 | gem 'rails-controller-testing'
70 | gem 'shoulda-matchers', '4.0.0.rc1'
71 | end
72 |
73 | # Windows does not include zoneinfo files, so bundle the tzinfo-data gem
74 | gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
75 |
--------------------------------------------------------------------------------
/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 |
--------------------------------------------------------------------------------
/spec/validators/cat_validator_spec.rb:
--------------------------------------------------------------------------------
1 | require 'rails_helper'
2 |
3 | LORE_IPSUM_250 = 'Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nullam pretium felis sit amet libero congue, sed bibendum tortor eleifend. Nam imperdiet pellentesque magna, sed consectetur est egestas vitae. Praesent tempus lacus nec finibus tincidunt amet.'
4 | LORE_IPSUM_513 = + LORE_IPSUM_250 + LORE_IPSUM_250 + "1234567890123"
5 |
6 | RSpec.describe Cat, :type => :model do
7 |
8 | def mock_relationships(cat)
9 | cat.colony = mock_model("Colony")
10 | end
11 |
12 | context 'given a cat with only name' do
13 | it 'must be valid' do
14 | valid_cat = Cat.new(name: "Kitty", saved_state: "active")
15 | mock_relationships(valid_cat)
16 | expect(valid_cat).to be_valid
17 | end
18 | end
19 |
20 | context 'given a cat without name' do
21 | it 'must not be valid' do
22 | valid_cat = Cat.new(saved_state: "active")
23 | mock_relationships(valid_cat)
24 | expect(valid_cat).to_not be_valid
25 | end
26 | end
27 |
28 | context 'given a cat with 21 characters name' do
29 | it 'must not be valid' do
30 | valid_cat = Cat.new(name: "123456789012345678901", saved_state: "active")
31 | mock_relationships(valid_cat)
32 | expect(valid_cat).to_not be_valid
33 | end
34 | end
35 |
36 | context 'given a cat with name and bio with 250 words' do
37 | it 'must be valid' do
38 | valid_cat = Cat.new(name: "Kitty", bio: LORE_IPSUM_250, saved_state: "active")
39 | mock_relationships(valid_cat)
40 | expect(valid_cat).to be_valid
41 | end
42 | end
43 |
44 | context 'given a cat with name and bio with 513 words' do
45 | it 'must not be valid' do
46 | valid_cat = Cat.new(name: "Kitty", bio: LORE_IPSUM_513, saved_state: "active")
47 | mock_relationships(valid_cat)
48 | expect(valid_cat).to_not be_valid
49 | end
50 | end
51 |
52 | context 'given a cat with name and birth_date which is yesterday' do
53 | it 'must be valid' do
54 | valid_cat = Cat.new(name: "Kitty", birthday_date: Date.yesterday, saved_state: "active")
55 | mock_relationships(valid_cat)
56 | expect(valid_cat).to be_valid
57 | end
58 | end
59 |
60 | context 'given a cat with name and birth_date which is tomorrow' do
61 | it 'must not be valid' do
62 | valid_cat = Cat.new(name: "Kitty", birthday_date: Date.tomorrow, saved_state: "active")
63 | mock_relationships(valid_cat)
64 | expect(valid_cat).to_not be_valid
65 | end
66 | end
67 |
68 | end
69 |
--------------------------------------------------------------------------------
/docs/conventions.md:
--------------------------------------------------------------------------------
1 | # Development Conentions
2 |
3 | If you've just decided to contribute to the project's codebase, please read our
4 | [installation](installation.md) and [beginner](beginners.md) guides to get started.
5 |
6 | ## Back-end: Ruby on Rails
7 |
8 | ### Code Conventions
9 | We follow recommendations by [Airbnb's ruby style guide](https://github.com/airbnb/ruby).
10 | You may want to use [Rubocop](https://github.com/rubocop-hq/rubocop) as a
11 | static code analyzer to fulfill CodeClimate suggestions.
12 |
13 | ### Automated Testing
14 | We are using [rspec](https://github.com/rspec/rspec-rails) along with
15 | [shoulda-matchers](https://github.com/thoughtbot/shoulda-matchers) for our automated tests.
16 |
17 | You may run all tests by typing:
18 | ```
19 | rspec
20 | ```
21 |
22 | Or a single file:
23 | ```
24 | rspec spec/models/cat_spec.rb
25 | ```
26 |
27 | Or a even a specific block or line in a file:
28 | ```
29 | rspec spec/models/cat_spec.rb:3
30 | ```
31 |
32 | ## Front-end: React
33 |
34 | ### Code Conventions
35 | We are currently developing our front-end views by building
36 | [React](https://reactjs.org/) components along with
37 | [Storybook](https://storybook.js.org/).
38 |
39 | **MAKE SURE YOU DOWNLOAD THE LATEST CHANGES FROM THE `react` BRANCH FIRST**
40 |
41 | - All web UI components can be found at `app/javascript/bundles/UI/components`
42 | - All stories are found at `app/javascript/stories/ui`
43 | - All [Jest](https://jestjs.io/) tests lay on `app/javascript/spec`
44 |
45 | One of our main goals is to stick to
46 | [Airbnb's JavaScript style guide](https://github.com/airbnb/javascript)
47 | to make our code cleaner and clearer.
48 |
49 |
50 | ### Automated Testing
51 | - Install and configuration [here](https://blog.arkency.com/testing-react-dot-js-components-with-jest-in-rails-plus-webpacker-plus-webpack-environment/)
52 | we change the path to `app/javascript/spec`.
53 | - Write your tests in `app/javascript/spec/`. Quick start tutorial [here](https://medium.com/capital-one-developers/unit-testing-behavior-of-react-components-with-test-driven-development-ae15b03a3689)
54 | - You can test a file with `yarn test nameOfFile` for example `yarn test Input.test.js` if the file is in `app/javascript/spec`.
55 | - Or run all test files with `yarn test`.
56 |
57 | ### Component styling
58 | We are currently using CSS components for component styling.
59 | You can check out the following example to get started:
60 |
61 | https://github.com/gajus/react-css-modules#css-modules
62 |
63 | ### Starting storybook
64 | `npm run storybook`
65 |
66 |
--------------------------------------------------------------------------------
/docs/README.md:
--------------------------------------------------------------------------------
1 | [](https://circleci.com/gh/infusionvlc/ConexionFelina) [](https://codeclimate.com/github/infusionvlc/ConexionFelina/maintainability) [](https://hakiri.io/github/infusionvlc/ConexionFelina/master)
2 |
3 | # COVI (Conexión Felina)
4 |
5 | ## Este proyecto tiene como objetivo acercar a las personas la situación de los gatos de las colonias de Viveros 🐱❤️
6 |
7 | Conexión Felina es una aplicación para hacer más fácil la labor de las personas voluntarias que cuidan de los gatos callejeros. Aquí vive todo el trabajo que nuestros colaboradores han hecho con mucho esfuerzo 💪 y, sobretodo, con mucho cariño ❤️.
8 |
9 | En COVI, parte de la comunidad **[INFUSIÓN](http://www.infusionvlc.com)**, creemos que la **diversidad** es una fuente de **riqueza** en todos los ámbitos y por eso queremos visibilizar y acoger a todas las personas, sea cual sea su género, sexo, edad, experiencia, origen, etc 👱🧔🏽👨🌾👵. Por eso, toda persona involucrada en la comunidad debe cumplir nuestro **[código de conducta](http://www.infusionvlc.com/reglas)** 🖐️.
10 |
11 | ## Cómo contribuir
12 | Nuestro equipo está formado por personas con experiencias muy diversas: desde desarrolladores 💻 a diseñadores 🎨 y traductores 💬. **Toda ayuda siempre es bienvenida** y siempre estamos buscando a más gente para participar en todos nuestros proyectos.
13 |
14 | Si te animas, [puedes enviarnos un email](mailto:hola@infusionvlc.com) 📮 y contarnos más sobre ti y en qué quieres echarnos una mano. Te enviaremos una invitación a nuestro equipo de trabajo.
15 |
16 | Si estás interesado/a en colaborar con nosotros en el desarrollo de la web, puedes encontrar las instrucciones en castellano, valenciano e inglés en [nuestra wiki](https://github.com/infusionvlc/ConexionFelina/wiki) 📓.
17 |
18 |
19 | ### Open Collective
20 |
21 | ¡Muchas gracias a todos los backers y los sponsors que aportáis vuestro granito de arena a la comunidad! [Tú también puedes unirte y ayudarnos a continuar haciendo posibles estos proyectos](https://opencollective.com/infusionvlc)
22 |
23 |
24 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | [](https://circleci.com/gh/infusionvlc/ConexionFelina)
2 | [](https://codeclimate.com/github/infusionvlc/ConexionFelina/maintainability)
3 | [](https://codeclimate.com/github/infusionvlc/ConexionFelina/test_coverage)
4 | [](https://hakiri.io/github/infusionvlc/ConexionFelina/master)
5 |
6 |
7 |
8 | # COVI (Conexión Felina)
9 |
10 | Docs: https://infusionvlc.github.io/ConexionFelina/
11 |
12 | ## Este proyecto tiene como objetivo acercar a las personas la situación de los gatos de las colonias de Viveros 🐱❤️
13 |
14 | Conexión Felina es una aplicación para hacer más fácil la labor de las personas voluntarias que cuidan de los gatos callejeros. Aquí vive todo el trabajo que nuestros colaboradores han hecho con mucho esfuerzo 💪 y, sobretodo, con mucho cariño ❤️.
15 |
16 | En COVI, parte de la comunidad **[INFUSIÓN](http://www.infusionvlc.com)**, creemos que la **diversidad** es una fuente de **riqueza** en todos los ámbitos y por eso queremos visibilizar y acoger a todas las personas, sea cual sea su género, sexo, edad, experiencia, origen, etc 👱🧔🏽👨🌾👵 Por eso, toda persona involucrada en la comunidad debe cumplir nuestro **[código de conducta](http://www.infusionvlc.com/reglas)**. 🖐️
17 |
18 | ## Cómo contribuir
19 | Nuestro equipo está formado por personas con experiencias muy diversas: desde desarrolladores 💻 a diseñadores 🎨 y traductores 💬. **Toda ayuda siempre es bienvenida** y siempre estamos buscando a más gente para participar en todos nuestros proyectos.
20 |
21 | Si te animas, [puedes enviarnos un email](mailto:hola@infusionvlc.com) 📮 y contarnos más sobre ti y en qué quieres echarnos una mano. Te enviaremos una invitación a nuestro equipo de trabajo.
22 |
23 | Si estás interesado/a en colaborar con nosotros en el desarrollo de la web, puedes encontrar instrucciones [nuestra wiki](https://github.com/infusionvlc/ConexionFelina/wiki). 📓
24 |
25 |
26 | ### Open Collective
27 |
28 | ¡Muchas gracias a todos los backers y los sponsors que aportáis vuestro granito de arena a la comunidad! [Tú también puedes unirte y ayudarnos a continuar haciendo posibles estos proyectos](https://opencollective.com/infusionvlc)
29 |
30 |
31 |
--------------------------------------------------------------------------------
/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 | require "capybara/rspec"
10 | require 'support/factory_bot'
11 |
12 | Rails.application.load_seed
13 |
14 | include Warden::Test::Helpers
15 |
16 | # Requires supporting ruby files with custom matchers and macros, etc, in
17 | # spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
18 | # run as spec files by default. This means that files in spec/support that end
19 | # in _spec.rb will both be required and run as specs, causing the specs to be
20 | # run twice. It is recommended that you do not name files matching this glob to
21 | # end with _spec.rb. You can configure this pattern with the --pattern
22 | # option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
23 | #
24 | # The following line is provided for convenience purposes. It has the downside
25 | # of increasing the boot-up time by auto-requiring all files in the support
26 | # directory. Alternatively, in the individual `*_spec.rb` files, manually
27 | # require only the support files necessary.
28 | #
29 | Dir[Rails.root.join('spec/support/**/*.rb')].each { |f| require f }
30 |
31 | # Checks for pending migrations and applies them before tests are run.
32 | # If you are not using ActiveRecord, you can remove this line.
33 | ActiveRecord::Migration.maintain_test_schema!
34 |
35 | RSpec.configure do |config|
36 | # Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
37 | config.fixture_path = "#{::Rails.root}/spec/fixtures"
38 |
39 | # If you're not using ActiveRecord, or you'd prefer not to run each of your
40 | # examples within a transaction, remove the following line or assign false
41 | # instead of true.
42 | config.use_transactional_fixtures = true
43 |
44 | # RSpec Rails can automatically mix in different behaviours to your tests
45 | # based on their file location, for example enabling you to call `get` and
46 | # `post` in specs under `spec/controllers`.
47 | #
48 | # You can disable this behaviour by removing the line below, and instead
49 | # explicitly tag your specs with their type, e.g.:
50 | #
51 | # RSpec.describe UsersController, :type => :controller do
52 | # # ...
53 | # end
54 | #
55 | # The different available types are documented in the features, such as in
56 | # https://relishapp.com/rspec/rspec-rails/docs
57 | config.infer_spec_type_from_file_location!
58 |
59 | # Filter lines from Rails gems in backtraces.
60 | config.filter_rails_from_backtrace!
61 | # arbitrary gems may also be filtered via:
62 | # config.filter_gems_from_backtrace("gem name")
63 | end
64 |
65 | Shoulda::Matchers.configure do |config|
66 | config.integrate do |with|
67 | with.test_framework :rspec
68 | with.library :rails
69 | end
70 | end
71 |
--------------------------------------------------------------------------------
/docs/database.md:
--------------------------------------------------------------------------------
1 | # Database Schema
2 |
3 | You can check out the latest schema version on our
4 | [GitHub repo](https://github.com/infusionvlc/ConexionFelina/db/schema.png).
5 |
6 | 
7 |
8 | ---
9 |
10 | ## Class Descriptions
11 |
12 | ## Cat
13 | A Cat object contains all basic information from a real cat.
14 | This cat may be a street cat or even an already adopted cat.
15 |
16 | Notes on some of this model's fields:
17 | * **Gender**: either `:male` or `:female` (or unknown)
18 | * **Sterilized**: either `:yes` or `:no` (or unknown)
19 | * **Document**: chip code or official document for the cat's identification
20 |
21 | ## Colony
22 | A Colony is a collection of [cats](#cat) living in a [location](#location).
23 | Each colony has a list of tasks that volunteers are able to manage and do.
24 | All colonies are independent of the rest and are managed by their volunteers
25 | exclusively.
26 |
27 | ## Location
28 | A Location is a real emplacement where colonies live. This object allows the
29 | application to store spatial information of colonies distribution.
30 |
31 | ## User
32 | Users are objects that let the application store information about real users,
33 | such as their adoptions, messages, tasks, etc.
34 |
35 | Notes on some of this model's fields:
36 | * **Role**: may be `:basic`, `:volunteer` or `:admin`.
37 | More on [user authorization here](pundit.md).
38 | * **Purrs**: amount of points this user has earned by purchasing
39 | [products](#product) or making [donations](#donation).
40 |
41 | ## Task
42 | A Task is some work that volunteers need to get done in a colony. It may be
43 | a one-time task or a recurring one. Tasks are [assigned](#assignment) to
44 | [volunteers](#user). All tasks may have one or more [turns](#turns),
45 | that allow volunteers to set up a responsible person for its execution.
46 |
47 | ## Turn
48 | A Turn has a start date and an end date in which specified [volunteers](#user)
49 | are responsible of the related task.
50 |
51 | ## Assignment
52 | Contains information about which [volunteers](#user) are responsible for a
53 | [task](#task) during a [turn](#turn).
54 |
55 | ## Illness
56 | An Illness contains basic information about a condition any [cat](#cat) may have,
57 | along with a description and some treatment guidelines.
58 |
59 | ## Suffering
60 | A Suffering specifiecs which [illness](#illness) a [cat](#cat) has got.
61 | It also contains a diagnosis date and a dischargement date, along with some notes.
62 | There's also a `chronic` field in case the condition may not be recoverable.
63 |
64 | ## Treatment Entry
65 | A Treatment Entry logs any action taken to combat a [suffering](#suffering)
66 | from a cat.
67 |
68 | ## Adoption
69 | An Adoption holds the date a [cat](#cat) was adopted by a [user](#user).
70 |
71 | ## Sponsor (sponsorship)
72 | Any [user](#user) is able to sponsor a [cat](#cat) by making a monthly donation
73 | to support a [**colony**](#colony). Volunteers will send them back updates and photos about their
74 | sponsored cat's life.
75 |
76 | Notes on some of this model's fields:
77 | * **Renovate**: a `boolean` field that stores if a sponsorhip
78 |
79 | ## Donation
80 | A Donation object holds any amount of money a [user](#user) has donated to the **project**.
81 |
82 | ## Work in progress...
83 | We're still defining how the store and chats will work...
--------------------------------------------------------------------------------
/spec/validators/suffering_validator_spec.rb:
--------------------------------------------------------------------------------
1 | require "rails_helper"
2 |
3 | RSpec.describe SufferingValidator do
4 | def mock_relationships(suffering)
5 | suffering.cat = mock_model("Cat")
6 | suffering.illness = mock_model("Illness")
7 | end
8 |
9 | context 'when a suffering for a healty cat is created' do
10 | it 'should be valid with a status other than healthy and a dischargement date' do
11 | valid_suffering = Suffering.new(diagnosis_date: Date.today, notes: '', chronic: false, status: 0, dischargement_date: Date.today)
12 | mock_relationships(valid_suffering)
13 | expect(valid_suffering).to be_valid
14 | end
15 |
16 | it 'should not be valid with a healthy status and an empty dischargement date' do
17 | valid_suffering = Suffering.new(diagnosis_date: Date.today, notes: '', chronic: false, status: 4, dischargement_date: nil)
18 | mock_relationships(valid_suffering)
19 | expect(valid_suffering).to_not be_valid
20 | end
21 |
22 | it 'should be valid with a healthy status and an dischargement date' do
23 | valid_suffering = Suffering.new(diagnosis_date: Date.today, notes: '', chronic: false, status: 4, dischargement_date: Date.today)
24 | mock_relationships(valid_suffering)
25 | expect(valid_suffering).to be_valid
26 | end
27 |
28 | it 'should be valid with a status other than healthy and an empty dischargement date' do
29 | valid_suffering = Suffering.new(diagnosis_date: Date.today, notes: '', chronic: false, status: 0, dischargement_date: nil)
30 | mock_relationships(valid_suffering)
31 | expect(valid_suffering).to be_valid
32 | end
33 |
34 | it 'should not be valid with a nil status and a nil dischargement_date' do
35 | valid_suffering = Suffering.new(diagnosis_date: Date.today, notes: '', chronic: false, status: nil, dischargement_date: nil)
36 | mock_relationships(valid_suffering)
37 | expect(valid_suffering).to_not be_valid
38 | end
39 |
40 | it 'should not be valid with a nil status and a dischargement_date' do
41 | valid_suffering = Suffering.new(diagnosis_date: Date.today, notes: '', chronic: false, status: nil, dischargement_date: Date.today)
42 | mock_relationships(valid_suffering)
43 | expect(valid_suffering).to_not be_valid
44 | end
45 | end
46 |
47 | context "given a suffering with a diagnosis date earlier than today" do
48 | it "must be valid" do
49 | valid_suffering = Suffering.new(diagnosis_date: Date.yesterday, notes: '', chronic: false, status: 4, dischargement_date: Date.today)
50 | mock_relationships(valid_suffering)
51 | expect(valid_suffering).to be_valid
52 | end
53 | end
54 |
55 | context "given a suffering with a diagnosis date equal to today" do
56 | it "must be valid" do
57 | valid_suffering = Suffering.new(diagnosis_date: Date.today, notes: '', chronic: false, status: 4, dischargement_date: Date.today)
58 | mock_relationships(valid_suffering)
59 |
60 | expect(valid_suffering).to be_valid
61 | end
62 | end
63 |
64 | context "given a suffering with a diagnosis date later than today" do
65 | it "must be invalid" do
66 | invalid_suffering = Suffering.new(diagnosis_date: Date.tomorrow)
67 | mock_relationships(invalid_suffering)
68 |
69 | expect(invalid_suffering).to_not be_valid
70 | end
71 | end
72 | end
73 |
--------------------------------------------------------------------------------
/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: conexion_felina_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: postgres
33 |
34 | # The password associated with the postgres role (username).
35 | password: postgres
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: conexion_felina_test
61 | username: postgres
62 | password: postgres
63 |
64 | # As with config/secrets.yml, you never want to store sensitive information,
65 | # like your database password, in your source code. If your source code is
66 | # ever seen by anyone, they now have access to your database.
67 | #
68 | # Instead, provide the password as a unix environment variable when you boot
69 | # the app. Read http://guides.rubyonrails.org/configuring.html#configuring-a-database
70 | # for a full rundown on how to provide these environment variables in a
71 | # production deployment.
72 | #
73 | # On Heroku and other platform providers, you may have a full connection URL
74 | # available as an environment variable. For example:
75 | #
76 | # DATABASE_URL="postgres://myuser:mypass@localhost/somedatabase"
77 | #
78 | # You can use this database configuration with:
79 | #
80 | # production:
81 | # url: <%= ENV['DATABASE_URL'] %>
82 | #
83 | production:
84 | <<: *default
85 | database: conexion_felina_production
86 | username: conexion_felina
87 | password: <%= ENV['CONEXION_FELINA_DATABASE_PASSWORD'] %>
88 |
--------------------------------------------------------------------------------
/public/instagram.svg:
--------------------------------------------------------------------------------
1 |
2 |
58 |
--------------------------------------------------------------------------------