date_paginate 0.0.1 → 0.0.2
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/app/views/date_paginate/_paginate_days.html.erb +1 -1
- data/app/views/date_paginate/_paginate_months.html.erb +1 -1
- data/app/views/date_paginate/_paginate_weeks.html.erb +1 -1
- data/lib/date_paginate/helpers/paginator.rb +5 -1
- data/lib/date_paginate/version.rb +1 -1
- data/spec/controllers/action_view_extension_spec.rb +15 -0
- data/spec/fake_app/log/test.log +133446 -0
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: e83eeb515cf4a5037db8c82a7b08dda1fa0840bf
|
4
|
+
data.tar.gz: 6349d2179b9b52aac193cb2452f32162ca311963
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 05fffc1ce465b407b56aba16d630432ded3a60f40a54201cfa0f65deff007969b3d90abd90651fd51d02eb4dee670e860016f1a342dc649b4a95d11c49d06a1c
|
7
|
+
data.tar.gz: 087fd3e93a5f76ff02ff869e548de2b29a2e1c778699f97e0771bd9004a52787230d140ba2633746353b63949fea1209eea032b8fdf7931aa30cf4b58f386a73
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<% recent_days.each do |begin_time| %>
|
4
4
|
<% begin_time = begin_time.in_time_zone if date.is_a? ActiveSupport::TimeWithZone %>
|
5
5
|
<span class="page<%=' current' if (date.between? begin_time, begin_time.end_of_day) %>">
|
6
|
-
<%= link_to_unless (date.between? begin_time, begin_time.end_of_day), begin_time.strftime('%Y-%m-%d'), year: begin_time.year, month: begin_time.month, day: begin_time.day %>
|
6
|
+
<%= link_to_unless (date.between? begin_time, begin_time.end_of_day), begin_time.strftime('%Y-%m-%d'), params.merge(year: begin_time.year, month: begin_time.month, day: begin_time.day) %>
|
7
7
|
</span>
|
8
8
|
<% end %>
|
9
9
|
</nav>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<% recent_months.each do |begin_date| %>
|
4
4
|
<% begin_date = begin_date.in_time_zone if date.is_a? ActiveSupport::TimeWithZone %>
|
5
5
|
<span class="page<%=' current' if (date.between? begin_date, begin_date.end_of_month) %>">
|
6
|
-
<%= link_to_unless (date.between? begin_date, begin_date.end_of_month), begin_date.strftime('%Y-%m'), year: begin_date.year, month: begin_date.month %>
|
6
|
+
<%= link_to_unless (date.between? begin_date, begin_date.end_of_month), begin_date.strftime('%Y-%m'), params.merge(year: begin_date.year, month: begin_date.month) %>
|
7
7
|
</span>
|
8
8
|
<% end %>
|
9
9
|
</nav>
|
@@ -3,7 +3,7 @@
|
|
3
3
|
<% recent_weeks.each do |begin_date| %>
|
4
4
|
<% begin_date = begin_date.in_time_zone if date.is_a? ActiveSupport::TimeWithZone %>
|
5
5
|
<span class="page<%=' current' if (date.between? begin_date, begin_date.end_of_week) %>">
|
6
|
-
<%= link_to_unless (date.between? begin_date, begin_date.end_of_week), "#{begin_date.strftime('%Y-%m-%d')} ~ #{begin_date.end_of_week.strftime('%Y-%m-%d')}", year: begin_date.year, month: begin_date.month, day: begin_date.day %>
|
6
|
+
<%= link_to_unless (date.between? begin_date, begin_date.end_of_week), "#{begin_date.strftime('%Y-%m-%d')} ~ #{begin_date.end_of_week.strftime('%Y-%m-%d')}", params.merge(year: begin_date.year, month: begin_date.month, day: begin_date.day) %>
|
7
7
|
</span>
|
8
8
|
<% end %>
|
9
9
|
</nav>
|
@@ -7,6 +7,8 @@ module DatePaginate
|
|
7
7
|
class Paginator
|
8
8
|
include ::ActionView::Context
|
9
9
|
|
10
|
+
PARAM_KEY_BLACKLIST = :authenticity_token, :commit, :utf8, :_method
|
11
|
+
|
10
12
|
def self.paginate_type_list
|
11
13
|
[:days, :weeks, :months]
|
12
14
|
end
|
@@ -23,6 +25,7 @@ module DatePaginate
|
|
23
25
|
@date_paginate_type = @options.delete(:date_paginate_type)
|
24
26
|
@num_pages = @options.delete(:num_pages)
|
25
27
|
@options["recent_#{@date_paginate_type}".to_sym] = send("recent_#{@date_paginate_type}")
|
28
|
+
@params = template.params.except(*PARAM_KEY_BLACKLIST).merge(@options.delete(:params) || {})
|
26
29
|
end
|
27
30
|
|
28
31
|
paginate_type_list.each do |date_paginate_type|
|
@@ -53,7 +56,8 @@ module DatePaginate
|
|
53
56
|
private :method_missing
|
54
57
|
|
55
58
|
def to_s(locals = {})
|
56
|
-
|
59
|
+
locals = @options.merge(params: @params).merge(locals)
|
60
|
+
@template.render :partial => partial_path, :locals => locals, :formats => [:html]
|
57
61
|
end
|
58
62
|
end
|
59
63
|
end
|
@@ -8,6 +8,11 @@ describe DiariesController do
|
|
8
8
|
get "index", year: Time.current.months_ago(1).year, month: Time.current.months_ago(1).month
|
9
9
|
expect(response.body.scan(/<a href=\"\/diaries\?.+">/).size).to eq(5)
|
10
10
|
end
|
11
|
+
|
12
|
+
it "with other params" do
|
13
|
+
get "index", status: 0, year: Time.current.months_ago(1).year, month: Time.current.months_ago(1).month
|
14
|
+
expect(response.body.scan(/<a href=\"\/diaries\?.+status=0.+">/).size).to eq(5)
|
15
|
+
end
|
11
16
|
end
|
12
17
|
|
13
18
|
describe "set_week" do
|
@@ -15,6 +20,11 @@ describe DiariesController do
|
|
15
20
|
get "week_partition", year: Time.current.year, month: Time.current.month, day: Time.current.day
|
16
21
|
expect(response.body.scan(/<a href=\"\/diaries\/week_partition\/archive\/\d+\/\d+\/\d+\">/).size).to eq(5)
|
17
22
|
end
|
23
|
+
|
24
|
+
it "with other params" do
|
25
|
+
get "week_partition", status: 0, year: Time.current.year, month: Time.current.month, day: Time.current.day
|
26
|
+
expect(response.body.scan(/<a href=\"\/diaries\/week_partition\/archive\/\d+\/\d+\/\d+\?status=0\">/).size).to eq(5)
|
27
|
+
end
|
18
28
|
end
|
19
29
|
|
20
30
|
describe "set_date" do
|
@@ -22,5 +32,10 @@ describe DiariesController do
|
|
22
32
|
get "day_partition", year: Time.current.year, month: Time.current.month, day: Time.current.day
|
23
33
|
expect(response.body.scan(/<a href=\"\/diaries\/day_partition\/archive\/\d+\/\d+\/\d+\">/).size).to eq(2)
|
24
34
|
end
|
35
|
+
|
36
|
+
it "with other params" do
|
37
|
+
get "week_partition", status: 0, year: Time.current.year, month: Time.current.month, day: Time.current.day
|
38
|
+
expect(response.body.scan(/<a href=\"\/diaries\/week_partition\/archive\/\d+\/\d+\/\d+\?status=0\">/).size).to eq(5)
|
39
|
+
end
|
25
40
|
end
|
26
41
|
end
|