[refs #576] Optimize tests, views and model

This commit is contained in:
konstantin.grabar 2012-07-24 13:19:22 +04:00
parent 15a86c2ecd
commit 3d19a4f23e
4 changed files with 9 additions and 17 deletions

View File

@ -19,6 +19,6 @@ class FlashNotify < ActiveRecord::Base
end
def should_show?(cookie_id, cookie_hash_id)
cookie_id.to_i == id && cookie_hash_id == hash_id ? false : true
!(cookie_id.to_i == id && cookie_hash_id == hash_id)
end
end

View File

@ -1,4 +1,4 @@
%h3= t("layout.flash_notifies.edit_header")
= form_for @flash_notify, :url => flash_notifies_path(@flash_notify), :html => { :class => :form } do |f|
= form_for @flash_notify, :url => flash_notify_path(@flash_notify), :html => { :class => :form } do |f|
= render "form", :f => f

View File

@ -10,8 +10,8 @@
%tbody
- @flash_notifies.each do |flash_notify|
%tr{:class => cycle("odd", "even")}
%td= flash_notify.body_en.slice(0..15) + "..."
%td= flash_notify.body_ru.slice(0..15) + "..."
%td= flash_notify.body_en.truncate 18
%td= flash_notify.body_ru.truncate 18
%td= flash_notify.published
%td
= link_to t("layout.flash_notifies.edit"), edit_flash_notify_path(flash_notify)

View File

@ -54,24 +54,16 @@ describe FlashNotifiesController do
set_session_for(@admin)
end
it 'should be able to perform index action' do
get :index
response.should render_template(:index)
end
it 'should load 2 flash notifies objects on index' do
get :index
assigns[:flash_notifies].count.should == 2
end
it 'should be able to perform new action' do
get :new
response.should render_template(:new)
[:index, :new, :edit].each do |action|
it "should be able to perform #{action} action" do
get action, :id => @flash_notify
response.should render_template(action)
end
it 'should be able to perform edit action' do
get :edit
response.should render_template(:edit)
end
it 'should be able to perform create action' do