forest_liana 1.0.3 → 1.0.4

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,149 @@
1
+ belongs_to_field_1:
2
+ id: 1
3
+ has_one_field_id: 1
4
+ has_many_field_id: 1
5
+
6
+ belongs_to_field_2:
7
+ id: 2
8
+ has_one_field_id: 2
9
+ has_many_field_id: 1
10
+
11
+ belongs_to_field_3:
12
+ id: 3
13
+ has_one_field_id: 3
14
+ has_many_field_id: 1
15
+
16
+ belongs_to_field_4:
17
+ id: 4
18
+ has_one_field_id: 4
19
+ has_many_field_id: 2
20
+
21
+ belongs_to_field_5:
22
+ id: 5
23
+ has_one_field_id: 5
24
+ has_many_field_id: 2
25
+
26
+ belongs_to_field_6:
27
+ id: 6
28
+ has_one_field_id: 6
29
+ has_many_field_id: 2
30
+
31
+ belongs_to_field_7:
32
+ id: 7
33
+ has_one_field_id: 7
34
+ has_many_field_id: 3
35
+
36
+ belongs_to_field_8:
37
+ id: 8
38
+ has_one_field_id: 8
39
+ has_many_field_id: 3
40
+
41
+ belongs_to_field_9:
42
+ id: 9
43
+ has_one_field_id: 9
44
+ has_many_field_id: 3
45
+
46
+ belongs_to_field_10:
47
+ id: 10
48
+ has_one_field_id: 10
49
+ has_many_field_id: 4
50
+
51
+ belongs_to_field_11:
52
+ id: 11
53
+ has_one_field_id: 11
54
+ has_many_field_id: 4
55
+
56
+ belongs_to_field_12:
57
+ id: 12
58
+ has_one_field_id: 12
59
+ has_many_field_id: 4
60
+
61
+ belongs_to_field_13:
62
+ id: 13
63
+ has_one_field_id: 13
64
+ has_many_field_id: 5
65
+
66
+ belongs_to_field_14:
67
+ id: 14
68
+ has_one_field_id: 14
69
+ has_many_field_id: 5
70
+
71
+ belongs_to_field_15:
72
+ id: 15
73
+ has_one_field_id: 15
74
+ has_many_field_id: 5
75
+
76
+ belongs_to_field_16:
77
+ id: 16
78
+ has_one_field_id: 16
79
+ has_many_field_id: 6
80
+
81
+ belongs_to_field_17:
82
+ id: 17
83
+ has_one_field_id: 17
84
+ has_many_field_id: 6
85
+
86
+ belongs_to_field_18:
87
+ id: 18
88
+ has_one_field_id: 18
89
+ has_many_field_id: 6
90
+
91
+ belongs_to_field_19:
92
+ id: 19
93
+ has_one_field_id: 19
94
+ has_many_field_id: 7
95
+
96
+ belongs_to_field_20:
97
+ id: 20
98
+ has_one_field_id: 20
99
+ has_many_field_id: 7
100
+
101
+ belongs_to_field_21:
102
+ id: 21
103
+ has_one_field_id: 21
104
+ has_many_field_id: 7
105
+
106
+ belongs_to_field_22:
107
+ id: 22
108
+ has_one_field_id: 22
109
+ has_many_field_id: 7
110
+
111
+ belongs_to_field_23:
112
+ id: 23
113
+ has_one_field_id: 23
114
+ has_many_field_id: 8
115
+
116
+ belongs_to_field_24:
117
+ id: 24
118
+ has_one_field_id: 24
119
+ has_many_field_id: 8
120
+
121
+ belongs_to_field_25:
122
+ id: 25
123
+ has_one_field_id: 25
124
+ has_many_field_id: 9
125
+
126
+ belongs_to_field_26:
127
+ id: 26
128
+ has_one_field_id: 26
129
+ has_many_field_id: 9
130
+
131
+ belongs_to_field_27:
132
+ id: 27
133
+ has_one_field_id: 27
134
+ has_many_field_id: 9
135
+
136
+ belongs_to_field_28:
137
+ id: 28
138
+ has_one_field_id: 28
139
+ has_many_field_id: 10
140
+
141
+ belongs_to_field_29:
142
+ id: 29
143
+ has_one_field_id: 29
144
+ has_many_field_id: 10
145
+
146
+ belongs_to_field_30:
147
+ id: 30
148
+ has_one_field_id: 30
149
+ has_many_field_id: 10
@@ -0,0 +1,32 @@
1
+ has_many_field_1:
2
+ id: 1
3
+
4
+ has_many_field_2:
5
+ id: 2
6
+
7
+ has_many_field_3:
8
+ id: 3
9
+
10
+ has_many_field_4:
11
+ id: 4
12
+
13
+ has_many_field_5:
14
+ id: 5
15
+ has_many_through_field_id: 3
16
+
17
+ has_many_field_6:
18
+ id: 6
19
+ has_many_through_field_id: 2
20
+
21
+ has_many_field_7:
22
+ id: 7
23
+
24
+ has_many_field_8:
25
+ id: 8
26
+ has_many_through_field_id: 2
27
+
28
+ has_many_field_9:
29
+ id: 9
30
+
31
+ has_many_field_10:
32
+ id: 10
@@ -0,0 +1,29 @@
1
+ has_many_through_field_1:
2
+ id: 1
3
+
4
+ has_many_through_field_2:
5
+ id: 2
6
+
7
+ has_many_through_field_3:
8
+ id: 3
9
+
10
+ has_many_through_field_4:
11
+ id: 4
12
+
13
+ has_many_through_field_5:
14
+ id: 5
15
+
16
+ has_many_through_field_6:
17
+ id: 6
18
+
19
+ has_many_through_field_7:
20
+ id: 7
21
+
22
+ has_many_through_field_8:
23
+ id: 8
24
+
25
+ has_many_through_field_9:
26
+ id: 9
27
+
28
+ has_many_through_field_10:
29
+ id: 10
@@ -0,0 +1,89 @@
1
+ has_one_field_1:
2
+ id: 1
3
+
4
+ has_one_field_2:
5
+ id: 2
6
+
7
+ has_one_field_3:
8
+ id: 3
9
+
10
+ has_one_field_4:
11
+ id: 4
12
+
13
+ has_one_field_5:
14
+ id: 5
15
+
16
+ has_one_field_6:
17
+ id: 6
18
+
19
+ has_one_field_7:
20
+ id: 7
21
+
22
+ has_one_field_8:
23
+ id: 8
24
+
25
+ has_one_field_9:
26
+ id: 9
27
+
28
+ has_one_field_10:
29
+ id: 10
30
+
31
+ has_one_field_11:
32
+ id: 11
33
+
34
+ has_one_field_12:
35
+ id: 12
36
+
37
+ has_one_field_13:
38
+ id: 13
39
+
40
+ has_one_field_14:
41
+ id: 14
42
+
43
+ has_one_field_15:
44
+ id: 15
45
+
46
+ has_one_field_16:
47
+ id: 16
48
+
49
+ has_one_field_17:
50
+ id: 17
51
+
52
+ has_one_field_18:
53
+ id: 18
54
+
55
+ has_one_field_19:
56
+ id: 19
57
+
58
+ has_one_field_20:
59
+ id: 20
60
+
61
+ has_one_field_21:
62
+ id: 21
63
+
64
+ has_one_field_22:
65
+ id: 22
66
+
67
+ has_one_field_23:
68
+ id: 23
69
+
70
+ has_one_field_24:
71
+ id: 24
72
+
73
+ has_one_field_25:
74
+ id: 25
75
+
76
+ has_one_field_26:
77
+ id: 26
78
+
79
+ has_one_field_27:
80
+ id: 27
81
+
82
+ has_one_field_28:
83
+ id: 28
84
+
85
+ has_one_field_29:
86
+ id: 29
87
+
88
+ has_one_field_30:
89
+ id: 30
@@ -0,0 +1,119 @@
1
+ string_field_1:
2
+ id: 1
3
+ field: Test 1
4
+
5
+ string_field_2:
6
+ id: 2
7
+ field: Test 2
8
+
9
+ string_field_3:
10
+ id: 3
11
+ field: Test 3
12
+
13
+ string_field_4:
14
+ id: 4
15
+ field: Test 4
16
+
17
+ string_field_5:
18
+ id: 5
19
+ field: Test 5
20
+
21
+ string_field_6:
22
+ id: 6
23
+ field: Test 6
24
+
25
+ string_field_7:
26
+ id: 7
27
+ field: Test 7
28
+
29
+ string_field_8:
30
+ id: 8
31
+ field: Test 8
32
+
33
+ string_field_9:
34
+ id: 9
35
+ field: Test 9
36
+
37
+ string_field_10:
38
+ id: 10
39
+ field: Test 10
40
+
41
+ string_field_11:
42
+ id: 11
43
+ field: Test 11
44
+
45
+ string_field_12:
46
+ id: 12
47
+ field: Test 12
48
+
49
+ string_field_13:
50
+ id: 13
51
+ field: Test 13
52
+
53
+ string_field_14:
54
+ id: 14
55
+ field: Test 14
56
+
57
+ string_field_15:
58
+ id: 15
59
+ field: Test 15
60
+
61
+ string_field_16:
62
+ id: 16
63
+ field: Test 16
64
+
65
+ string_field_17:
66
+ id: 17
67
+ field: Test 17
68
+
69
+ string_field_18:
70
+ id: 18
71
+ field: Test 18
72
+
73
+ string_field_19:
74
+ id: 19
75
+ field: Test 19
76
+
77
+ string_field_20:
78
+ id: 20
79
+ field: Test 20
80
+
81
+ string_field_21:
82
+ id: 21
83
+ field: Test 21
84
+
85
+ string_field_22:
86
+ id: 22
87
+ field: Test 22
88
+
89
+ string_field_23:
90
+ id: 23
91
+ field: Test 23
92
+
93
+ string_field_24:
94
+ id: 24
95
+ field: Test 24
96
+
97
+ string_field_25:
98
+ id: 25
99
+ field: Test 25
100
+
101
+ string_field_26:
102
+ id: 26
103
+ field: Test 26
104
+
105
+ string_field_27:
106
+ id: 27
107
+ field: Test 27
108
+
109
+ string_field_28:
110
+ id: 28
111
+ field: Test 28
112
+
113
+ string_field_29:
114
+ id: 29
115
+ field: Test 29
116
+
117
+ string_field_30:
118
+ id: 30
119
+ field: Test 30
@@ -0,0 +1,108 @@
1
+ module ForestLiana
2
+ class ResourcesGetterTest < ActiveSupport::TestCase
3
+
4
+ test 'StringField page 1 size 15' do
5
+ getter = ResourcesGetter.new(StringField, {
6
+ page: { size: 15, number: 1 }
7
+ })
8
+ getter.perform
9
+ records = getter.records
10
+ count = getter.count
11
+
12
+ assert records.count == 15
13
+ assert count = 30
14
+ assert records.first.id == 30
15
+ assert records.last.id == 16
16
+ end
17
+
18
+ test 'StringField page 2 size 10' do
19
+ getter = ResourcesGetter.new(StringField, {
20
+ page: { size: 10, number: 2 }
21
+ })
22
+ getter.perform
23
+ records = getter.records
24
+ count = getter.count
25
+
26
+ assert records.count == 10
27
+ assert count = 30
28
+ assert records.first.id == 20
29
+ assert records.last.id == 11
30
+ end
31
+
32
+ test 'StringField sort by field' do
33
+ getter = ResourcesGetter.new(StringField, {
34
+ page: { size: 10, number: 1 },
35
+ sort: '-field'
36
+ })
37
+ getter.perform
38
+ records = getter.records
39
+ count = getter.count
40
+
41
+ assert records.count == 10
42
+ assert count = 30
43
+ assert records.map(&:field) == ['Test 9', 'Test 8', 'Test 7', 'Test 6',
44
+ 'Test 5', 'Test 4', 'Test 30', 'Test 3',
45
+ 'Test 29', 'Test 28']
46
+ end
47
+
48
+ test 'Sort by a belongs_to association' do
49
+ getter = ResourcesGetter.new(BelongsToField, {
50
+ page: { size: 10, number: 1 },
51
+ sort: 'has_one_field.id'
52
+ })
53
+ getter.perform
54
+ records = getter.records
55
+ count = getter.count
56
+
57
+ assert records.count == 10
58
+ assert count = 30
59
+ assert records.first.has_one_field_id == 1
60
+ assert records.last.has_one_field_id == 10
61
+ end
62
+
63
+ test 'Sort by a has_one association' do
64
+ getter = ResourcesGetter.new(HasOneField, {
65
+ page: { size: 10, number: 1 },
66
+ sort: '-belongs_to_field.id'
67
+ })
68
+ getter.perform
69
+ records = getter.records
70
+ count = getter.count
71
+
72
+ assert records.count == 10
73
+ assert count = 30
74
+ assert records.first.belongs_to_field.id == 30
75
+ assert records.last.belongs_to_field.id == 21
76
+ end
77
+
78
+ test 'Sort by a has_many association' do
79
+ getter = ResourcesGetter.new(HasManyField, {
80
+ page: { size: 10, number: 1 },
81
+ sort: '-belongs_to_fields'
82
+ })
83
+ getter.perform
84
+ records = getter.records
85
+ count = getter.count
86
+
87
+ assert records.count == 10
88
+ assert count = 30
89
+ assert records.first.id = 7
90
+ end
91
+
92
+ test 'Sort by a has_many through association' do
93
+ getter = ResourcesGetter.new(HasManyThroughField, {
94
+ page: { size: 10, number: 1 },
95
+ sort: '-belongs_to_fields'
96
+ })
97
+ getter.perform
98
+ records = getter.records
99
+ count = getter.count
100
+
101
+ assert records.count == 10
102
+ assert count = 30
103
+ assert records.first.id = 2
104
+ assert records.second.id = 3
105
+ end
106
+
107
+ end
108
+ end