Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Development #4

Open
wants to merge 15 commits into
base: main
Choose a base branch
from
Open

Development #4

wants to merge 15 commits into from

Conversation

VasylShevchenko
Copy link
Collaborator

No description provided.

@VasylShevchenko VasylShevchenko requested a review from sveredyuk July 6, 2021 14:59
README.md Outdated
config/initializers/ez_status.rb
```ruby
# Backend adapter to store all status
config.backend = Ez::Status::Store.new
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove

Copy link
Contributor

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

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

self.table_name = Ez::Status.config.active_record_table_name

validates :name, presence: true
validates :result, presence: false
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

remove presence false

Copy link
Collaborator Author

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
Copy link
Contributor

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

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done


module Ez
module Status
class Status < ApplicationRecord
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

class Record

Copy link
Collaborator Author

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
Copy link
Contributor

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

Copy link
Collaborator Author

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
Copy link
Contributor

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

Copy link
Collaborator Author

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
Copy link
Contributor

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

Copy link
Collaborator Author

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,]
Copy link
Contributor

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)
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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
Copy link
Contributor

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)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  • check Record model data.

Copy link
Contributor

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: '',
  ),
])

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

2 participants