bscf-core 0.1.0 → 0.2.1
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/Rakefile +1 -1
- data/app/models/bscf/core/address.rb +7 -0
- data/app/models/bscf/core/business.rb +15 -0
- data/app/models/bscf/core/category.rb +11 -0
- data/app/models/bscf/core/order.rb +24 -0
- data/app/models/bscf/core/order_item.rb +15 -0
- data/app/models/bscf/core/product.rb +29 -0
- data/app/models/bscf/core/quotation.rb +29 -0
- data/app/models/bscf/core/quotation_item.rb +23 -0
- data/app/models/bscf/core/request_for_quotation.rb +13 -0
- data/app/models/bscf/core/rfq_item.rb +9 -0
- data/app/models/bscf/core/role.rb +10 -0
- data/app/models/bscf/core/user.rb +21 -0
- data/app/models/bscf/core/user_profile.rb +26 -0
- data/app/models/bscf/core/user_role.rb +8 -0
- data/app/models/bscf/core/virtual_account.rb +53 -0
- data/app/models/bscf/core/virtual_account_transaction.rb +158 -0
- data/db/migrate/20250326065606_create_bscf_core_users.rb +18 -0
- data/db/migrate/20250326075111_create_bscf_core_roles.rb +9 -0
- data/db/migrate/20250326080646_create_bscf_core_user_profiles.rb +19 -0
- data/db/migrate/20250326081052_create_bscf_core_addresses.rb +14 -0
- data/db/migrate/20250326084233_create_bscf_core_user_roles.rb +10 -0
- data/db/migrate/20250326085741_create_bscf_core_virtual_accounts.rb +24 -0
- data/db/migrate/20250326103305_create_bscf_core_categories.rb +11 -0
- data/db/migrate/20250326105652_create_bscf_core_products.rb +14 -0
- data/db/migrate/20250326112449_create_bscf_core_businesses.rb +14 -0
- data/db/migrate/20250326115203_create_bscf_core_request_for_quotations.rb +11 -0
- data/db/migrate/20250326120613_create_bscf_core_rfq_items.rb +12 -0
- data/db/migrate/20250326121246_create_bscf_core_bscf_core_virtual_account_transactions.rb +19 -0
- data/db/migrate/20250327041651_create_bscf_core_quotations.rb +15 -0
- data/db/migrate/20250327044020_create_bscf_core_quotation_items.rb +15 -0
- data/db/migrate/20250327102217_create_bscf_core_orders.rb +14 -0
- data/db/migrate/20250327112412_create_bscf_core_order_items.rb +14 -0
- data/lib/bscf/core/engine.rb +18 -0
- data/lib/bscf/core/version.rb +1 -1
- data/lib/tasks/release.rake +42 -0
- data/spec/factories/bscf/core/addresses.rb +10 -0
- data/spec/factories/bscf/core/businesses.rb +24 -0
- data/spec/factories/bscf/core/categories.rb +16 -0
- data/spec/factories/bscf/core/order_items.rb +10 -0
- data/spec/factories/bscf/core/orders.rb +10 -0
- data/spec/factories/bscf/core/products.rb +8 -0
- data/spec/factories/bscf/core/quotation_items.rb +11 -0
- data/spec/factories/bscf/core/quotations.rb +28 -0
- data/spec/factories/bscf/core/request_for_quotations.rb +7 -0
- data/spec/factories/bscf/core/rfq_items.rb +8 -0
- data/spec/factories/bscf/core/roles.rb +5 -0
- data/spec/factories/bscf/core/user_profiles.rb +15 -0
- data/spec/factories/bscf/core/user_roles.rb +6 -0
- data/spec/factories/bscf/core/users.rb +10 -0
- data/spec/factories/bscf/core/virtual_account_transactions.rb +34 -0
- data/spec/factories/bscf/core/virtual_accounts.rb +38 -0
- metadata +51 -37
- data/spec/dummy/Rakefile +0 -6
- data/spec/dummy/app/assets/stylesheets/application.css +0 -15
- data/spec/dummy/app/controllers/application_controller.rb +0 -2
- data/spec/dummy/app/jobs/application_job.rb +0 -7
- data/spec/dummy/app/mailers/application_mailer.rb +0 -4
- data/spec/dummy/app/models/application_record.rb +0 -3
- data/spec/dummy/app/views/layouts/mailer.html.erb +0 -13
- data/spec/dummy/app/views/layouts/mailer.text.erb +0 -1
- data/spec/dummy/bin/dev +0 -2
- data/spec/dummy/bin/rails +0 -4
- data/spec/dummy/bin/rake +0 -4
- data/spec/dummy/bin/setup +0 -34
- data/spec/dummy/config/application.rb +0 -43
- data/spec/dummy/config/boot.rb +0 -5
- data/spec/dummy/config/cable.yml +0 -10
- data/spec/dummy/config/database.yml +0 -17
- data/spec/dummy/config/environment.rb +0 -5
- data/spec/dummy/config/environments/development.rb +0 -67
- data/spec/dummy/config/environments/production.rb +0 -86
- data/spec/dummy/config/environments/test.rb +0 -53
- data/spec/dummy/config/initializers/cors.rb +0 -16
- data/spec/dummy/config/initializers/filter_parameter_logging.rb +0 -8
- data/spec/dummy/config/initializers/inflections.rb +0 -16
- data/spec/dummy/config/locales/en.yml +0 -31
- data/spec/dummy/config/puma.rb +0 -38
- data/spec/dummy/config/routes.rb +0 -3
- data/spec/dummy/config/storage.yml +0 -34
- data/spec/dummy/config.ru +0 -6
- data/spec/dummy/log/development.log +0 -17
- data/spec/dummy/tmp/local_secret.txt +0 -1
- data/spec/examples.txt +0 -3
- data/spec/rails_helper.rb +0 -46
- data/spec/spec_helper.rb +0 -34
- data/spec/support/models/shared_examples.rb +0 -49
- data/spec/support/requests/shared_requests.rb +0 -126
@@ -1,126 +0,0 @@
|
|
1
|
-
module Bscf
|
2
|
-
module Core
|
3
|
-
RSpec.shared_examples "request_shared_spec" do |controller, field_count, exclude = []|
|
4
|
-
include Comee::Core::Engine.routes.url_helpers
|
5
|
-
|
6
|
-
let(:factory) { controller.classify.underscore.to_sym }
|
7
|
-
let(:clazz) { "Bscf::Core::#{controller.classify}".constantize }
|
8
|
-
|
9
|
-
unless exclude.include?(:index)
|
10
|
-
describe "GET /index" do
|
11
|
-
it "returns success response" do
|
12
|
-
count = clazz.count
|
13
|
-
3.times { create(factory) }
|
14
|
-
get(send("#{controller}_url"), headers: headers)
|
15
|
-
expect(response).to be_successful
|
16
|
-
result = JSON(response.body)
|
17
|
-
|
18
|
-
expect(result["success"]).to be_truthy
|
19
|
-
expect(result["data"].count - count).to eq 3
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
unless exclude.include?(:show)
|
25
|
-
describe "GET /show" do
|
26
|
-
it "returns a success response" do
|
27
|
-
obj = create(factory)
|
28
|
-
get(send("#{controller.singularize}_url", obj), headers: headers)
|
29
|
-
expect(response).to be_successful
|
30
|
-
result = JSON(response.body)
|
31
|
-
expect(result["success"]).to be_truthy
|
32
|
-
expect(result["data"].count).to eq field_count
|
33
|
-
expect(result["data"]["id"]).to eq obj.id
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
unless exclude.include?(:create)
|
39
|
-
describe "POST /create" do
|
40
|
-
context "with valid params" do
|
41
|
-
it "creates a new object" do
|
42
|
-
params = {payload: valid_attributes}
|
43
|
-
expect do
|
44
|
-
post(
|
45
|
-
send("#{controller}_url"),
|
46
|
-
headers: headers,
|
47
|
-
params: params,
|
48
|
-
as: :json
|
49
|
-
)
|
50
|
-
end.to change(clazz, :count).by(1)
|
51
|
-
expect(response).to have_http_status(:created)
|
52
|
-
expect(response.content_type).to eq("application/json; charset=utf-8")
|
53
|
-
|
54
|
-
result = JSON(response.body)
|
55
|
-
expect(result["success"]).to be_truthy
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context "with invalid params" do
|
60
|
-
it "renders a JSON response with errors for the new object" do
|
61
|
-
params = {payload: invalid_attributes}
|
62
|
-
post(
|
63
|
-
send("#{controller}_url"),
|
64
|
-
params: params,
|
65
|
-
headers: headers,
|
66
|
-
as: :json
|
67
|
-
)
|
68
|
-
|
69
|
-
expect(response).to have_http_status(422)
|
70
|
-
expect(response.content_type).to eq("application/json; charset=utf-8")
|
71
|
-
|
72
|
-
result = JSON(response.body)
|
73
|
-
expect(result["success"]).to be_falsey
|
74
|
-
expect(result["error"]).not_to be_blank
|
75
|
-
end
|
76
|
-
end
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
unless exclude.include?(:update)
|
81
|
-
describe "PUT /update" do
|
82
|
-
context "with valid params" do
|
83
|
-
it "updates the requested object" do
|
84
|
-
obj = create(factory)
|
85
|
-
params = {id: obj.to_param, payload: new_attributes}
|
86
|
-
put(
|
87
|
-
send("#{controller.singularize}_url", obj),
|
88
|
-
headers: headers,
|
89
|
-
params: params, as: :json
|
90
|
-
)
|
91
|
-
obj.reload
|
92
|
-
|
93
|
-
expect(response).to have_http_status(:ok)
|
94
|
-
expect(obj.send(new_attributes.keys[0])).to eq new_attributes.values[0]
|
95
|
-
expect(response.content_type).to eq("application/json; charset=utf-8")
|
96
|
-
|
97
|
-
result = JSON(response.body)
|
98
|
-
expect(result["success"]).to be_truthy
|
99
|
-
expect(result["data"]["id"]).to eq obj.id
|
100
|
-
end
|
101
|
-
end
|
102
|
-
|
103
|
-
context "with invalid params" do
|
104
|
-
it "renders a JSON response with errors for the object" do
|
105
|
-
obj = create(factory)
|
106
|
-
params = {id: obj.to_param, payload: invalid_attributes}
|
107
|
-
put(
|
108
|
-
send("#{controller.singularize}_url", obj),
|
109
|
-
headers: headers,
|
110
|
-
params: params,
|
111
|
-
as: :json
|
112
|
-
)
|
113
|
-
|
114
|
-
expect(response).to have_http_status(422)
|
115
|
-
expect(response.content_type).to eq("application/json; charset=utf-8")
|
116
|
-
|
117
|
-
result = JSON(response.body)
|
118
|
-
expect(result["success"]).to be_falsey
|
119
|
-
expect(result["error"]).not_to be_blank
|
120
|
-
end
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
|
-
end
|
125
|
-
end
|
126
|
-
end
|