Skip to content

Commit 72859a3

Browse files
fixed tests
1 parent 431fc9c commit 72859a3

File tree

9 files changed

+48
-9
lines changed

9 files changed

+48
-9
lines changed

.rubocop.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@ AllCops:
66
- 'spec/**/*'
77
- 'db/**/*'
88
- 'config/**/*'
9+
- 'spec/**/*'
910
- 'bin/*'
1011
- 'config.ru'
1112
- 'Gemfile'

app/controllers/auth/tara_controller.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ class TaraController < ParentController
55
allow_unauthenticated
66

77
def callback
8-
expires_now
8+
expires_now && reset_session
99

1010
unless in_white_list?
1111
flash[:alert] = I18n.t('.access_denied')

config/application.yml.sample

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -66,11 +66,21 @@ secret_word: ''
6666

6767
e_invoice_provider_test_mode: 'true'
6868

69+
70+
deposit_min_num: 10001
71+
deposit_max_num: 14001
72+
6973
development:
7074
allowed_base_urls: 'https://registry.test, https://registrar_center.test, https://eeid.test, https://auction_center.test, https://auction.test'
75+
tara_redirect_uri: 'https://eis_billing_system.test/auth/tara/callback'
76+
tara_identifier: ''
77+
tara_secret: ''
78+
79+
staging:
80+
tara_redirect_uri: 'https://st-billing.infra.tld.ee/auth/tara/callback'
81+
tara_identifier: ''
82+
tara_secret: ''
7183

72-
deposit_min_num: 10001
73-
deposit_max_num: 14001
7484

7585
apipie_login: test
7686
apipie_password: test

spec/factories/users.rb

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,8 @@
22
factory :user do
33
email { "admin@example.com" }
44
password_digest { "MyString" }
5+
uid { "EE60001019906" }
6+
identity_code { "60001019906" }
7+
provider { "tara" }
58
end
69
end

spec/factories/white_codes.rb

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
FactoryBot.define do
22
factory :white_code do
3-
code { "MyString" }
3+
code { "60001019906" }
44
end
55
end

spec/rails_helper.rb

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727
# directory. Alternatively, in the individual `*_spec.rb` files, manually
2828
# require only the support files necessary.
2929
#
30-
# Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
30+
Dir[Rails.root.join('spec', 'support', '**', '*.rb')].sort.each { |f| require f }
3131

3232
# Checks for pending migrations and applies them before tests are run.
3333
# If you are not using ActiveRecord, you can remove these lines.
@@ -39,6 +39,8 @@
3939
end
4040
RSpec.configure do |config|
4141
config.include FactoryBot::Syntax::Methods
42+
43+
config.include Auth
4244
# config.fixture_path = "#{::Rails.root}/spec/fixtures"
4345

4446
# Remove this line if you're not using ActiveRecord or ActiveRecord fixtures

spec/requests/dashboards/invoice_status_spec.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,12 @@
22

33
RSpec.describe "InvoiceStatus", type: :request do
44
let(:user) { create(:user) }
5+
let(:white_code) { create(:white_code) }
6+
57
before(:each) do
6-
Current.user = user
7-
allow_any_instance_of(ParentController).to receive(:require_user_logged_in!).and_return(Current.user)
8+
user.reload && white_code.reload
9+
10+
login user
811

912
mock_response = {
1013
'message' => 'Invoice data was successfully updated'

spec/requests/dashboards/invoice_synchronizes_spec.rb

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,10 +3,12 @@
33
RSpec.describe "InvoiceSynchronizesController", type: :request do
44
let(:user) { create(:user) }
55
let(:invoice) { create(:invoice) }
6+
let(:white_code) { create(:white_code) }
67

78
before(:each) do
8-
Current.user = user
9-
allow_any_instance_of(ParentController).to receive(:require_user_logged_in!).and_return(Current.user)
9+
user.reload && white_code.reload
10+
11+
login user
1012
end
1113

1214
describe "POST update invoice status" do

spec/support/auth.rb

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
module Auth
2+
def login(user, first_name = 'TEST', last_name = 'OK')
3+
om = {
4+
'provider' => 'tara',
5+
'uid' => user.uid,
6+
'info' => {
7+
'first_name' => first_name,
8+
'last_name' => last_name,
9+
'name' => user.uid
10+
}
11+
}
12+
13+
OmniAuth.config.test_mode = true
14+
OmniAuth.config.add_mock(:tara, om)
15+
16+
post auth_tara_callback_path(provider: 'tara')
17+
end
18+
end

0 commit comments

Comments
 (0)