mirror of
https://github.com/Evolix/chexpire.git
synced 2024-05-15 15:08:38 +02:00
Create resource Checks
This commit is contained in:
parent
747f63bea1
commit
8f3cf9f56b
2
app/helpers/checks_helper.rb
Normal file
2
app/helpers/checks_helper.rb
Normal file
|
@ -0,0 +1,2 @@
|
||||||
|
module ChecksHelper
|
||||||
|
end
|
43
app/models/check.rb
Normal file
43
app/models/check.rb
Normal file
|
@ -0,0 +1,43 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: checks
|
||||||
|
#
|
||||||
|
# id :bigint(8) not null, primary key
|
||||||
|
# active :boolean default(TRUE), not null
|
||||||
|
# comment :string(255)
|
||||||
|
# domain :string(255) not null
|
||||||
|
# domain_created_at :datetime
|
||||||
|
# domain_expire_at :datetime
|
||||||
|
# domain_updated_at :datetime
|
||||||
|
# kind :integer not null
|
||||||
|
# last_run_at :datetime
|
||||||
|
# last_success_at :datetime
|
||||||
|
# vendor :string(255)
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# user_id :bigint(8)
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_checks_on_user_id (user_id)
|
||||||
|
#
|
||||||
|
# Foreign Keys
|
||||||
|
#
|
||||||
|
# fk_rails_... (user_id => users.id)
|
||||||
|
#
|
||||||
|
|
||||||
|
class Check < ApplicationRecord
|
||||||
|
belongs_to :user
|
||||||
|
|
||||||
|
enum kind: [:domain, :ssl]
|
||||||
|
|
||||||
|
self.skip_time_zone_conversion_for_attributes = [
|
||||||
|
:domain_created_at,
|
||||||
|
:domain_updated_at,
|
||||||
|
:domain_expire_at,
|
||||||
|
]
|
||||||
|
|
||||||
|
validates :kind, presence: true
|
||||||
|
validates :domain, presence: true
|
||||||
|
validates :active, presence: true
|
||||||
|
end
|
|
@ -35,5 +35,6 @@ class User < ApplicationRecord
|
||||||
devise :database_authenticatable, :registerable,
|
devise :database_authenticatable, :registerable,
|
||||||
:recoverable, :rememberable, :validatable, :confirmable
|
:recoverable, :rememberable, :validatable, :confirmable
|
||||||
|
|
||||||
|
has_many :checks
|
||||||
validates :tos_accepted, acceptance: true
|
validates :tos_accepted, acceptance: true
|
||||||
end
|
end
|
||||||
|
|
19
db/migrate/20180529092950_create_checks.rb
Normal file
19
db/migrate/20180529092950_create_checks.rb
Normal file
|
@ -0,0 +1,19 @@
|
||||||
|
class CreateChecks < ActiveRecord::Migration[5.2]
|
||||||
|
def change
|
||||||
|
create_table :checks do |t|
|
||||||
|
t.references :user, foreign_key: true
|
||||||
|
t.integer :kind, null: false
|
||||||
|
t.string :domain, null: false
|
||||||
|
t.datetime :domain_created_at
|
||||||
|
t.datetime :domain_updated_at
|
||||||
|
t.datetime :domain_expire_at
|
||||||
|
t.datetime :last_run_at
|
||||||
|
t.datetime :last_success_at
|
||||||
|
t.string :vendor
|
||||||
|
t.string :comment
|
||||||
|
t.boolean :active, default: true, null: false
|
||||||
|
|
||||||
|
t.timestamps
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
20
db/schema.rb
20
db/schema.rb
|
@ -10,7 +10,24 @@
|
||||||
#
|
#
|
||||||
# It's strongly recommended that you check this file into your version control system.
|
# It's strongly recommended that you check this file into your version control system.
|
||||||
|
|
||||||
ActiveRecord::Schema.define(version: 2018_05_24_205809) do
|
ActiveRecord::Schema.define(version: 2018_05_29_092950) do
|
||||||
|
|
||||||
|
create_table "checks", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||||
|
t.bigint "user_id"
|
||||||
|
t.integer "kind", null: false
|
||||||
|
t.string "domain", null: false
|
||||||
|
t.datetime "domain_created_at"
|
||||||
|
t.datetime "domain_updated_at"
|
||||||
|
t.datetime "domain_expire_at"
|
||||||
|
t.datetime "last_run_at"
|
||||||
|
t.datetime "last_success_at"
|
||||||
|
t.string "vendor"
|
||||||
|
t.string "comment"
|
||||||
|
t.boolean "active", default: true, null: false
|
||||||
|
t.datetime "created_at", null: false
|
||||||
|
t.datetime "updated_at", null: false
|
||||||
|
t.index ["user_id"], name: "index_checks_on_user_id"
|
||||||
|
end
|
||||||
|
|
||||||
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
create_table "users", options: "ENGINE=InnoDB DEFAULT CHARSET=utf8", force: :cascade do |t|
|
||||||
t.string "email", default: "", null: false
|
t.string "email", default: "", null: false
|
||||||
|
@ -36,4 +53,5 @@ ActiveRecord::Schema.define(version: 2018_05_24_205809) do
|
||||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||||
end
|
end
|
||||||
|
|
||||||
|
add_foreign_key "checks", "users"
|
||||||
end
|
end
|
||||||
|
|
7
test/controllers/checks_controller_test.rb
Normal file
7
test/controllers/checks_controller_test.rb
Normal file
|
@ -0,0 +1,7 @@
|
||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class ChecksControllerTest < ActionDispatch::IntegrationTest
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
55
test/fixtures/checks.yml
vendored
Normal file
55
test/fixtures/checks.yml
vendored
Normal file
|
@ -0,0 +1,55 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: checks
|
||||||
|
#
|
||||||
|
# id :bigint(8) not null, primary key
|
||||||
|
# active :boolean default(TRUE), not null
|
||||||
|
# comment :string(255)
|
||||||
|
# domain :string(255) not null
|
||||||
|
# domain_created_at :datetime
|
||||||
|
# domain_expire_at :datetime
|
||||||
|
# domain_updated_at :datetime
|
||||||
|
# kind :integer not null
|
||||||
|
# last_run_at :datetime
|
||||||
|
# last_success_at :datetime
|
||||||
|
# vendor :string(255)
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# user_id :bigint(8)
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_checks_on_user_id (user_id)
|
||||||
|
#
|
||||||
|
# Foreign Keys
|
||||||
|
#
|
||||||
|
# fk_rails_... (user_id => users.id)
|
||||||
|
#
|
||||||
|
|
||||||
|
# Read about fixtures at http://api.rubyonrails.org/classes/ActiveRecord/FixtureSet.html
|
||||||
|
|
||||||
|
domain_example_org:
|
||||||
|
user: user1
|
||||||
|
kind: domain
|
||||||
|
domain: example.org
|
||||||
|
domain_created_at: 2017-03-01 17:29:50
|
||||||
|
domain_updated_at: 2018-02-15 12:10:00
|
||||||
|
domain_expire_at: 2019-03-01 17:29:49
|
||||||
|
last_run_at: 2018-05-24 17:29:50
|
||||||
|
last_success_at: 2018-05-24 17:29:50
|
||||||
|
vendor: ""
|
||||||
|
comment: ""
|
||||||
|
active: true
|
||||||
|
|
||||||
|
ssl_www_example_org:
|
||||||
|
user: user1
|
||||||
|
kind: ssl
|
||||||
|
domain: www.example.org
|
||||||
|
domain_created_at: 2018-05-24 17:29:50
|
||||||
|
domain_updated_at: 2018-05-24 17:29:50
|
||||||
|
domain_expire_at: 2019-05-24 17:29:49
|
||||||
|
last_run_at: 2018-05-24 17:29:50
|
||||||
|
last_success_at: 2018-05-24 17:29:50
|
||||||
|
vendor: ""
|
||||||
|
comment: "MyString"
|
||||||
|
active: true
|
35
test/models/check_test.rb
Normal file
35
test/models/check_test.rb
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
# == Schema Information
|
||||||
|
#
|
||||||
|
# Table name: checks
|
||||||
|
#
|
||||||
|
# id :bigint(8) not null, primary key
|
||||||
|
# active :boolean default(TRUE), not null
|
||||||
|
# comment :string(255)
|
||||||
|
# domain :string(255) not null
|
||||||
|
# domain_created_at :datetime
|
||||||
|
# domain_expire_at :datetime
|
||||||
|
# domain_updated_at :datetime
|
||||||
|
# kind :integer not null
|
||||||
|
# last_run_at :datetime
|
||||||
|
# last_success_at :datetime
|
||||||
|
# vendor :string(255)
|
||||||
|
# created_at :datetime not null
|
||||||
|
# updated_at :datetime not null
|
||||||
|
# user_id :bigint(8)
|
||||||
|
#
|
||||||
|
# Indexes
|
||||||
|
#
|
||||||
|
# index_checks_on_user_id (user_id)
|
||||||
|
#
|
||||||
|
# Foreign Keys
|
||||||
|
#
|
||||||
|
# fk_rails_... (user_id => users.id)
|
||||||
|
#
|
||||||
|
|
||||||
|
require "test_helper"
|
||||||
|
|
||||||
|
class CheckTest < ActiveSupport::TestCase
|
||||||
|
# test "the truth" do
|
||||||
|
# assert true
|
||||||
|
# end
|
||||||
|
end
|
Loading…
Reference in a new issue