-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Development #4
base: main
Are you sure you want to change the base?
Development #4
Conversation
README.md
Outdated
config/initializers/ez_status.rb | ||
```ruby | ||
# Backend adapter to store all status | ||
config.backend = Ez::Status::Store.new |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
# We need a method for capturing current monitor metrics
Ez::Status.capture! # => insert_all metrics monitors
# + add readme
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
app/models/ez/status/status.rb
Outdated
self.table_name = Ez::Status.config.active_record_table_name | ||
|
||
validates :name, presence: true | ||
validates :result, presence: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove presence false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
remove
lib/ez/status.rb
Outdated
config.basic_auth_credentials = {} | ||
|
||
config.active_record_table_name = nil |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config.active_record_table_name = :ez_status_records
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
app/models/ez/status/status.rb
Outdated
|
||
module Ez | ||
module Status | ||
class Status < ApplicationRecord |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
class Record
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
"class Create#{table_name.to_s.classify} < ActiveRecord::Migration[#{ActiveRecord::Migration.current_version}] | ||
def change | ||
create_table :#{table_name.to_s.underscore} do |t| | ||
t.string :name, null: false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.string :monitor_name, null: false
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
def change | ||
create_table :#{table_name.to_s.underscore} do |t| | ||
t.string :name, null: false | ||
t.string :result, null: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.boolean :result, null: true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
t.string :name, null: false | ||
t.string :result, null: true | ||
t.string :message, null: true | ||
t.string :value, null: true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
t.bigint :value, null: true
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
done
|
||
```ruby | ||
# Order columns and which columns need to show | ||
config.columns = [:message, :value, :result, :monitor_name,] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
config. ui_columns
@@ -17,6 +17,11 @@ def css_for(item) | |||
custom_css_map[scoped_item] || scoped_item | |||
end | |||
|
|||
def css_for_column_name(item) | |||
item.gsub!(/_/, '-') | |||
css_for(item) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
css_for(item.gsub(/_/, '-'))
context 'when default' do | ||
before { visit '/status' } | ||
|
||
it 'decorate DOM with ez-status classes' do | ||
xit 'should default order' do |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
before { visit '/status' } | ||
|
||
xit 'should correct custom order' do | ||
# expect(page.body).to match order |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
around do |spec| | ||
Ez::Status.config.columns = %i[result monitor_name] | ||
spec.run | ||
Ez::Status.config.columns = Ez::Status::DEFAULT_COLUMNS |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
around do |spec|
stub_config(:columns, %i[result monitor_name], &spec.run)
end
# support
def stub_config(config_key, values, &block)
prev_values = Ez::Status.config.public_send(config_key)
Ez::Status.config.public_send("#{config_key}=", values)
block.call
Ez::Status.config.public_send("#{config_key}=", prev_values)
end
|
||
describe 'capture!' do | ||
it 'saves results to DB' do | ||
expect(Ez::Status::Records.count).to be 0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect { capture }.to change { Ez::Status::Records.count }.from(0).to(2)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- check Record model data.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
expect(Ez::Status::Records.all).to match_array([
have_attributes(
monitor: '',
),
have_attributes(
monitor: '',
),
])
No description provided.