Commit e1da1211043b549714804cd3bffc05b680e6fea9

Authored by Victor Costa
1 parent c7479e4d

rails3: fix some cucumber tests

app/controllers/public/content_viewer_controller.rb
@@ -118,7 +118,7 @@ class ContentViewerController < ApplicationController @@ -118,7 +118,7 @@ class ContentViewerController < ApplicationController
118 end 118 end
119 119
120 def article_versions 120 def article_versions
121 - path = params[:page].join('/') 121 + path = params[:page]
122 @page = profile.articles.find_by_path(path) 122 @page = profile.articles.find_by_path(path)
123 return unless allow_access_to_page(path) 123 return unless allow_access_to_page(path)
124 124
app/helpers/application_helper.rb
@@ -764,6 +764,10 @@ module ApplicationHelper @@ -764,6 +764,10 @@ module ApplicationHelper
764 (field_helpers - %w(hidden_field)).each do |selector| 764 (field_helpers - %w(hidden_field)).each do |selector|
765 src = <<-END_SRC 765 src = <<-END_SRC
766 def #{selector}(field, *args, &proc) 766 def #{selector}(field, *args, &proc)
  767 + begin
  768 + object ||= @template.instance_variable_get("@"+object_name.to_s)
  769 + rescue
  770 + end
767 text = object.class.respond_to?(:human_attribute_name) && object.class.human_attribute_name(field.to_s) || field.to_s.humanize 771 text = object.class.respond_to?(:human_attribute_name) && object.class.human_attribute_name(field.to_s) || field.to_s.humanize
768 NoosferoFormBuilder::output_field(text, super) 772 NoosferoFormBuilder::output_field(text, super)
769 end 773 end
app/models/blog.rb
@@ -55,7 +55,7 @@ class Blog &lt; Folder @@ -55,7 +55,7 @@ class Blog &lt; Folder
55 if self.external_feed(true) && self.external_feed.id == self.external_feed_data[:id].to_i 55 if self.external_feed(true) && self.external_feed.id == self.external_feed_data[:id].to_i
56 self.external_feed.attributes = self.external_feed_data 56 self.external_feed.attributes = self.external_feed_data
57 else 57 else
58 - self.build_external_feed(self.external_feed_data) 58 + self.build_external_feed(self.external_feed_data, :without_protection => true)
59 end 59 end
60 self.external_feed.valid? 60 self.external_feed.valid?
61 self.external_feed.errors.delete(:blog_id) # dont validate here relation: external_feed <-> blog 61 self.external_feed.errors.delete(:blog_id) # dont validate here relation: external_feed <-> blog
app/models/domain.rb
@@ -2,7 +2,7 @@ require &#39;noosfero/multi_tenancy&#39; @@ -2,7 +2,7 @@ require &#39;noosfero/multi_tenancy&#39;
2 2
3 class Domain < ActiveRecord::Base 3 class Domain < ActiveRecord::Base
4 4
5 - attr_accessible :name 5 + attr_accessible :name, :owner
6 6
7 # relationships 7 # relationships
8 ############### 8 ###############
app/models/forum.rb
@@ -3,7 +3,7 @@ class Forum &lt; Folder @@ -3,7 +3,7 @@ class Forum &lt; Folder
3 acts_as_having_posts :order => 'updated_at DESC' 3 acts_as_having_posts :order => 'updated_at DESC'
4 include PostsLimit 4 include PostsLimit
5 5
6 - attr_accessible :has_terms_of_use 6 + attr_accessible :has_terms_of_use, :terms_of_use
7 7
8 settings_items :terms_of_use, :type => :string, :default => "" 8 settings_items :terms_of_use, :type => :string, :default => ""
9 settings_items :has_terms_of_use, :type => :boolean, :default => false 9 settings_items :has_terms_of_use, :type => :boolean, :default => false
app/models/organization.rb
1 # Represents any organization of the system 1 # Represents any organization of the system
2 class Organization < Profile 2 class Organization < Profile
3 3
4 - attr_accessible :moderated_articles, :foundation_year, :contact_person, :acronym, :legal_form, :economic_activity, :management_information, :cnpj, :display_name 4 + attr_accessible :moderated_articles, :foundation_year, :contact_person, :acronym, :legal_form, :economic_activity, :management_information, :cnpj, :display_name, :enable_contact_us
5 5
6 SEARCH_FILTERS += %w[ 6 SEARCH_FILTERS += %w[
7 more_popular 7 more_popular
app/models/product_categories_block.rb
@@ -15,7 +15,7 @@ class ProductCategoriesBlock &lt; Block @@ -15,7 +15,7 @@ class ProductCategoriesBlock &lt; Block
15 15
16 def content(args={}) 16 def content(args={})
17 profile = owner 17 profile = owner
18 - lambda do 18 + proc do
19 if @categories.nil? or @categories.length == 0 19 if @categories.nil? or @categories.length == 0
20 categories = ProductCategory.on_level().order(:name) 20 categories = ProductCategory.on_level().order(:name)
21 if @categories and @categories.length == 0 21 if @categories and @categories.length == 0
app/models/production_cost.rb
1 class ProductionCost < ActiveRecord::Base 1 class ProductionCost < ActiveRecord::Base
2 2
3 - attr_accessible :name 3 + attr_accessible :name, :owner
4 4
5 belongs_to :owner, :polymorphic => true 5 belongs_to :owner, :polymorphic => true
6 validates_presence_of :owner 6 validates_presence_of :owner
app/models/profile.rb
@@ -3,7 +3,7 @@ @@ -3,7 +3,7 @@
3 # which by default is the one returned by Environment:default. 3 # which by default is the one returned by Environment:default.
4 class Profile < ActiveRecord::Base 4 class Profile < ActiveRecord::Base
5 5
6 - attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email 6 + attr_accessible :name, :identifier, :public_profile, :nickname, :custom_footer, :custom_header, :address, :zip_code, :contact_phone, :image_builder, :description, :closed, :template_id, :environment, :lat, :lng, :is_template, :fields_privacy, :preferred_domain_id, :category_ids, :country, :city, :state, :national_region_code, :email, :contact_email, :redirect_l10n
7 7
8 # use for internationalizable human type names in search facets 8 # use for internationalizable human type names in search facets
9 # reimplement on subclasses 9 # reimplement on subclasses
app/models/validation_info.rb
1 class ValidationInfo < ActiveRecord::Base 1 class ValidationInfo < ActiveRecord::Base
2 2
3 - attr_accessible :validation_methodology, :restrictions 3 + attr_accessible :validation_methodology, :restrictions, :organization
4 4
5 validates_presence_of :validation_methodology 5 validates_presence_of :validation_methodology
6 6
features/plugins.feature
@@ -18,8 +18,8 @@ Feature: plugins @@ -18,8 +18,8 @@ Feature: plugins
18 | TestPlugin | 18 | TestPlugin |
19 And the following events of TestPlugin 19 And the following events of TestPlugin
20 | event | body | 20 | event | body |
21 - | control_panel_buttons | lambda { {:title => 'Test plugin button', :icon => '', :url => ''} } |  
22 - | profile_tabs | lambda { {:title => 'Test plugin tab', :id => 'test_plugin', :content => lambda {'Test plugin random content'} } } | 21 + | control_panel_buttons | proc { {:title => 'Test plugin button', :icon => '', :url => ''} } |
  22 + | profile_tabs | proc { {:title => 'Test plugin tab', :id => 'test_plugin', :content => proc {'Test plugin random content'} } } |
23 23
24 Scenario: a user must see the plugin\'s button in the control panel if the plugin is enabled 24 Scenario: a user must see the plugin\'s button in the control panel if the plugin is enabled
25 Given plugin Test is enabled on environment 25 Given plugin Test is enabled on environment
features/step_definitions/create_community_steps.rb
1 include DatesHelper 1 include DatesHelper
2 2
3 Given /^I create community "(.+)"$/ do |community| 3 Given /^I create community "(.+)"$/ do |community|
4 - Given %{I go to admin_user's control panel} 4 + step %{I go to admin_user's control panel}
5 click_link('Manage my groups') 5 click_link('Manage my groups')
6 click_link('Create a new community') 6 click_link('Create a new community')
7 fill_in("Name", :with => community) 7 fill_in("Name", :with => community)
@@ -10,18 +10,18 @@ end @@ -10,18 +10,18 @@ end
10 10
11 Given /^I approve community "(.+)"$/ do |community| 11 Given /^I approve community "(.+)"$/ do |community|
12 task = CreateCommunity.all.select {|c| c.name == community}.first 12 task = CreateCommunity.all.select {|c| c.name == community}.first
13 - Given %{I go to admin_user's control panel} 13 + step %{I go to admin_user's control panel}
14 click_link('Process requests') 14 click_link('Process requests')
15 choose("decision-finish-#{task.id}") 15 choose("decision-finish-#{task.id}")
16 - click_button('Apply!') 16 + first(:button, 'Apply!').click
17 end 17 end
18 18
19 Given /^I reject community "(.+)"$/ do |community| 19 Given /^I reject community "(.+)"$/ do |community|
20 task = CreateCommunity.all.select {|c| c.name == community}.first 20 task = CreateCommunity.all.select {|c| c.name == community}.first
21 - Given %{I go to admin_user's control panel} 21 + step %{I go to admin_user's control panel}
22 click_link('Process requests') 22 click_link('Process requests')
23 choose("decision-cancel-#{task.id}") 23 choose("decision-cancel-#{task.id}")
24 - click_button('Apply!') 24 + first(:button, 'Apply!').click
25 end 25 end
26 26
27 Then /^I should see "([^\"]*)"'s creation date$/ do |community| 27 Then /^I should see "([^\"]*)"'s creation date$/ do |community|
features/step_definitions/http_caching_steps.rb
@@ -13,7 +13,7 @@ Then /^there must be no cache at all$/ do @@ -13,7 +13,7 @@ Then /^there must be no cache at all$/ do
13 end 13 end
14 14
15 Then 'there must be no cookies' do 15 Then 'there must be no cookies' do
16 - cookies.should == {} 16 + cookies.to_hash.should == {}
17 end 17 end
18 18
19 Then /^there must be a cookie "(.+)"$/ do |cookie_name| 19 Then /^there must be a cookie "(.+)"$/ do |cookie_name|
features/step_definitions/noosfero_steps.rb
@@ -36,7 +36,7 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do | @@ -36,7 +36,7 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do |
36 end 36 end
37 if domain 37 if domain
38 d = Domain.new :name => domain, :owner => organization 38 d = Domain.new :name => domain, :owner => organization
39 - d.save(false) 39 + d.save(:validate => false)
40 end 40 end
41 if city 41 if city
42 c = City.find_by_name city 42 c = City.find_by_name city
@@ -79,7 +79,7 @@ Given /^the folllowing &quot;([^\&quot;]*)&quot; from &quot;([^\&quot;]*)&quot;$/ do |kind, plugin, table| @@ -79,7 +79,7 @@ Given /^the folllowing &quot;([^\&quot;]*)&quot; from &quot;([^\&quot;]*)&quot;$/ do |kind, plugin, table|
79 end 79 end
80 if domain 80 if domain
81 d = Domain.new :name => domain, :owner => organization 81 d = Domain.new :name => domain, :owner => organization
82 - d.save(false) 82 + d.save(:validate => false)
83 end 83 end
84 end 84 end
85 end 85 end
@@ -203,7 +203,7 @@ Given /^the following products?$/ do |table| @@ -203,7 +203,7 @@ Given /^the following products?$/ do |table|
203 qualifier = Qualifier.find_by_name(data.delete("qualifier")) 203 qualifier = Qualifier.find_by_name(data.delete("qualifier"))
204 data.merge!(:qualifiers => [qualifier]) 204 data.merge!(:qualifiers => [qualifier])
205 end 205 end
206 - product = Product.create!(data) 206 + product = Product.create!(data, :without_protection => true)
207 end 207 end
208 end 208 end
209 209
@@ -216,7 +216,7 @@ Given /^the following inputs?$/ do |table| @@ -216,7 +216,7 @@ Given /^the following inputs?$/ do |table|
216 solidary = data.delete("solidary") 216 solidary = data.delete("solidary")
217 input = Input.create!(data.merge(:product => product, :product_category => category, :unit => unit, 217 input = Input.create!(data.merge(:product => product, :product_category => category, :unit => unit,
218 :is_from_solidarity_economy => solidary), :without_protection => true) 218 :is_from_solidarity_economy => solidary), :without_protection => true)
219 - input.update_attributes!(:position => data['position']) 219 + input.update_attribute(:position, data['position'])
220 end 220 end
221 end 221 end
222 222
@@ -224,7 +224,7 @@ Given /^the following states$/ do |table| @@ -224,7 +224,7 @@ Given /^the following states$/ do |table|
224 table.hashes.each do |item| 224 table.hashes.each do |item|
225 data = item.dup 225 data = item.dup
226 if validator = Enterprise.find_by_name(data.delete("validator_name")) 226 if validator = Enterprise.find_by_name(data.delete("validator_name"))
227 - State.create!(data.merge(:environment => Environment.default, :validators => [validator])) 227 + State.create!(data.merge(:environment => Environment.default, :validators => [validator]), :without_protection => true)
228 else 228 else
229 r = State.create!(data.merge(:environment => Environment.default)) 229 r = State.create!(data.merge(:environment => Environment.default))
230 end 230 end
@@ -421,7 +421,7 @@ Given /^enterprise &quot;([^\&quot;]*)&quot; is disabled$/ do |enterprise_name| @@ -421,7 +421,7 @@ Given /^enterprise &quot;([^\&quot;]*)&quot; is disabled$/ do |enterprise_name|
421 end 421 end
422 422
423 Then /^the page title should be "(.*)"$/ do |text| 423 Then /^the page title should be "(.*)"$/ do |text|
424 - Then %{I should see "#{text}" within "title"} 424 + step %{I should see "#{text}" within "title"}
425 end 425 end
426 426
427 Then /^The page should contain "(.*)"$/ do |selector| 427 Then /^The page should contain "(.*)"$/ do |selector|
@@ -534,7 +534,7 @@ end @@ -534,7 +534,7 @@ end
534 534
535 Given /^the environment domain is "([^\"]*)"$/ do |domain| 535 Given /^the environment domain is "([^\"]*)"$/ do |domain|
536 d = Domain.new :name => domain, :owner => Environment.default 536 d = Domain.new :name => domain, :owner => Environment.default
537 - d.save(false) 537 + d.save(:validate => false)
538 end 538 end
539 539
540 When /^([^\']*)'s account is activated$/ do |person| 540 When /^([^\']*)'s account is activated$/ do |person|
features/step_definitions/web_steps.rb
@@ -11,7 +11,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;support&quot;, &quot;pat @@ -11,7 +11,8 @@ require File.expand_path(File.join(File.dirname(__FILE__), &quot;..&quot;, &quot;support&quot;, &quot;pat
11 11
12 module WithinHelpers 12 module WithinHelpers
13 def with_scope(locator) 13 def with_scope(locator)
14 - locator ? first(locator) { yield } : yield 14 + locator = locator ? first(locator) : locator
  15 + locator ? within(locator) { yield } : yield
15 end 16 end
16 end 17 end
17 World(WithinHelpers) 18 World(WithinHelpers)
features/support/fixture_path.rb 0 → 100644
@@ -0,0 +1,5 @@ @@ -0,0 +1,5 @@
  1 +module FixturePathHelper
  2 + def (ActionDispatch::Integration::Session).fixture_path
  3 + ActionController::TestCase.fixture_path
  4 + end
  5 +end