firetail 0.0.1.pre.alpha → 1.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +11 -0
- data/.gitignore +13 -13
- data/Gemfile +1 -1
- data/Gemfile.lock +8 -6
- data/README.md +24 -10
- data/examples/rails/.gitattributes +8 -0
- data/examples/rails/.gitignore +31 -0
- data/examples/rails/.rspec +1 -0
- data/examples/rails/.ruby-version +1 -0
- data/examples/rails/Gemfile +44 -0
- data/examples/rails/Gemfile.lock +240 -0
- data/examples/rails/README.md +24 -0
- data/examples/rails/Rakefile +6 -0
- data/examples/rails/app/channels/application_cable/channel.rb +4 -0
- data/examples/rails/app/channels/application_cable/connection.rb +4 -0
- data/examples/rails/app/controllers/application_controller.rb +2 -0
- data/examples/rails/app/controllers/comments_controller.rb +52 -0
- data/examples/rails/app/controllers/concerns/.keep +0 -0
- data/examples/rails/app/controllers/posts_controller.rb +51 -0
- data/examples/rails/app/jobs/application_job.rb +7 -0
- data/examples/rails/app/mailers/application_mailer.rb +4 -0
- data/examples/rails/app/models/application_record.rb +3 -0
- data/examples/rails/app/models/comment.rb +4 -0
- data/examples/rails/app/models/concerns/.keep +0 -0
- data/examples/rails/app/models/post.rb +5 -0
- data/examples/rails/app/views/layouts/mailer.html.erb +13 -0
- data/examples/rails/app/views/layouts/mailer.text.erb +1 -0
- data/examples/rails/bin/bundle +114 -0
- data/examples/rails/bin/rails +5 -0
- data/examples/rails/bin/rake +5 -0
- data/examples/rails/bin/setup +33 -0
- data/examples/rails/bin/spring +14 -0
- data/examples/rails/config/application.rb +41 -0
- data/examples/rails/config/boot.rb +4 -0
- data/examples/rails/config/cable.yml +10 -0
- data/examples/rails/config/credentials.yml.enc +1 -0
- data/examples/rails/config/database.yml +25 -0
- data/examples/rails/config/environment.rb +5 -0
- data/examples/rails/config/environments/development.rb +66 -0
- data/examples/rails/config/environments/production.rb +113 -0
- data/examples/rails/config/environments/test.rb +60 -0
- data/examples/rails/config/firetail.yml +2 -0
- data/examples/rails/config/initializers/application_controller_renderer.rb +8 -0
- data/examples/rails/config/initializers/backtrace_silencers.rb +8 -0
- data/examples/rails/config/initializers/cors.rb +16 -0
- data/examples/rails/config/initializers/filter_parameter_logging.rb +6 -0
- data/examples/rails/config/initializers/inflections.rb +16 -0
- data/examples/rails/config/initializers/mime_types.rb +4 -0
- data/examples/rails/config/initializers/wrap_parameters.rb +14 -0
- data/examples/rails/config/locales/en.yml +33 -0
- data/examples/rails/config/puma.rb +43 -0
- data/examples/rails/config/routes.rb +6 -0
- data/examples/rails/config/schema.json +431 -0
- data/examples/rails/config/spring.rb +6 -0
- data/examples/rails/config/storage.yml +34 -0
- data/examples/rails/config.ru +6 -0
- data/examples/rails/db/migrate/20230730163722_create_posts.rb +8 -0
- data/examples/rails/db/migrate/20230730163741_create_comments.rb +9 -0
- data/examples/rails/db/migrate/20230730164121_add_fields_to_post.rb +6 -0
- data/examples/rails/db/migrate/20230730164214_add_fields_to_comments.rb +6 -0
- data/examples/rails/db/schema.rb +30 -0
- data/examples/rails/db/seeds.rb +7 -0
- data/examples/rails/lib/tasks/.keep +0 -0
- data/examples/rails/log/.keep +0 -0
- data/examples/rails/public/robots.txt +1 -0
- data/examples/rails/spec/models/comment_spec.rb +5 -0
- data/examples/rails/spec/models/post_spec.rb +5 -0
- data/examples/rails/spec/rails_helper.rb +63 -0
- data/examples/rails/spec/requests/comments_spec.rb +127 -0
- data/examples/rails/spec/requests/posts_spec.rb +127 -0
- data/examples/rails/spec/routing/comments_routing_spec.rb +30 -0
- data/examples/rails/spec/routing/posts_routing_spec.rb +30 -0
- data/examples/rails/spec/spec_helper.rb +94 -0
- data/examples/rails/storage/.keep +0 -0
- data/examples/rails/test/channels/application_cable/connection_test.rb +11 -0
- data/examples/rails/test/controllers/.keep +0 -0
- data/examples/rails/test/fixtures/files/.keep +0 -0
- data/examples/rails/test/integration/.keep +0 -0
- data/examples/rails/test/mailers/.keep +0 -0
- data/examples/rails/test/models/.keep +0 -0
- data/examples/rails/test/test_helper.rb +13 -0
- data/examples/rails/tmp/.keep +0 -0
- data/examples/rails/tmp/pids/.keep +0 -0
- data/examples/rails/vendor/.keep +0 -0
- data/firetail.gemspec +1 -1
- data/lib/backend.rb +0 -3
- data/lib/firetail/version.rb +1 -1
- data/lib/firetail.rb +2 -5
- data/lib/generators/firetail/install/templates/firetail.yml +2 -2
- data/lib/railtie.rb +3 -4
- metadata +90 -10
|
@@ -0,0 +1,63 @@
|
|
|
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_relative '../config/environment'
|
|
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
|
+
|
|
10
|
+
# Requires supporting ruby files with custom matchers and macros, etc, in
|
|
11
|
+
# spec/support/ and its subdirectories. Files matching `spec/**/*_spec.rb` are
|
|
12
|
+
# run as spec files by default. This means that files in spec/support that end
|
|
13
|
+
# in _spec.rb will both be required and run as specs, causing the specs to be
|
|
14
|
+
# run twice. It is recommended that you do not name files matching this glob to
|
|
15
|
+
# end with _spec.rb. You can configure this pattern with the --pattern
|
|
16
|
+
# option on the command line or in ~/.rspec, .rspec or `.rspec-local`.
|
|
17
|
+
#
|
|
18
|
+
# The following line is provided for convenience purposes. It has the downside
|
|
19
|
+
# of increasing the boot-up time by auto-requiring all files in the support
|
|
20
|
+
# directory. Alternatively, in the individual `*_spec.rb` files, manually
|
|
21
|
+
# require only the support files necessary.
|
|
22
|
+
#
|
|
23
|
+
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
|
|
24
|
+
|
|
25
|
+
# Checks for pending migrations and applies them before tests are run.
|
|
26
|
+
# If you are not using ActiveRecord, you can remove these lines.
|
|
27
|
+
begin
|
|
28
|
+
ActiveRecord::Migration.maintain_test_schema!
|
|
29
|
+
rescue ActiveRecord::PendingMigrationError => e
|
|
30
|
+
abort e.to_s.strip
|
|
31
|
+
end
|
|
32
|
+
RSpec.configure do |config|
|
|
33
|
+
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures
|
|
34
|
+
config.fixture_path = "#{::Rails.root}/spec/fixtures"
|
|
35
|
+
|
|
36
|
+
# If you're not using ActiveRecord, or you'd prefer not to run each of your
|
|
37
|
+
# examples within a transaction, remove the following line or assign false
|
|
38
|
+
# instead of true.
|
|
39
|
+
config.use_transactional_fixtures = true
|
|
40
|
+
|
|
41
|
+
# You can uncomment this line to turn off ActiveRecord support entirely.
|
|
42
|
+
# config.use_active_record = false
|
|
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://rspec.info/features/6-0/rspec-rails
|
|
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
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
|
4
|
+
# It demonstrates how one might use RSpec to test the controller code that
|
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
|
6
|
+
#
|
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
|
9
|
+
# controller code, this generated spec may or may not pass.
|
|
10
|
+
#
|
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
|
14
|
+
|
|
15
|
+
RSpec.describe "/comments", type: :request do
|
|
16
|
+
# This should return the minimal set of attributes required to create a valid
|
|
17
|
+
# Comment. As you add validations to Comment, be sure to
|
|
18
|
+
# adjust the attributes here as well.
|
|
19
|
+
let(:valid_attributes) {
|
|
20
|
+
skip("Add a hash of attributes valid for your model")
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let(:invalid_attributes) {
|
|
24
|
+
skip("Add a hash of attributes invalid for your model")
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# This should return the minimal set of values that should be in the headers
|
|
28
|
+
# in order to pass any filters (e.g. authentication) defined in
|
|
29
|
+
# CommentsController, or in your router and rack
|
|
30
|
+
# middleware. Be sure to keep this updated too.
|
|
31
|
+
let(:valid_headers) {
|
|
32
|
+
{}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe "GET /index" do
|
|
36
|
+
it "renders a successful response" do
|
|
37
|
+
Comment.create! valid_attributes
|
|
38
|
+
get comments_url, headers: valid_headers, as: :json
|
|
39
|
+
expect(response).to be_successful
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe "GET /show" do
|
|
44
|
+
it "renders a successful response" do
|
|
45
|
+
comment = Comment.create! valid_attributes
|
|
46
|
+
get comment_url(comment), as: :json
|
|
47
|
+
expect(response).to be_successful
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe "POST /create" do
|
|
52
|
+
context "with valid parameters" do
|
|
53
|
+
it "creates a new Comment" do
|
|
54
|
+
expect {
|
|
55
|
+
post comments_url,
|
|
56
|
+
params: { comment: valid_attributes }, headers: valid_headers, as: :json
|
|
57
|
+
}.to change(Comment, :count).by(1)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "renders a JSON response with the new comment" do
|
|
61
|
+
post comments_url,
|
|
62
|
+
params: { comment: valid_attributes }, headers: valid_headers, as: :json
|
|
63
|
+
expect(response).to have_http_status(:created)
|
|
64
|
+
expect(response.content_type).to match(a_string_including("application/json"))
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "with invalid parameters" do
|
|
69
|
+
it "does not create a new Comment" do
|
|
70
|
+
expect {
|
|
71
|
+
post comments_url,
|
|
72
|
+
params: { comment: invalid_attributes }, as: :json
|
|
73
|
+
}.to change(Comment, :count).by(0)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "renders a JSON response with errors for the new comment" do
|
|
77
|
+
post comments_url,
|
|
78
|
+
params: { comment: invalid_attributes }, headers: valid_headers, as: :json
|
|
79
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
|
80
|
+
expect(response.content_type).to match(a_string_including("application/json"))
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe "PATCH /update" do
|
|
86
|
+
context "with valid parameters" do
|
|
87
|
+
let(:new_attributes) {
|
|
88
|
+
skip("Add a hash of attributes valid for your model")
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
it "updates the requested comment" do
|
|
92
|
+
comment = Comment.create! valid_attributes
|
|
93
|
+
patch comment_url(comment),
|
|
94
|
+
params: { comment: new_attributes }, headers: valid_headers, as: :json
|
|
95
|
+
comment.reload
|
|
96
|
+
skip("Add assertions for updated state")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "renders a JSON response with the comment" do
|
|
100
|
+
comment = Comment.create! valid_attributes
|
|
101
|
+
patch comment_url(comment),
|
|
102
|
+
params: { comment: new_attributes }, headers: valid_headers, as: :json
|
|
103
|
+
expect(response).to have_http_status(:ok)
|
|
104
|
+
expect(response.content_type).to match(a_string_including("application/json"))
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
context "with invalid parameters" do
|
|
109
|
+
it "renders a JSON response with errors for the comment" do
|
|
110
|
+
comment = Comment.create! valid_attributes
|
|
111
|
+
patch comment_url(comment),
|
|
112
|
+
params: { comment: invalid_attributes }, headers: valid_headers, as: :json
|
|
113
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
|
114
|
+
expect(response.content_type).to match(a_string_including("application/json"))
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
describe "DELETE /destroy" do
|
|
120
|
+
it "destroys the requested comment" do
|
|
121
|
+
comment = Comment.create! valid_attributes
|
|
122
|
+
expect {
|
|
123
|
+
delete comment_url(comment), headers: valid_headers, as: :json
|
|
124
|
+
}.to change(Comment, :count).by(-1)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
require 'rails_helper'
|
|
2
|
+
|
|
3
|
+
# This spec was generated by rspec-rails when you ran the scaffold generator.
|
|
4
|
+
# It demonstrates how one might use RSpec to test the controller code that
|
|
5
|
+
# was generated by Rails when you ran the scaffold generator.
|
|
6
|
+
#
|
|
7
|
+
# It assumes that the implementation code is generated by the rails scaffold
|
|
8
|
+
# generator. If you are using any extension libraries to generate different
|
|
9
|
+
# controller code, this generated spec may or may not pass.
|
|
10
|
+
#
|
|
11
|
+
# It only uses APIs available in rails and/or rspec-rails. There are a number
|
|
12
|
+
# of tools you can use to make these specs even more expressive, but we're
|
|
13
|
+
# sticking to rails and rspec-rails APIs to keep things simple and stable.
|
|
14
|
+
|
|
15
|
+
RSpec.describe "/posts", type: :request do
|
|
16
|
+
# This should return the minimal set of attributes required to create a valid
|
|
17
|
+
# Post. As you add validations to Post, be sure to
|
|
18
|
+
# adjust the attributes here as well.
|
|
19
|
+
let(:valid_attributes) {
|
|
20
|
+
skip("Add a hash of attributes valid for your model")
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
let(:invalid_attributes) {
|
|
24
|
+
skip("Add a hash of attributes invalid for your model")
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
# This should return the minimal set of values that should be in the headers
|
|
28
|
+
# in order to pass any filters (e.g. authentication) defined in
|
|
29
|
+
# PostsController, or in your router and rack
|
|
30
|
+
# middleware. Be sure to keep this updated too.
|
|
31
|
+
let(:valid_headers) {
|
|
32
|
+
{}
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
describe "GET /index" do
|
|
36
|
+
it "renders a successful response" do
|
|
37
|
+
Post.create! valid_attributes
|
|
38
|
+
get posts_url, headers: valid_headers, as: :json
|
|
39
|
+
expect(response).to be_successful
|
|
40
|
+
end
|
|
41
|
+
end
|
|
42
|
+
|
|
43
|
+
describe "GET /show" do
|
|
44
|
+
it "renders a successful response" do
|
|
45
|
+
post = Post.create! valid_attributes
|
|
46
|
+
get post_url(post), as: :json
|
|
47
|
+
expect(response).to be_successful
|
|
48
|
+
end
|
|
49
|
+
end
|
|
50
|
+
|
|
51
|
+
describe "POST /create" do
|
|
52
|
+
context "with valid parameters" do
|
|
53
|
+
it "creates a new Post" do
|
|
54
|
+
expect {
|
|
55
|
+
post posts_url,
|
|
56
|
+
params: { post: valid_attributes }, headers: valid_headers, as: :json
|
|
57
|
+
}.to change(Post, :count).by(1)
|
|
58
|
+
end
|
|
59
|
+
|
|
60
|
+
it "renders a JSON response with the new post" do
|
|
61
|
+
post posts_url,
|
|
62
|
+
params: { post: valid_attributes }, headers: valid_headers, as: :json
|
|
63
|
+
expect(response).to have_http_status(:created)
|
|
64
|
+
expect(response.content_type).to match(a_string_including("application/json"))
|
|
65
|
+
end
|
|
66
|
+
end
|
|
67
|
+
|
|
68
|
+
context "with invalid parameters" do
|
|
69
|
+
it "does not create a new Post" do
|
|
70
|
+
expect {
|
|
71
|
+
post posts_url,
|
|
72
|
+
params: { post: invalid_attributes }, as: :json
|
|
73
|
+
}.to change(Post, :count).by(0)
|
|
74
|
+
end
|
|
75
|
+
|
|
76
|
+
it "renders a JSON response with errors for the new post" do
|
|
77
|
+
post posts_url,
|
|
78
|
+
params: { post: invalid_attributes }, headers: valid_headers, as: :json
|
|
79
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
|
80
|
+
expect(response.content_type).to match(a_string_including("application/json"))
|
|
81
|
+
end
|
|
82
|
+
end
|
|
83
|
+
end
|
|
84
|
+
|
|
85
|
+
describe "PATCH /update" do
|
|
86
|
+
context "with valid parameters" do
|
|
87
|
+
let(:new_attributes) {
|
|
88
|
+
skip("Add a hash of attributes valid for your model")
|
|
89
|
+
}
|
|
90
|
+
|
|
91
|
+
it "updates the requested post" do
|
|
92
|
+
post = Post.create! valid_attributes
|
|
93
|
+
patch post_url(post),
|
|
94
|
+
params: { post: new_attributes }, headers: valid_headers, as: :json
|
|
95
|
+
post.reload
|
|
96
|
+
skip("Add assertions for updated state")
|
|
97
|
+
end
|
|
98
|
+
|
|
99
|
+
it "renders a JSON response with the post" do
|
|
100
|
+
post = Post.create! valid_attributes
|
|
101
|
+
patch post_url(post),
|
|
102
|
+
params: { post: new_attributes }, headers: valid_headers, as: :json
|
|
103
|
+
expect(response).to have_http_status(:ok)
|
|
104
|
+
expect(response.content_type).to match(a_string_including("application/json"))
|
|
105
|
+
end
|
|
106
|
+
end
|
|
107
|
+
|
|
108
|
+
context "with invalid parameters" do
|
|
109
|
+
it "renders a JSON response with errors for the post" do
|
|
110
|
+
post = Post.create! valid_attributes
|
|
111
|
+
patch post_url(post),
|
|
112
|
+
params: { post: invalid_attributes }, headers: valid_headers, as: :json
|
|
113
|
+
expect(response).to have_http_status(:unprocessable_entity)
|
|
114
|
+
expect(response.content_type).to match(a_string_including("application/json"))
|
|
115
|
+
end
|
|
116
|
+
end
|
|
117
|
+
end
|
|
118
|
+
|
|
119
|
+
describe "DELETE /destroy" do
|
|
120
|
+
it "destroys the requested post" do
|
|
121
|
+
post = Post.create! valid_attributes
|
|
122
|
+
expect {
|
|
123
|
+
delete post_url(post), headers: valid_headers, as: :json
|
|
124
|
+
}.to change(Post, :count).by(-1)
|
|
125
|
+
end
|
|
126
|
+
end
|
|
127
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe CommentsController, type: :routing do
|
|
4
|
+
describe "routing" do
|
|
5
|
+
it "routes to #index" do
|
|
6
|
+
expect(get: "/comments").to route_to("comments#index")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "routes to #show" do
|
|
10
|
+
expect(get: "/comments/1").to route_to("comments#show", id: "1")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
it "routes to #create" do
|
|
15
|
+
expect(post: "/comments").to route_to("comments#create")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "routes to #update via PUT" do
|
|
19
|
+
expect(put: "/comments/1").to route_to("comments#update", id: "1")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "routes to #update via PATCH" do
|
|
23
|
+
expect(patch: "/comments/1").to route_to("comments#update", id: "1")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "routes to #destroy" do
|
|
27
|
+
expect(delete: "/comments/1").to route_to("comments#destroy", id: "1")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
require "rails_helper"
|
|
2
|
+
|
|
3
|
+
RSpec.describe PostsController, type: :routing do
|
|
4
|
+
describe "routing" do
|
|
5
|
+
it "routes to #index" do
|
|
6
|
+
expect(get: "/posts").to route_to("posts#index")
|
|
7
|
+
end
|
|
8
|
+
|
|
9
|
+
it "routes to #show" do
|
|
10
|
+
expect(get: "/posts/1").to route_to("posts#show", id: "1")
|
|
11
|
+
end
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
it "routes to #create" do
|
|
15
|
+
expect(post: "/posts").to route_to("posts#create")
|
|
16
|
+
end
|
|
17
|
+
|
|
18
|
+
it "routes to #update via PUT" do
|
|
19
|
+
expect(put: "/posts/1").to route_to("posts#update", id: "1")
|
|
20
|
+
end
|
|
21
|
+
|
|
22
|
+
it "routes to #update via PATCH" do
|
|
23
|
+
expect(patch: "/posts/1").to route_to("posts#update", id: "1")
|
|
24
|
+
end
|
|
25
|
+
|
|
26
|
+
it "routes to #destroy" do
|
|
27
|
+
expect(delete: "/posts/1").to route_to("posts#destroy", id: "1")
|
|
28
|
+
end
|
|
29
|
+
end
|
|
30
|
+
end
|
|
@@ -0,0 +1,94 @@
|
|
|
1
|
+
# This file was generated by the `rails generate rspec:install` command. Conventionally, all
|
|
2
|
+
# specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
|
|
3
|
+
# The generated `.rspec` file contains `--require spec_helper` which will cause
|
|
4
|
+
# this file to always be loaded, without a need to explicitly require it in any
|
|
5
|
+
# files.
|
|
6
|
+
#
|
|
7
|
+
# Given that it is always loaded, you are encouraged to keep this file as
|
|
8
|
+
# light-weight as possible. Requiring heavyweight dependencies from this file
|
|
9
|
+
# will add to the boot time of your test suite on EVERY test run, even for an
|
|
10
|
+
# individual file that may not need all of that loaded. Instead, consider making
|
|
11
|
+
# a separate helper file that requires the additional dependencies and performs
|
|
12
|
+
# the additional setup, and require it from the spec files that actually need
|
|
13
|
+
# it.
|
|
14
|
+
#
|
|
15
|
+
# See https://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
|
|
16
|
+
RSpec.configure do |config|
|
|
17
|
+
# rspec-expectations config goes here. You can use an alternate
|
|
18
|
+
# assertion/expectation library such as wrong or the stdlib/minitest
|
|
19
|
+
# assertions if you prefer.
|
|
20
|
+
config.expect_with :rspec do |expectations|
|
|
21
|
+
# This option will default to `true` in RSpec 4. It makes the `description`
|
|
22
|
+
# and `failure_message` of custom matchers include text for helper methods
|
|
23
|
+
# defined using `chain`, e.g.:
|
|
24
|
+
# be_bigger_than(2).and_smaller_than(4).description
|
|
25
|
+
# # => "be bigger than 2 and smaller than 4"
|
|
26
|
+
# ...rather than:
|
|
27
|
+
# # => "be bigger than 2"
|
|
28
|
+
expectations.include_chain_clauses_in_custom_matcher_descriptions = true
|
|
29
|
+
end
|
|
30
|
+
|
|
31
|
+
# rspec-mocks config goes here. You can use an alternate test double
|
|
32
|
+
# library (such as bogus or mocha) by changing the `mock_with` option here.
|
|
33
|
+
config.mock_with :rspec do |mocks|
|
|
34
|
+
# Prevents you from mocking or stubbing a method that does not exist on
|
|
35
|
+
# a real object. This is generally recommended, and will default to
|
|
36
|
+
# `true` in RSpec 4.
|
|
37
|
+
mocks.verify_partial_doubles = true
|
|
38
|
+
end
|
|
39
|
+
|
|
40
|
+
# This option will default to `:apply_to_host_groups` in RSpec 4 (and will
|
|
41
|
+
# have no way to turn it off -- the option exists only for backwards
|
|
42
|
+
# compatibility in RSpec 3). It causes shared context metadata to be
|
|
43
|
+
# inherited by the metadata hash of host groups and examples, rather than
|
|
44
|
+
# triggering implicit auto-inclusion in groups with matching metadata.
|
|
45
|
+
config.shared_context_metadata_behavior = :apply_to_host_groups
|
|
46
|
+
|
|
47
|
+
# The settings below are suggested to provide a good initial experience
|
|
48
|
+
# with RSpec, but feel free to customize to your heart's content.
|
|
49
|
+
=begin
|
|
50
|
+
# This allows you to limit a spec run to individual examples or groups
|
|
51
|
+
# you care about by tagging them with `:focus` metadata. When nothing
|
|
52
|
+
# is tagged with `:focus`, all examples get run. RSpec also provides
|
|
53
|
+
# aliases for `it`, `describe`, and `context` that include `:focus`
|
|
54
|
+
# metadata: `fit`, `fdescribe` and `fcontext`, respectively.
|
|
55
|
+
config.filter_run_when_matching :focus
|
|
56
|
+
|
|
57
|
+
# Allows RSpec to persist some state between runs in order to support
|
|
58
|
+
# the `--only-failures` and `--next-failure` CLI options. We recommend
|
|
59
|
+
# you configure your source control system to ignore this file.
|
|
60
|
+
config.example_status_persistence_file_path = "spec/examples.txt"
|
|
61
|
+
|
|
62
|
+
# Limits the available syntax to the non-monkey patched syntax that is
|
|
63
|
+
# recommended. For more details, see:
|
|
64
|
+
# https://rspec.info/features/3-12/rspec-core/configuration/zero-monkey-patching-mode/
|
|
65
|
+
config.disable_monkey_patching!
|
|
66
|
+
|
|
67
|
+
# Many RSpec users commonly either run the entire suite or an individual
|
|
68
|
+
# file, and it's useful to allow more verbose output when running an
|
|
69
|
+
# individual spec file.
|
|
70
|
+
if config.files_to_run.one?
|
|
71
|
+
# Use the documentation formatter for detailed output,
|
|
72
|
+
# unless a formatter has already been configured
|
|
73
|
+
# (e.g. via a command-line flag).
|
|
74
|
+
config.default_formatter = "doc"
|
|
75
|
+
end
|
|
76
|
+
|
|
77
|
+
# Print the 10 slowest examples and example groups at the
|
|
78
|
+
# end of the spec run, to help surface which specs are running
|
|
79
|
+
# particularly slow.
|
|
80
|
+
config.profile_examples = 10
|
|
81
|
+
|
|
82
|
+
# Run specs in random order to surface order dependencies. If you find an
|
|
83
|
+
# order dependency and want to debug it, you can fix the order by providing
|
|
84
|
+
# the seed, which is printed after each run.
|
|
85
|
+
# --seed 1234
|
|
86
|
+
config.order = :random
|
|
87
|
+
|
|
88
|
+
# Seed global randomization in this process using the `--seed` CLI option.
|
|
89
|
+
# Setting this allows you to use `--seed` to deterministically reproduce
|
|
90
|
+
# test failures related to randomization by passing the same `--seed` value
|
|
91
|
+
# as the one that triggered the failure.
|
|
92
|
+
Kernel.srand config.seed
|
|
93
|
+
=end
|
|
94
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
ENV['RAILS_ENV'] ||= 'test'
|
|
2
|
+
require_relative "../config/environment"
|
|
3
|
+
require "rails/test_help"
|
|
4
|
+
|
|
5
|
+
class ActiveSupport::TestCase
|
|
6
|
+
# Run tests in parallel with specified workers
|
|
7
|
+
parallelize(workers: :number_of_processors)
|
|
8
|
+
|
|
9
|
+
# Setup all fixtures in test/fixtures/*.yml for all tests in alphabetical order.
|
|
10
|
+
fixtures :all
|
|
11
|
+
|
|
12
|
+
# Add more helper methods to be used by all tests here...
|
|
13
|
+
end
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
data/firetail.gemspec
CHANGED
|
@@ -37,5 +37,5 @@ Gem::Specification.new do |spec|
|
|
|
37
37
|
spec.add_dependency "async", "~> 1.30.3"
|
|
38
38
|
spec.add_dependency "jwt", "~> 2.5"
|
|
39
39
|
spec.add_dependency "json-schema", "~> 3.0.0"
|
|
40
|
-
spec.add_dependency "committee_firetail", "~> 5.0.
|
|
40
|
+
spec.add_dependency "committee_firetail", "~> 5.0.1"
|
|
41
41
|
end
|
data/lib/backend.rb
CHANGED
|
@@ -23,9 +23,6 @@ class Backend
|
|
|
23
23
|
req.body = payload
|
|
24
24
|
# Create new thread
|
|
25
25
|
Thread.new {
|
|
26
|
-
Thread.current.report_on_exception = false
|
|
27
|
-
# Wait for thread completion of thread is not the current thread
|
|
28
|
-
Thread.list.each{ |t| t.join unless t == Thread.current }
|
|
29
26
|
# Send the request
|
|
30
27
|
request = http.request(req)
|
|
31
28
|
}
|
data/lib/firetail/version.rb
CHANGED
data/lib/firetail.rb
CHANGED
|
@@ -38,7 +38,7 @@ module Firetail
|
|
|
38
38
|
if defined?(Rails)
|
|
39
39
|
begin
|
|
40
40
|
default_location = File.join(Rails.root, "config/firetail.yml")
|
|
41
|
-
config = YAML.
|
|
41
|
+
config = YAML.safe_load(ERB.new(File.read(default_location)).result)
|
|
42
42
|
rescue Errno::ENOENT
|
|
43
43
|
# error message if firetail is not installed
|
|
44
44
|
puts ""
|
|
@@ -53,7 +53,7 @@ module Firetail
|
|
|
53
53
|
raise Error.new "API Key is missing from firetail.yml configuration" if config['api_key'].nil?
|
|
54
54
|
|
|
55
55
|
@api_key = config['api_key']
|
|
56
|
-
@url = config['url'] ? config['url'] : "https://api.logging.eu-west-1.
|
|
56
|
+
@url = config['url'] ? config['url'] : "https://api.logging.eu-west-1.prod.firetail.app/logs/bulk" # default goes to europe
|
|
57
57
|
@log_drains_timeout = config['log_drains_timeout'] ? config['log_drains_timeout'] : 5
|
|
58
58
|
@network_timeout = config['network_timeout'] ? config['network_timeout'] : 10
|
|
59
59
|
@number_of_retries = config['number_of_retries'] ? config['number_of_retries'] : 4
|
|
@@ -171,9 +171,6 @@ module Firetail
|
|
|
171
171
|
statusCode: status,
|
|
172
172
|
body: body,
|
|
173
173
|
headers: response_headers,
|
|
174
|
-
},
|
|
175
|
-
oauth: {
|
|
176
|
-
subject: subject ? sha1_hash(subject) : nil,
|
|
177
174
|
}
|
|
178
175
|
})
|
|
179
176
|
@request.body.rewind
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
api_key: ENV.fetch("FIRETAIL_API_KEY")
|
|
2
|
-
url: ENV.fetch("FIRETAIL_URL")
|
|
1
|
+
api_key: <%= ENV.fetch("FIRETAIL_API_KEY", nil) %>
|
|
2
|
+
url: <%= ENV.fetch("FIRETAIL_URL", nil) %>
|
data/lib/railtie.rb
CHANGED
|
@@ -10,7 +10,7 @@ class Railtie < Rails::Railtie
|
|
|
10
10
|
schema_path = File.join(Rails.root, "config/schema.json")
|
|
11
11
|
|
|
12
12
|
# check if schema file exists in config/
|
|
13
|
-
if File.
|
|
13
|
+
if File.exist?(schema_path)
|
|
14
14
|
app.config.middleware.use Committee::Middleware::RequestValidation,
|
|
15
15
|
schema_path: schema_path,
|
|
16
16
|
coerce_date_times: true,
|
|
@@ -22,9 +22,8 @@ class Railtie < Rails::Railtie
|
|
|
22
22
|
puts "Need schema.json in \"config/\" directory"
|
|
23
23
|
puts "Try re-running \"rails g firetail:install\" again"
|
|
24
24
|
end
|
|
25
|
-
rescue
|
|
26
|
-
puts
|
|
27
|
-
puts "Try re-running \"rails g firetail:install\" again"
|
|
25
|
+
rescue Error => e
|
|
26
|
+
puts e
|
|
28
27
|
end
|
|
29
28
|
end
|
|
30
29
|
end
|