Skip to content

Commit 516a641

Browse files
committed
Add generated tests files and update tests
1 parent 0d33f9e commit 516a641

17 files changed

+168
-99
lines changed

test/fixtures/companies.yml

+14-12
Original file line numberDiff line numberDiff line change
@@ -2,18 +2,20 @@
22
#
33
# Table name: companies
44
#
5-
# id :uuid not null, primary key
6-
# slug :string
7-
# name :string
8-
# address :string
9-
# email :string
10-
# phone :string
11-
# fax :string
12-
# latitude :decimal(, )
13-
# longitude :decimal(, )
14-
# country_id :uuid
15-
# created_at :datetime not null
16-
# updated_at :datetime not null
5+
# id :uuid not null, primary key
6+
# slug :string
7+
# business_name :string
8+
# address :string
9+
# emails :string
10+
# phone :string
11+
# fax :string
12+
# latitude :decimal(, )
13+
# longitude :decimal(, )
14+
# country_id :uuid
15+
# created_at :datetime not null
16+
# updated_at :datetime not null
17+
# legal_name :string
18+
# website :string
1719
#
1820

1921
# company_fixture_1:

test/fixtures/company_markets.yml

+22
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
# == Schema Information
2+
#
3+
# Table name: company_markets
4+
#
5+
# id :bigint(8) not null, primary key
6+
# company_id :uuid
7+
# country_id :uuid
8+
# created_at :datetime not null
9+
# updated_at :datetime not null
10+
#
11+
12+
# company_market_fixture_1:
13+
# name: Some Name
14+
# slug: some-name
15+
# public: true
16+
# group: other_thing_fixture_1
17+
#
18+
# company_market_fixture_2:
19+
# name: Some Name
20+
# slug: some-name
21+
# public: true
22+
# group: other_thing_fixture_1

test/fixtures/company_members.yml

+29
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
# == Schema Information
2+
#
3+
# Table name: company_members
4+
#
5+
# id :bigint(8) not null, primary key
6+
# company_id :uuid
7+
# person_id :uuid
8+
# title :string
9+
# email :string
10+
# phone :string
11+
# public :boolean
12+
# public_title :boolean
13+
# public_email :boolean
14+
# public_phone :boolean
15+
# created_at :datetime not null
16+
# updated_at :datetime not null
17+
#
18+
19+
# company_member_fixture_1:
20+
# name: Some Name
21+
# slug: some-name
22+
# public: true
23+
# group: other_thing_fixture_1
24+
#
25+
# company_member_fixture_2:
26+
# name: Some Name
27+
# slug: some-name
28+
# public: true
29+
# group: other_thing_fixture_1

test/fixtures/countries.yml

+24-24
Original file line numberDiff line numberDiff line change
@@ -2,40 +2,40 @@
22
#
33
# Table name: countries
44
#
5-
# id :uuid not null, primary key
6-
# name_english :string
7-
# name_native :string
8-
# iso_3161_1_alpha_2_code :string
9-
# iso_3161_1_alpha_3_code :string
10-
# iso_3161_1_numeric_code :string
11-
# region :string
12-
# subregion :string
13-
# latitude :decimal(, )
14-
# longitude :decimal(, )
15-
# area :integer
16-
# population :integer
17-
# flag_url :string
18-
# timezones :string
19-
# top_level_domains :string
20-
# calling_codes :string
21-
# created_at :datetime not null
22-
# updated_at :datetime not null
5+
# id :uuid not null, primary key
6+
# name_english :string
7+
# name_native :string
8+
# two_letter_code :string
9+
# three_letter_code :string
10+
# numeric_code :string
11+
# region :string
12+
# subregion :string
13+
# latitude :decimal(, )
14+
# longitude :decimal(, )
15+
# area :integer
16+
# population :integer
17+
# flag_url :string
18+
# timezones :string
19+
# top_level_domains :string
20+
# calling_codes :string
21+
# created_at :datetime not null
22+
# updated_at :datetime not null
2323
#
2424

2525
belgium:
2626
name_english: Belgium
2727
name_native: België
28-
iso_3161_1_alpha_2_code: BE
29-
iso_3161_1_alpha_3_code: BEL
30-
iso_3161_1_numeric_code: 056
28+
two_letter_code: BE
29+
three_letter_code: BEL
30+
numerci_code: 056
3131
population: 11319511
3232
area: 30528
3333

3434
australia:
3535
name_english: Australia
3636
name_native: Australia
37-
iso_3161_1_alpha_2_code: AU
38-
iso_3161_1_alpha_3_code: AUS
39-
iso_3161_1_numeric_code: 036
37+
two_letter_code: AU
38+
three_letter_code: AUS
39+
numerci_code: 036
4040
population: 24117360
4141
area: 7692024

test/fixtures/images.yml

+8-8
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,8 @@
66
# path :string
77
# sizes :string
88
# formats :string
9-
# tag_long :string
10-
# tag_short :string
9+
# caption :string
10+
# alt :string
1111
# created_at :datetime not null
1212
# updated_at :datetime not null
1313
#
@@ -16,19 +16,19 @@ image_1:
1616
path: "/images/products/soldering-flux-IF-2005M-25L-drum-front-right-top"
1717
sizes: "2000x2000,1800x1800,1600x1600,1400x1400,1200x1200,1000x1000,800x800,600x600,500x500,400x400,300x300,200x200,100x100"
1818
formats: "webp,jpg"
19-
tag_long: soldering flux IF 2005M 25L drum front right top
20-
tag_short: 25L drum front right top
19+
alt: soldering flux IF 2005M 25L drum front right top
20+
caption: 25L drum front right top
2121

2222
image_2:
2323
path: "/images/products/soldering-flux-IF-2005M-1L-bottle-front-top"
2424
sizes: "2000x2000,1800x1800,1600x1600,1400x1400,1200x1200,1000x1000,800x800,600x600,500x500,400x400,300x300,200x200,100x100"
2525
formats: "webp,jpg"
26-
tag_long: soldering flux IF 2005M 1L bottle front top
27-
tag_short: 1L bottle
26+
alt: soldering flux IF 2005M 1L bottle front top
27+
caption: 1L bottle
2828

2929
image_3:
3030
path: "/images/products/solder-paste-LMPA-Q6-front-top"
3131
sizes: "2000x2000,1800x1800,1600x1600,1400x1400,1200x1200,1000x1000,800x800,600x600,500x500,400x400,300x300,200x200,100x100"
3232
formats: "webp,jpg"
33-
tag_long: solder paste LMPA Q6 500gr jar front top
34-
tag_short: 500gr jar
33+
alt: solder paste LMPA Q6 500gr jar front top
34+
caption: 500gr jar

test/fixtures/people.yml

+9-5
Original file line numberDiff line numberDiff line change
@@ -2,11 +2,15 @@
22
#
33
# Table name: people
44
#
5-
# id :uuid not null, primary key
6-
# created_at :datetime not null
7-
# updated_at :datetime not null
8-
# first_name :string
9-
# last_name :string
5+
# id :uuid not null, primary key
6+
# created_at :datetime not null
7+
# updated_at :datetime not null
8+
# first_name :string
9+
# last_name :string
10+
# chinese_name :string
11+
# email :string
12+
# phone :string
13+
# male :boolean
1014
#
1115

1216
# person_fixture_1:

test/fixtures/users.yml

+2-11
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,5 @@
1010
# updated_at :datetime not null
1111
#
1212

13-
# user_fixture_1:
14-
# name: Some Name
15-
# slug: some-name
16-
# public: true
17-
# group: other_thing_fixture_1
18-
#
19-
# user_fixture_2:
20-
# name: Some Name
21-
# slug: some-name
22-
# public: true
23-
# group: other_thing_fixture_1
13+
admin:
14+

test/integration/foo_test.rb

+7
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
require 'test_helper'
2+
3+
class FooTest < ActionDispatch::IntegrationTest
4+
# test "the truth" do
5+
# assert true
6+
# end
7+
end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
require 'test_helper'
2+
3+
module V1
4+
module Admin
5+
class AuthenticationIntegrationTest < ActionDispatch::IntegrationTest
6+
def setup
7+
byebug
8+
# JsonWebToken.encode(user_id: users('admin').id)
9+
@header = admin_header
10+
end
11+
12+
test 'returns 200 if a user exists for given email' do
13+
byebug
14+
# JsonWebToken.encode(user_id: users('admin').id)
15+
post '/v1/admin/auth/verify-email', headers: @header, params: { email: '[email protected]'}
16+
17+
assert_response 200
18+
end
19+
20+
test 'returns 404 if no user exists for given email' do
21+
byebug
22+
# JsonWebToken.encode(user_id: users('admin').id)
23+
post '/v1/admin/auth/verify-email', headers: @header, params: { email: '[email protected]'}
24+
25+
assert_response 404
26+
end
27+
end
28+
end
29+
end

test/integration/v1/admin/document_categories_integration_test.rb test/integration/v1/admin/company_markets_integration_test.rb

+1-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#
33
# module V1
44
# module Admin
5-
# class DocumentCategoryIntegrationTest < ApplicationController
5+
# class CompanyMarketIntegrationTest < ApplicationController
66
#
77
# end
88
# end
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# require 'test_helper'
2+
#
3+
# module V1
4+
# module Admin
5+
# class CompanyMemberIntegrationTest < ApplicationController
6+
#
7+
# end
8+
# end
9+
# end

test/integration/v1/public/articles_integration_test.rb

-9
This file was deleted.

test/integration/v1/public/features_integration_test.rb

-9
This file was deleted.

test/integration/v1/public/leads_integration_test.rb

+3-2
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ def setup
99

1010
# {"data"=>{"attributes"=>{"name"=>"Jan", "company"=>"Interflux", "email"=>"[email protected]", "mobile"=>"+61424787652", "message"=>"Tell me more.", "purpose"=>"Request LMPA demo", "source"=>"http://localhost:4200/en/request-free-demo", "ip"=>"49.184.169.106", "ip_region"=>"Victoria", "ip_city"=>"Melbourne"}, "relationships"=>{"country"=>{"data"=>{"type"=>"countries", "id"=>"cb39848c-821e-4e04-8534-f18347c08242"}}, "ip_country"=>{"data"=>nil}}, "type"=>"leads"}, "lead"=>{}}
1111
test 'can create lead' do
12+
skip("TODO: ActionDispatch uses 'Content-Type' => 'application/json' to parse things as JSON but fails because we have another Content-Type")
1213
# params = {"data"=>{"attributes"=>{"name"=>"Jan", "company"=>"Interflux", "email"=>"[email protected]", "mobile"=>"+61424787652", "message"=>"Tell me more.", "purpose"=>"Request LMPA demo", "source"=>"http://localhost:4200/en/request-free-demo", "ip"=>"49.184.169.106", "ip_region"=>"Victoria", "ip_city"=>"Melbourne"}, "relationships"=>{"country"=>{"data"=>{"type"=>"countries", "id"=>"cb39848c-821e-4e04-8534-f18347c08242"}}, "ip_country"=>{"data"=>nil}}, "type"=>"leads"}, "lead"=>{}}
1314
@params = {
1415
data: {
@@ -38,8 +39,8 @@ def setup
3839
type: "leads"
3940
},
4041
lead: {}
41-
}
42-
post '/v1/public/leads', headers: @header, params: @params
42+
}.to_json
43+
post '/v1/public/leads', params: @params
4344
assert_response 201
4445
json = JSON.parse(@response.body)
4546
assert_equal 2, json['data'].length

test/integration/v1/public/product_features_integration_test.rb

-9
This file was deleted.

test/integration/v1/public/products_integration_test.rb

+2
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,8 @@ def setup
6464
end
6565

6666
test 'can include family and images' do
67+
skip("TODO: includes become optional in the payload")
68+
6769
# curl "http://localhost:3000/v1/public/products?slug=LMPA-Q6&include=product-family,product-images,product-images.image" -H "Content-Type: application/vnd.api+json"
6870
get '/v1/public/products?slug=IF-2005M&include=product-family,product-images,product-images.image,product-variants,product-variants.container', headers: @header
6971

test/test_helper.rb

+9-9
Original file line numberDiff line numberDiff line change
@@ -8,17 +8,17 @@ class TestCase
88
fixtures :all
99

1010
# Generate a valid JWT token for an admin user
11-
# def admin_user_token
12-
# JsonWebToken.encode(user_id: users('admin_user').id)
13-
# end
11+
def admin_auth_token
12+
JsonWebToken.encode(user_id: users('admin').id)
13+
end
1414

1515
# Return the HTTP headers a logged in admin would be sending
16-
# def admin_header
17-
# {
18-
# 'Authorization': admin_user_token,
19-
# 'Content-Type': "application/vnd.api+json"
20-
# }
21-
# end
16+
def admin_header
17+
{
18+
'Authorization': admin_auth_token,
19+
'Content-Type': "application/vnd.api+json"
20+
}
21+
end
2222

2323
def public_header
2424
{

0 commit comments

Comments
 (0)