New Checkpoint model. Update factories. Model specs.
This commit is contained in:
@@ -20,6 +20,7 @@ class Budget
|
||||
has_many :valuator_assignments, dependent: :destroy
|
||||
has_many :valuators, through: :valuator_assignments
|
||||
has_many :comments, as: :commentable
|
||||
has_many :checkpoints
|
||||
|
||||
validates :title, presence: true
|
||||
validates :author, presence: true
|
||||
|
||||
10
app/models/budget/investment/checkpoint.rb
Normal file
10
app/models/budget/investment/checkpoint.rb
Normal file
@@ -0,0 +1,10 @@
|
||||
class Budget
|
||||
class Investment
|
||||
class Checkpoint < ActiveRecord::Base
|
||||
belongs_to :investment
|
||||
|
||||
validates :title, presence: true
|
||||
validates :investment, presence: true
|
||||
end
|
||||
end
|
||||
end
|
||||
@@ -0,0 +1,11 @@
|
||||
class CreateBudgetInvestmentCheckpoints < ActiveRecord::Migration
|
||||
def change
|
||||
create_table :budget_investment_checkpoints do |t|
|
||||
t.integer :investment_id
|
||||
t.string "title", limit: 80
|
||||
t.text "description"
|
||||
|
||||
t.timestamps null: false
|
||||
end
|
||||
end
|
||||
end
|
||||
12
db/schema.rb
12
db/schema.rb
@@ -11,7 +11,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 20170613203256) do
|
||||
ActiveRecord::Schema.define(version: 20170620132731) do
|
||||
|
||||
# These are extensions that must be enabled in order to support this database
|
||||
enable_extension "plpgsql"
|
||||
@@ -114,6 +114,14 @@ ActiveRecord::Schema.define(version: 20170613203256) do
|
||||
|
||||
add_index "budget_headings", ["group_id"], name: "index_budget_headings_on_group_id", using: :btree
|
||||
|
||||
create_table "budget_investment_checkpoints", force: :cascade do |t|
|
||||
t.integer "investment_id"
|
||||
t.string "title", limit: 80
|
||||
t.text "description"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
end
|
||||
|
||||
create_table "budget_investments", force: :cascade do |t|
|
||||
t.integer "author_id"
|
||||
t.integer "administrator_id"
|
||||
@@ -924,7 +932,7 @@ ActiveRecord::Schema.define(version: 20170613203256) do
|
||||
t.boolean "email_digest", default: true
|
||||
t.boolean "email_on_direct_message", default: true
|
||||
t.boolean "official_position_badge", default: false
|
||||
t.datetime "password_changed_at", default: '2016-12-21 17:55:08', null: false
|
||||
t.datetime "password_changed_at", default: '2017-06-20 13:30:34', null: false
|
||||
t.boolean "created_from_signature", default: false
|
||||
t.integer "failed_email_digests_count", default: 0
|
||||
t.text "former_users_data_log", default: ""
|
||||
|
||||
@@ -322,6 +322,12 @@ FactoryGirl.define do
|
||||
reason "unfeasible"
|
||||
end
|
||||
|
||||
factory :budget_investment_checkpoint, class: 'Budget::Investment::Checkpoint' do
|
||||
association :investment, factory: :budget_investment
|
||||
sequence(:title) { |n| "Budget Investment Checkpoint #{n} title" }
|
||||
description 'Checkpoint description'
|
||||
end
|
||||
|
||||
factory :vote do
|
||||
association :votable, factory: :debate
|
||||
association :voter, factory: :user
|
||||
|
||||
23
spec/models/budget/investment/checkpoint_spec.rb
Normal file
23
spec/models/budget/investment/checkpoint_spec.rb
Normal file
@@ -0,0 +1,23 @@
|
||||
require 'rails_helper'
|
||||
|
||||
describe "Budget::Investment::Checkpoint" do
|
||||
|
||||
describe "Validations" do
|
||||
let(:checkpoint) { build(:budget_investment_checkpoint) }
|
||||
|
||||
it "should be valid" do
|
||||
expect(checkpoint).to be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without a title" do
|
||||
checkpoint.title = nil
|
||||
expect(checkpoint).to_not be_valid
|
||||
end
|
||||
|
||||
it "should not be valid without an investment" do
|
||||
checkpoint.investment_id = nil
|
||||
expect(checkpoint).to_not be_valid
|
||||
end
|
||||
end
|
||||
|
||||
end
|
||||
@@ -486,7 +486,6 @@ describe Budget::Investment do
|
||||
|
||||
end
|
||||
|
||||
|
||||
describe 'Permissions' do
|
||||
let(:budget) { create(:budget) }
|
||||
let(:group) { create(:budget_group, budget: budget) }
|
||||
|
||||
Reference in New Issue
Block a user