Skip to content

Commit

Permalink
Fix controller specs
Browse files Browse the repository at this point in the history
  • Loading branch information
kcinay055679 committed Aug 2, 2024
1 parent ff01a4f commit cbdc90f
Show file tree
Hide file tree
Showing 6 changed files with 34 additions and 7 deletions.
3 changes: 1 addition & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema[7.0].define(version: 2024_06_24_122411) do
ActiveRecord::Schema[7.0].define(version: 2024_06_03_085509) do
# These are extensions that must be enabled in order to support this database
enable_extension "plpgsql"

Expand Down Expand Up @@ -148,7 +148,6 @@
t.string "email"
t.integer "department_id"
t.string "shortname"
t.integer "ptime_employee_id"
t.index ["company_id"], name: "index_people_on_company_id"
end

Expand Down
4 changes: 2 additions & 2 deletions spec/controllers/people/picture_controller_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
end

it 'should update picture' do
process :update, method: :put, params: { id: bob.id, picture: fixture_file_upload('picture.png', 'image/png') }
put :update, params: { id: bob.id, picture: fixture_file_upload('picture.png', 'image/png') }

path = json['data']['picture_path']

Expand All @@ -25,7 +25,7 @@
expect(bob['picture']).to eq('picture.png')
expect(path).to eq(picture_person_path(bob))

process :show, method: :get , params: { id: bob.id }
get :show, params: { id: bob.id }

new_picture_md5 = 'c903aeff2bec840bd7c028631bd56596'

Expand Down
2 changes: 1 addition & 1 deletion spec/features/cv_search_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@
fill_in 'cv_search_field', with: education_location
check_search_results(Person.human_attribute_name(:educations))
click_link(Person.human_attribute_name(:educations))
expect(current_url).to eq(person_path(person, q: education_location))
expect(current_url).to end_with(person_path(person, q: education_location))
end

it 'should only display results when length of search-text is > 3' do
Expand Down
3 changes: 2 additions & 1 deletion spec/features/routing_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,8 @@
"/": "/de/people",
"/de/": "/de/people",
"/people": "/de/people",
"/people_skills": "/de/people_skills"
"/people_skills": "/de/people_skills",
"/en": "/en/people",
}
before(:each) do
sign_in auth_users(:user), scope: :auth_user
Expand Down
4 changes: 3 additions & 1 deletion spec/rails_helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -66,6 +66,8 @@
config.include(JsonMacros, type: :controller)
config.include(JsonAssertion, type: :controller)
config.include(ControllerHelpers, type: :controller)
config.include DefaultParams, type: :controller


# Feature helper

Expand All @@ -85,6 +87,6 @@
config.filter_rails_from_backtrace!

config.before(:each, type: :feature) do
default_url_options[:locale] = I18n.default_locale
default_url_options[:locale] = I18n.locale
end
end
25 changes: 25 additions & 0 deletions spec/support/default_params.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
require 'active_support/concern'

module DefaultParams
extend ActiveSupport::Concern

included do
let(:default_params) {{locale: I18n.locale}}
prepend RequestHelpersCustomized
end

module RequestHelpersCustomized
l = lambda do |path, **kwargs|
if default_params
kwargs[:params] ||= {}
default_params.each do |key, value|
kwargs[:params][key] ||= value
end
end
super(path, params: kwargs[:params])
end
%w(get post patch put delete).each do |method|
define_method(method, l)
end
end
end

0 comments on commit cbdc90f

Please sign in to comment.