mirror of
https://github.com/kbparagua/paloma
synced 2023-03-27 23:21:17 -04:00
104 lines
3.2 KiB
Ruby
104 lines
3.2 KiB
Ruby
require 'spec_helper'
|
|
|
|
feature 'Callbacks' do
|
|
|
|
it 'should execute [articles][new] callback', :js => true do
|
|
visit new_article_path
|
|
|
|
page.has_selector?('#from-articles-new-callback').should == true
|
|
end
|
|
|
|
|
|
it 'should execute callbacks for [articles][create] and [articles][show]', :js => true do
|
|
visit new_article_path
|
|
|
|
fill_in 'article[title]', :with => 'sexy paloma'
|
|
fill_in 'article[body]', :with => 'sexy paloma body'
|
|
click_button 'Save'
|
|
|
|
page.has_selector?('#from-articles-create-callback').should == true
|
|
page.has_selector?('#from-articles-show-callback').should == true
|
|
end
|
|
|
|
|
|
it 'should execute "new" callback instead of "create" after failed save', :js => true do
|
|
visit new_article_path
|
|
|
|
fill_in 'article[body]', :with => 'sexy paloma body'
|
|
click_button 'Save'
|
|
|
|
page.has_selector?('#from-articles-create-callback').should == false
|
|
page.has_selector?('#from-articles-new-callback').should == true
|
|
end
|
|
|
|
|
|
it 'should have an access on the passed parameters on js_callback', :js => true do
|
|
1.upto(30) do |i|
|
|
Article.create :title => "Sexy Paloma #{i}", :body => "Sexy Body"
|
|
end
|
|
|
|
visit articles_path
|
|
page.has_selector?('#article-count-30').should == true
|
|
end
|
|
|
|
|
|
it 'should not execute [articles][update] callback', :js => true do
|
|
article = Article.create :title => "Sexy Paloma Baby!", :body => "OMG"
|
|
|
|
visit edit_article_path(article)
|
|
fill_in 'article[body]', :with => 'Updated Body'
|
|
click_button 'Save'
|
|
|
|
page.has_selector?('#from-articles-update-callback').should == false
|
|
page.has_selector?('#from-articles-show-callback').should == true
|
|
end
|
|
|
|
|
|
it 'should execute [articles][edit] callback after failed update', :js => true do
|
|
article = Article.create :title => 'Sexy Paloma Baby!', :body => 'Yeah'
|
|
|
|
visit edit_article_path(article)
|
|
fill_in 'article[title]', :with => ''
|
|
click_button 'Save'
|
|
|
|
page.has_selector?('#from-articles-edit-callback').should == true
|
|
end
|
|
|
|
|
|
it 'should execute [sample_namespace/categories][index] callback', :js => true do
|
|
1.upto(10).each { |i| Category.create :name => "Category #{i}" }
|
|
|
|
visit sample_namespace_categories_path
|
|
page.has_selector?('#from-categories-index').should == true
|
|
end
|
|
|
|
|
|
it 'should execute [sample_namespace/categories][index] callback instead of new callback', :js => true do
|
|
visit new_sample_namespace_category_path
|
|
|
|
page.has_selector?('#from-categories-index').should == true
|
|
end
|
|
|
|
|
|
it 'should receive the controller and action name on params automatically', :js => true do
|
|
article = Article.create :title => 'Sexylicious', :body => 'Yeah'
|
|
|
|
visit article_path(article)
|
|
|
|
page.has_selector?('#controller-and-action-received').should == true
|
|
end
|
|
|
|
|
|
it 'should receive the controller with namespace and action name on params automatically', :js => true do
|
|
visit sample_namespace_categories_path
|
|
|
|
page.has_selector?('#controller-with-namespace-and-action-received').should == true
|
|
end
|
|
|
|
|
|
it 'should receive the callback controller and action name on params automatically', :js => true do
|
|
visit new_article_path
|
|
|
|
page.has_selector?('#callback-details-received').should == true
|
|
end
|
|
end
|