eitil 1.4.1 → 2.0.3
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/README.md +0 -1
- data/eitil_integrate/lib/eitil_integrate/application_exporter/lookups.rb +1 -1
- data/lib/eitil/railtie.rb +2 -3
- data/lib/eitil/version.rb +1 -1
- data/spec/dummy_app/app/controllers/application_controller.rb +0 -2
- data/spec/dummy_app/app/controllers/users_controller.rb +0 -31
- data/spec/dummy_app/config/routes.rb +0 -5
- data/spec/dummy_app/db/test.sqlite3 +0 -0
- data/spec/spec_helper.rb +0 -2
- metadata +2 -27
- data/eitil_wrapper/README.md +0 -309
- data/eitil_wrapper/lib/eitil_wrapper/callbacks/helper_methods.rb +0 -118
- data/eitil_wrapper/lib/eitil_wrapper/callbacks.rb +0 -2
- data/eitil_wrapper/lib/eitil_wrapper/decorators/application_decorator.rb +0 -22
- data/eitil_wrapper/lib/eitil_wrapper/decorators/controller_decorator.rb +0 -72
- data/eitil_wrapper/lib/eitil_wrapper/decorators.rb +0 -3
- data/eitil_wrapper/lib/eitil_wrapper/jobs/new_job.rb +0 -34
- data/eitil_wrapper/lib/eitil_wrapper/jobs/new_job_now.rb +0 -37
- data/eitil_wrapper/lib/eitil_wrapper/jobs/single_method_job.rb +0 -11
- data/eitil_wrapper/lib/eitil_wrapper/jobs.rb +0 -4
- data/eitil_wrapper/lib/eitil_wrapper/railtie.rb +0 -94
- data/eitil_wrapper/lib/eitil_wrapper/records/default_calculators.rb +0 -104
- data/eitil_wrapper/lib/eitil_wrapper/records/default_scopes.rb +0 -95
- data/eitil_wrapper/lib/eitil_wrapper/records/default_sorts.rb +0 -81
- data/eitil_wrapper/lib/eitil_wrapper/records.rb +0 -4
- data/eitil_wrapper/lib/eitil_wrapper/request_logger/controller_mixin.rb +0 -48
- data/eitil_wrapper/lib/eitil_wrapper/request_logger/logger_job.rb +0 -17
- data/eitil_wrapper/lib/eitil_wrapper/request_logger.rb +0 -5
- data/eitil_wrapper/lib/eitil_wrapper/routes/extended_resources.rb +0 -40
- data/eitil_wrapper/lib/eitil_wrapper/routes.rb +0 -2
- data/eitil_wrapper/lib/eitil_wrapper.rb +0 -9
- data/spec/dummy_app/app/decorators/address_decorator.rb +0 -3
- data/spec/dummy_app/app/decorators/application_decorator.rb +0 -12
- data/spec/dummy_app/app/decorators/user_decorator.rb +0 -19
- data/spec/eitil_wrapper/decorators/decorators_spec.rb +0 -49
@@ -1,19 +0,0 @@
|
|
1
|
-
class UserDecorator < ApplicationDecorator
|
2
|
-
|
3
|
-
def first_and_last_name(user)
|
4
|
-
user.slice(:first_name, :last_name)
|
5
|
-
end
|
6
|
-
|
7
|
-
def app(user)
|
8
|
-
user.slice(:phone, :email)
|
9
|
-
end
|
10
|
-
|
11
|
-
def web(user)
|
12
|
-
user.slice(:age, :wage)
|
13
|
-
end
|
14
|
-
|
15
|
-
def base(user)
|
16
|
-
user.as_json
|
17
|
-
end
|
18
|
-
|
19
|
-
end
|
@@ -1,49 +0,0 @@
|
|
1
|
-
|
2
|
-
RSpec.describe "EitilWrapper::Decorators" do
|
3
|
-
|
4
|
-
include Rack::Test::Methods
|
5
|
-
|
6
|
-
let(:user) { User.create(first_name: 'slim', last_name: 'shady') }
|
7
|
-
|
8
|
-
def body(endpoint)
|
9
|
-
@body ||= JSON.parse(get("/users/#{user.id}/#{endpoint}").body)
|
10
|
-
end
|
11
|
-
|
12
|
-
it "should respond to a request" do
|
13
|
-
response = get "/users/#{user.id}/decorator_a"
|
14
|
-
expect(response).to be_a Rack::MockResponse
|
15
|
-
end
|
16
|
-
|
17
|
-
it "should, by default, return all of a records' columns" do
|
18
|
-
response_keys = body(:decorator_a).keys.map(&:to_sym)
|
19
|
-
table_columns = [:id, :created_at, :updated_at, :first_name, :last_name, :email, :birthday, :phone, :confirmed, :last_sign_in, :age, :wage]
|
20
|
-
expect(table_columns.all? { |column| response_keys.include?(column) }).to be_truthy
|
21
|
-
end
|
22
|
-
|
23
|
-
it "should, if a specific decorator method is passed, return that method's value" do
|
24
|
-
response_keys = body(:decorator_b).keys.map(&:to_sym)
|
25
|
-
decorator_keys = [:first_name, :last_name]
|
26
|
-
expect(response_keys).to eq decorator_keys
|
27
|
-
end
|
28
|
-
|
29
|
-
it "should, if no decorator method is passed, but param['isMobile'] is present, return the :app method's value" do
|
30
|
-
response = post "/users/#{user.id}/decorator_c", { "isMobile" => true }
|
31
|
-
response_keys = JSON.parse(response.body).keys.map(&:to_sym)
|
32
|
-
decorator_keys = [:phone, :email]
|
33
|
-
expect(response_keys).to eq decorator_keys
|
34
|
-
end
|
35
|
-
|
36
|
-
it "should, if no decorator method is passed, but param['isWeb'] is present, return the :web method's value" do
|
37
|
-
response = post "/users/#{user.id}/decorator_c", { "isWeb" => true }
|
38
|
-
response_keys = JSON.parse(response.body).keys.map(&:to_sym)
|
39
|
-
decorator_keys = [:age, :wage]
|
40
|
-
expect(response_keys).to eq decorator_keys
|
41
|
-
end
|
42
|
-
|
43
|
-
it "should, if a decorator class is passed, return the value of that class' method" do
|
44
|
-
response_keys = body(:decorator_d).keys.map(&:to_sym)
|
45
|
-
decorator_keys = [:created_at, :updated_at]
|
46
|
-
expect(response_keys).to eq decorator_keys
|
47
|
-
end
|
48
|
-
|
49
|
-
end
|