tramway-api 1.8.7.3 → 2.0.0.2

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 11004151aa05f918b93dfcc0732fe11e69030074fd0f677470b8d8971bf15cb8
4
- data.tar.gz: 966562fdf9a961d25ed49e70b509df1039b8009e49520374ccdc4667432053f7
3
+ metadata.gz: 86dbb20f2ceaf8080df47a5437984da9242f4b04b093ba89ba7353af262c0761
4
+ data.tar.gz: d9ca7cf50ef790630662b3e69329e35798cda5dc8af8fb25790e56e6eaa644fa
5
5
  SHA512:
6
- metadata.gz: cda3e5383e1b5e8d18b6ca86b58a811fc44d58ad2a6d8a0a080d283081053a385d56d24c175687ab648232560128d3dbf7e4f11d2801e1819f927fa57900a61a
7
- data.tar.gz: c6e6e8f9bbf3ae234ce5f5b415d946158b69a5ba281f0dc638ef0c4eaf5b742700cc661744fc7182d8bc71000e80cc61bca74a39efdb2c99ab430f83b6435d90
6
+ metadata.gz: 58861b209bffc3aee14d7d1ccccb8046d057bd655326aedd7dc3010b80b267a1a1633486187042f7a7d4f46d9f9f4444bc3758c9236387e97b8c8e6d08edf5d6
7
+ data.tar.gz: ca7d7c90b7b17dd89677fcb5a59ea32f94c3d5efc097240d844680fb7b47feea4135659f9939e9955f1a7ecca56f05acc486be03aca3bd72b4e94361e07805b2
data/README.md CHANGED
@@ -257,7 +257,7 @@ RSpec.describe 'Post creating user', type: :feature do
257
257
 
258
258
  it 'returns created status' do
259
259
  post '/api/v1/user', params: { user: attributes }
260
- expect(response.status).to eq 201
260
+ expect(response[:status]).to eq 201
261
261
  end
262
262
 
263
263
  it 'returns no errors' do
@@ -275,17 +275,17 @@ end
275
275
  require 'rails_helper'
276
276
 
277
277
  RSpec.describe 'Post generate token', type: :feature do
278
- describe 'POST /api/v1/user_token' do
278
+ describe 'POST /api/v1/user_tokens' do
279
279
  let(:user) { create :user, password: '123456789' }
280
280
 
281
281
  it 'returns created status' do
282
- post '/api/v1/user_token', params: { auth: { login: user.email, password: '123456789' } }
282
+ post '/api/v1/user_tokens', params: { auth: { login: user.email, password: '123456789' } }
283
283
 
284
- expect(response.status).to eq 201
284
+ expect(response[:status]).to eq 201
285
285
  end
286
286
 
287
287
  it 'returns token' do
288
- post '/api/v1/user_token', params: { auth: { login: user.email, password: '123456789' } }
288
+ post '/api/v1/user_tokens', params: { auth: { login: user.email, password: '123456789' } }
289
289
 
290
290
  expect(json_response[:auth_token].present?).to be_truthy
291
291
  expect(json_response[:user]).to include_json({ email: user.email, uuid: user.uuid })
@@ -372,7 +372,7 @@ Then write test:
372
372
  it 'returns status' do
373
373
  get '/api/v1/records', params: { model: 'User' }, headers: headers
374
374
 
375
- expect(response.status).to eq 200
375
+ expect(response[:status]).to eq 200
376
376
  end
377
377
 
378
378
  it 'returns needed count' do
@@ -455,7 +455,7 @@ RSpec.describe 'Post generate token', type: :feature do
455
455
  it 'returns created status' do
456
456
  post '/api/v1/user_token', params: { auth: { login: user.email, password: '123456789' } }
457
457
 
458
- expect(response.status).to eq 201
458
+ expect(response[:status]).to eq 201
459
459
  end
460
460
 
461
461
  it 'returns token' do
@@ -16,7 +16,7 @@ module Tramway
16
16
  end
17
17
 
18
18
  def authenticate
19
- return if current_user || params[:user_based_model].in?(Tramway::Api.user_based_models)
19
+ return if current_tramway_user || params[:user_based_model].in?(Tramway::Api.user_based_models)
20
20
 
21
21
  unauthorized
22
22
  end
@@ -54,7 +54,7 @@ module Tramway
54
54
  params[:auth]&.permit(:login, :password)
55
55
  end
56
56
 
57
- def current_user
57
+ def current_tramway_user
58
58
  Tramway::Api.user_based_models.map do |user_based_model|
59
59
  send("current_#{user_based_model.constantize.name.underscore}") unless user_based_model == User
60
60
  end.compact.first
@@ -44,7 +44,7 @@ module Tramway
44
44
 
45
45
  def check_available_model_class
46
46
  unless model_class
47
- head(:unauthorized) && return unless current_user
47
+ head(:unauthorized) && return unless current_tramway_user
48
48
 
49
49
  head(:unprocessable_entity) && return
50
50
  end
@@ -53,7 +53,7 @@ module Tramway
53
53
  def check_available_model_action_for_record
54
54
  action_is_available = check_action
55
55
  action_is_available.tap do
56
- if action_is_available.is_a?(Proc) && !action_is_available.call(record, current_user)
56
+ if action_is_available.is_a?(Proc) && !action_is_available.call(record, current_tramway_user)
57
57
  head(:unprocessable_entity) && return
58
58
  end
59
59
  end
@@ -63,7 +63,7 @@ module Tramway
63
63
  action_is_available = check_action
64
64
  return records if action_is_available == true
65
65
 
66
- action_is_available.call records, current_user if action_is_available.is_a?(Proc)
66
+ action_is_available.call records, current_tramway_user if action_is_available.is_a?(Proc)
67
67
  end
68
68
 
69
69
  def check_action
@@ -73,7 +73,7 @@ module Tramway
73
73
  project: (@application_engine || application_name),
74
74
  role: role,
75
75
  model_name: params[:model],
76
- current_user: current_user
76
+ current_user: current_tramway_user
77
77
  )
78
78
  end.compact.uniq - [false]
79
79
 
@@ -94,17 +94,17 @@ module Tramway
94
94
  project: (@application_engine || application_name),
95
95
  model_name: params[:model]
96
96
  )
97
- head(:unauthorized) && return if !current_user && !action_is_open
97
+ head(:unauthorized) && return if !current_tramway_user && !action_is_open
98
98
  end
99
99
 
100
- def available_models_for_current_user
100
+ def available_models_for_current_tramway_user
101
101
  checking_roles.reduce([]) do |models, role|
102
102
  models += ::Tramway::Api.available_models(role: role).map(&:to_s)
103
103
  end
104
104
  end
105
105
 
106
106
  def checking_roles
107
- [:open, current_user&.role].compact
107
+ [:open, current_tramway_user&.role].compact
108
108
  end
109
109
 
110
110
  protected
@@ -51,7 +51,7 @@ module Tramway::Api::V1
51
51
  end
52
52
 
53
53
  def destroy
54
- record.remove
54
+ record.destroy
55
55
  render json: record,
56
56
  serializer: serializer_class,
57
57
  include: '*',
@@ -26,7 +26,7 @@ class Tramway::Api::V1::UsersController < ::Tramway::Api::V1::ApplicationControl
26
26
  end
27
27
 
28
28
  def show
29
- render json: current_user, status: :ok
29
+ render json: current_tramway_user, status: :ok
30
30
  end
31
31
 
32
32
  private
@@ -2,6 +2,6 @@
2
2
 
3
3
  module Tramway
4
4
  module Api
5
- VERSION = '1.8.7.3'
5
+ VERSION = '2.0.0.2'
6
6
  end
7
7
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tramway-api
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.8.7.3
4
+ version: 2.0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Pavel Kalashnikov
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2021-12-19 00:00:00.000000000 Z
11
+ date: 2022-08-18 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: active_model_serializers
@@ -116,7 +116,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
116
116
  - !ruby/object:Gem::Version
117
117
  version: '0'
118
118
  requirements: []
119
- rubygems_version: 3.0.3.1
119
+ rubygems_version: 3.1.6
120
120
  signing_key:
121
121
  specification_version: 4
122
122
  summary: Engine for api