Skip to content

Commit bb284b7

Browse files
author
Austin Schneider
committed
remove dumb helpers
1 parent 2112fea commit bb284b7

File tree

5 files changed

+13
-89
lines changed

5 files changed

+13
-89
lines changed

app/helpers/application_helper.rb

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -20,34 +20,10 @@ def paginated_locations
2020
@paginated_locations ||= locations.paginate params[:page], CONFIG[:app][:locations_per_page]
2121
end
2222

23-
def render_paginated_locations
24-
if paginated_locations.present?
25-
render 'locations/table', locations: paginated_locations
26-
else
27-
content_tag :p, 'No URLs found.', class: 'empty'
28-
end
29-
end
30-
3123
def alerts
3224
@alerts ||= Alert.joins { location }.order { locations.title.asc }
3325
end
3426

35-
def render_alerts
36-
if alerts.present?
37-
render 'alerts/table', alerts: alerts
38-
else
39-
content_tag :p, 'No alerts found.', class: 'empty'
40-
end
41-
end
42-
43-
def render_email_callbacks
44-
if email_callbacks.present?
45-
render 'email_callbacks/table', email_callbacks: email_callbacks
46-
else
47-
content_tag :p, 'No email callbacks found.', class: 'empty'
48-
end
49-
end
50-
5127
def email_callbacks
5228
@email_callbacks ||= EmailCallback.order { label.asc }
5329
end

app/views/alerts/index.html.haml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,7 @@
11
#alerts
22
%h2 Alerts
33

4-
= render_alerts
4+
- if alerts.present?
5+
= render 'alerts/table', :alerts => alerts
6+
- else
7+
%p.empty No alerts found.

app/views/email_callbacks/index.html.haml

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,7 @@
33

44
%p= link_to 'Add email callback', new_email_callback_path
55

6-
= render_email_callbacks
6+
- if email_callbacks.present?
7+
= render 'email_callbacks/table', :email_callbacks => email_callbacks
8+
- else
9+
%p.empty No email callbacks found.

app/views/locations/index.html.haml

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,5 +8,9 @@
88
|
99
= link_to "Alerts", alerts_path
1010

11-
= render_paginated_locations
11+
- if paginated_locations.present?
12+
= render 'locations/table', :locations => paginated_locations
13+
- else
14+
%p.empty No URLs found.
15+
1216
= paginate paginated_locations

spec/helpers/application_helper_spec.rb

Lines changed: 0 additions & 62 deletions
Original file line numberDiff line numberDiff line change
@@ -33,68 +33,6 @@
3333
end
3434
end
3535

36-
describe "render_paginated_locations" do
37-
context "when there are paginated locations" do
38-
before do
39-
@locs = [double('location')]
40-
subject.stub(:paginated_locations) { @locs }
41-
end
42-
it "renders the locations table" do
43-
subject.should_receive(:render).with 'locations/table', locations: @locs
44-
subject.render_paginated_locations
45-
end
46-
end
47-
48-
context "when there are no paginated locations" do
49-
before { subject.stub :paginated_locations }
50-
it { subject.render_paginated_locations.should =~ /No URLs found/ }
51-
end
52-
end
53-
54-
describe "render_alerts" do
55-
context "when there are alerts" do
56-
before do
57-
@rendered_alerts = double('object')
58-
alerts = [double('alert')]
59-
subject.stub(:alerts) { alerts }
60-
view.stub(:render) do |*args|
61-
@rendered_alerts if args == ['alerts/table', {alerts: alerts}]
62-
end
63-
end
64-
it "renders the alerts table" do
65-
subject.render_alerts.should == @rendered_alerts
66-
end
67-
end
68-
69-
context "when there are no alerts" do
70-
before { subject.stub :alerts }
71-
it { subject.render_alerts.should =~ /No alerts found/ }
72-
end
73-
end
74-
75-
describe "render_email_callbacks" do
76-
context "when there are email callbacks" do
77-
before do
78-
@rendered_email_callbacks = double('object')
79-
email_callbacks = [double('email_callback')]
80-
subject.stub(:email_callbacks) { email_callbacks }
81-
view.stub(:render) do |*args|
82-
if args == ['email_callbacks/table', {email_callbacks: email_callbacks}]
83-
@rendered_email_callbacks
84-
end
85-
end
86-
end
87-
it "renders the email callbacks table" do
88-
subject.render_email_callbacks.should == @rendered_email_callbacks
89-
end
90-
end
91-
92-
context "when there are no email callbacks" do
93-
before { subject.stub :email_callbacks }
94-
it { subject.render_email_callbacks.should =~ /No email callbacks found/ }
95-
end
96-
end
97-
9836
describe "alerts" do
9937
context "when there are alerts" do
10038
before do

0 commit comments

Comments
 (0)