Skip to content

Commit 0ba3458

Browse files
committed
Iterate on CI/CD
1 parent 5332f4d commit 0ba3458

14 files changed

Lines changed: 45 additions & 26 deletions

File tree

.github/workflows/pr-validation.yml

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,17 @@ jobs:
8989
- name: Install dependencies
9090
run: |
9191
yarn install --frozen-lockfile --prefer-offline
92+
93+
- name: Run Ruby lint
94+
run: bundle exec rubocop
95+
96+
- name: Run JavaScript lint
97+
run: yarn lint:js
98+
99+
- name: Build assets
100+
run: |
101+
yarn build
102+
yarn build:css
92103
93104
- name: Setup test database
94105
env:

Gemfile

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -83,6 +83,9 @@ group :development, :test do
8383
# See https://guides.rubyonrails.org/debugging_rails_applications.html#debugging-with-the-debug-gem
8484
gem "debug", platforms: %i[mri windows], require: "debug/prelude"
8585

86+
# Dependency vulnerability scanning
87+
gem "bundler-audit", require: false
88+
8689
# Static analysis for security vulnerabilities [https://brakemanscanner.org/]
8790
gem "brakeman", require: false
8891

Gemfile.lock

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,9 @@ GEM
9494
bullet (8.1.0)
9595
activesupport (>= 3.0.0)
9696
uniform_notifier (~> 1.11)
97+
bundler-audit (0.9.3)
98+
bundler (>= 1.2.0)
99+
thor (~> 1.0)
97100
case_transform (0.2)
98101
activesupport
99102
concurrent-ruby (1.3.6)
@@ -440,6 +443,7 @@ DEPENDENCIES
440443
bootsnap
441444
brakeman
442445
bullet
446+
bundler-audit
443447
cssbundling-rails
444448
database_cleaner-active_record
445449
debug

app/controllers/api/v1/registrations_controller.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,8 @@ def respond_with(resource, _opts = {})
2020
end
2121

2222
def sign_up_params
23-
params.require(:user).permit(:email, :password, :password_confirmation, :role)
23+
params.require(:user).permit(:email, :password, :password_confirmation)
2424
end
2525
end
2626
end
27-
end
27+
end

spec/controllers/api/v1/ignore_lists_controller_spec.rb

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66

77
describe 'GET #index' do
88
before do
9-
sign_in user
9+
request.headers.merge!(auth_headers(admin))
1010
create_list(:ignore_list, 3, :twitch_user)
1111
create_list(:ignore_list, 2, :discord_user)
1212
create_list(:ignore_list, 2, :url)
@@ -44,7 +44,7 @@
4444

4545
describe 'GET #by_type' do
4646
before do
47-
sign_in user
47+
request.headers.merge!(auth_headers(admin))
4848
create(:ignore_list, list_type: 'twitch_user', value: 'baduser1')
4949
create(:ignore_list, list_type: 'twitch_user', value: 'baduser2')
5050
create(:ignore_list, list_type: 'discord_user', value: 'spammer#1234')
@@ -67,7 +67,7 @@
6767
describe 'GET #show' do
6868
let(:ignore_list) { create(:ignore_list) }
6969

70-
before { sign_in user }
70+
before { request.headers.merge!(auth_headers(admin)) }
7171

7272
it 'returns the ignore list' do
7373
get :show, params: { id: ignore_list.id }
@@ -79,7 +79,7 @@
7979

8080
describe 'POST #create' do
8181
context 'as admin' do
82-
before { sign_in admin }
82+
before { request.headers.merge!(auth_headers(admin)) }
8383

8484
it 'creates a new ignore list' do
8585
expect {
@@ -104,14 +104,14 @@
104104
value: 'test'
105105
}
106106
}
107-
expect(response).to have_http_status(:unprocessable_entity)
107+
expect(response).to have_http_status(:unprocessable_content)
108108
json = JSON.parse(response.body)
109109
expect(json['errors']).to include('List type is not included in the list')
110110
end
111111
end
112112

113113
context 'as regular user' do
114-
before { sign_in user }
114+
before { request.headers.merge!(auth_headers(user)) }
115115

116116
it 'returns forbidden' do
117117
post :create, params: {
@@ -126,7 +126,7 @@
126126
end
127127

128128
describe 'POST #bulk_create' do
129-
before { sign_in admin }
129+
before { request.headers.merge!(auth_headers(admin)) }
130130

131131
it 'creates multiple ignore lists' do
132132
expect {
@@ -166,7 +166,7 @@
166166
let(:ignore_list) { create(:ignore_list) }
167167

168168
context 'as admin' do
169-
before { sign_in admin }
169+
before { request.headers.merge!(auth_headers(admin)) }
170170

171171
it 'updates the ignore list' do
172172
patch :update, params: {
@@ -181,7 +181,7 @@
181181
end
182182

183183
context 'as regular user' do
184-
before { sign_in user }
184+
before { request.headers.merge!(auth_headers(user)) }
185185

186186
it 'returns forbidden' do
187187
patch :update, params: {
@@ -197,7 +197,7 @@
197197
let!(:ignore_list) { create(:ignore_list) }
198198

199199
context 'as admin' do
200-
before { sign_in admin }
200+
before { request.headers.merge!(auth_headers(admin)) }
201201

202202
it 'deletes the ignore list' do
203203
expect {
@@ -208,7 +208,7 @@
208208
end
209209

210210
context 'as regular user' do
211-
before { sign_in user }
211+
before { request.headers.merge!(auth_headers(user)) }
212212

213213
it 'returns forbidden' do
214214
delete :destroy, params: { id: ignore_list.id }
@@ -221,7 +221,7 @@
221221
let!(:lists) { create_list(:ignore_list, 5) }
222222

223223
context 'as admin' do
224-
before { sign_in admin }
224+
before { request.headers.merge!(auth_headers(admin)) }
225225

226226
it 'deletes multiple ignore lists' do
227227
ids_to_delete = lists.first(3).map(&:id)
@@ -235,4 +235,4 @@
235235
end
236236
end
237237
end
238-
end
238+
end

spec/rails_helper.rb

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@
6868

6969
# Include Devise test helpers
7070
config.include Devise::Test::IntegrationHelpers, type: :request
71+
config.include Devise::Test::ControllerHelpers, type: :controller
7172

7273
# Database cleaner setup
7374
config.before(:suite) do

spec/requests/admin/streamers_spec.rb

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -147,7 +147,7 @@
147147

148148
it "returns unprocessable entity status" do
149149
post admin_streamers_path, params: invalid_params
150-
expect(response).to have_http_status(:unprocessable_entity)
150+
expect(response).to have_http_status(:unprocessable_content)
151151
end
152152
end
153153
end
@@ -219,7 +219,7 @@
219219

220220
it "returns unprocessable entity status" do
221221
patch admin_streamer_path(streamer), params: invalid_params
222-
expect(response).to have_http_status(:unprocessable_entity)
222+
expect(response).to have_http_status(:unprocessable_content)
223223
end
224224
end
225225
end

spec/requests/admin/streams_refactored_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -88,7 +88,7 @@
8888

8989
it "returns unprocessable entity" do
9090
post admin_streams_path, params: invalid_params
91-
expect(response).to have_http_status(:unprocessable_entity)
91+
expect(response).to have_http_status(:unprocessable_content)
9292
end
9393
end
9494
end

spec/requests/admin/streams_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -103,7 +103,7 @@
103103

104104
it "returns unprocessable entity" do
105105
post admin_streams_path, params: invalid_params
106-
expect(response).to have_http_status(:unprocessable_entity)
106+
expect(response).to have_http_status(:unprocessable_content)
107107
end
108108
end
109109
end

spec/requests/admin/timestamps_spec.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ def login_admin
138138

139139
it "returns unprocessable entity" do
140140
post admin_timestamps_path, params: invalid_params
141-
expect(response).to have_http_status(:unprocessable_entity)
141+
expect(response).to have_http_status(:unprocessable_content)
142142
end
143143
end
144144
end

0 commit comments

Comments
 (0)