Merge pull request #70 from tyrauber/non-restful-controller-support
Non-restful controller support
This commit is contained in:
commit
d3a52b18cf
|
@ -10,11 +10,12 @@ class Impression < ActiveRecord::Base
|
||||||
private
|
private
|
||||||
|
|
||||||
def update_impressions_counter_cache
|
def update_impressions_counter_cache
|
||||||
|
if self.impressionable_type && self.impressionable_id
|
||||||
impressionable_class = self.impressionable_type.constantize
|
impressionable_class = self.impressionable_type.constantize
|
||||||
|
|
||||||
if impressionable_class.impressionist_counter_cache_options
|
if impressionable_class.impressionist_counter_cache_options
|
||||||
resouce = impressionable_class.find(self.impressionable_id)
|
resouce = impressionable_class.find(self.impressionable_id)
|
||||||
resouce.try(:update_impressionist_counter_cache)
|
resouce.try(:update_impressionist_counter_cache)
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
|
end
|
||||||
|
|
|
@ -3,4 +3,6 @@ class DummyController < ActionController::Base
|
||||||
|
|
||||||
impressionist
|
impressionist
|
||||||
|
|
||||||
|
def index
|
||||||
|
end
|
||||||
end
|
end
|
||||||
|
|
|
@ -1,3 +1,3 @@
|
||||||
TestApp::Application.routes.draw do
|
TestApp::Application.routes.draw do
|
||||||
resources :articles, :posts, :widgets
|
resources :articles, :posts, :widgets, :dummy
|
||||||
end
|
end
|
||||||
|
|
|
@ -123,3 +123,12 @@ describe WidgetsController do
|
||||||
end
|
end
|
||||||
|
|
||||||
end
|
end
|
||||||
|
describe DummyController do
|
||||||
|
fixtures :impressions
|
||||||
|
render_views
|
||||||
|
|
||||||
|
it "should log impression at the per action level on non-restful controller" do
|
||||||
|
get "index"
|
||||||
|
Impression.all.size.should eq 12
|
||||||
|
end
|
||||||
|
end
|
Loading…
Reference in New Issue