spec/zen/package/settings/controller/settings.rb in zen-0.3 vs spec/zen/package/settings/controller/settings.rb in zen-0.4

- old
+ new

@@ -1,50 +1,52 @@ require File.expand_path('../../../../../helper', __FILE__) require File.join(Zen::FIXTURES, 'package', 'settings', 'controller', 'settings') -describe("Settings::Controller::Settings") do +describe "Settings::Controller::Settings" do behaves_like :capybara index_url = Settings::Controller::Settings.r(:index).to_s save_button = lang('settings.buttons.save') - it('Submit a form without a CSRF token') do - response = page.driver.post( - Settings::Controller::Settings.r(:save).to_s - ) + it 'Try to change settings without a valid CSRF token' do + visit(index_url) - response.body.include?(lang('zen_general.errors.csrf')).should == true - response.status.should == 403 + within '#setting_form' do + find('input[name="csrf_token"]').set('') + click_on(save_button) + end + + page.has_content?(lang('zen_general.errors.csrf')).should == true end - it('Update a set of settings') do + it 'Update a set of settings' do visit(index_url) - within('#setting_form') do + within '#setting_form' do fill_in('website_name', :with => 'Zen spec') click_on(save_button) end page.find('input[name="website_name"]').value.should == 'Zen spec' - within('#setting_form') do + within '#setting_form' do fill_in('website_name', :with => 'Zen') click_on(save_button) end page.find('input[name="website_name"]').value.should == 'Zen' end - it('Update a setting using checkboxes') do + it 'Update a setting using checkboxes' do visit(index_url) page.has_selector?('input[type="checkbox"]').should == true page.has_selector?('input[type="checkbox"][value="value"]').should == true page.has_selector?('input[type="checkbox"][value="value1"]').should == true - within('#setting_form') do + within '#setting_form' do check('form_checkbox_0') check('form_checkbox_1') click_on(save_button) end @@ -56,18 +58,18 @@ value.is_a?(Array).should == true value.include?('value').should == true value.include?('value1').should == true end - it('Update a setting using a select box with multiple values') do + it 'Update a setting using a select box with multiple values' do visit(index_url) page.has_selector?('select[multiple="multiple"]').should == true page.has_selector?('option[value="value"]').should == true page.has_selector?('option[value="value1"]').should == true - within('#setting_form') do + within '#setting_form' do select('Label', :from => 'form_select_multiple') select('Label 1', :from => 'form_select_multiple') click_on(save_button) end @@ -78,19 +80,19 @@ value.include?('value').should == true value.include?('value1').should == true end - it('Call the event after_edit_setting') do + it 'Call the event after_edit_setting' do event_name = nil Zen::Event.listen(:after_edit_setting) do |setting| event_name = setting.value if setting.name == :website_name end visit(index_url) - within('#setting_form') do + within '#setting_form' do click_on(save_button) end page.find('input[name="website_name"]').value.should == 'Zen' event_name.should == 'Zen'