File tree Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Expand file tree Collapse file tree 3 files changed +7
-6
lines changed Original file line number Diff line number Diff line change @@ -26,6 +26,7 @@ def self.by_tech(tech_name)
26
26
end
27
27
28
28
def self . total_pages ( num_of_items_per_page )
29
- last_two_months . count / num_of_items_per_page
29
+ calculation = last_two_months . count / num_of_items_per_page . to_f
30
+ calculation . ceil
30
31
end
31
32
end
Original file line number Diff line number Diff line change 143
143
end
144
144
145
145
it "returns total-pages when api gets called" do
146
- create_list ( :job , 50 )
146
+ create_list ( :job , 55 )
147
147
tech = create ( :technology , name : "ruby" )
148
148
Job . find_each { |job | job . technologies << tech }
149
149
150
150
get :index , { technology : "ruby" }
151
151
152
- expect ( response_body [ "meta" ] [ "total-pages" ] ) . to eq ( 2 )
152
+ expect ( response_body [ "meta" ] [ "total-pages" ] ) . to eq ( 3 )
153
153
end
154
154
end
155
155
end
Original file line number Diff line number Diff line change 96
96
97
97
describe '#total_pages' do
98
98
it 'returns the total amount of pages' do
99
- create_list ( :job , 4 )
99
+ create_list ( :job , 30 )
100
100
tech = create ( :technology , name : "ruby" )
101
101
Job . find_each { |job | job . technologies << tech }
102
102
103
- expect ( Job . count ) . to eq ( 4 )
104
- expect ( Job . total_pages ( 2 ) ) . to eq ( 2 )
103
+ expect ( Job . count ) . to eq ( 30 )
104
+ expect ( Job . total_pages ( 4 ) ) . to eq ( 8 )
105
105
end
106
106
end
107
107
end
You can’t perform that action at this time.
0 commit comments