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 118 end
119 119  
120 120 def article_versions
121   - path = params[:page].join('/')
  121 + path = params[:page]
122 122 @page = profile.articles.find_by_path(path)
123 123 return unless allow_access_to_page(path)
124 124  
... ...
app/helpers/application_helper.rb
... ... @@ -764,6 +764,10 @@ module ApplicationHelper
764 764 (field_helpers - %w(hidden_field)).each do |selector|
765 765 src = <<-END_SRC
766 766 def #{selector}(field, *args, &proc)
  767 + begin
  768 + object ||= @template.instance_variable_get("@"+object_name.to_s)
  769 + rescue
  770 + end
767 771 text = object.class.respond_to?(:human_attribute_name) && object.class.human_attribute_name(field.to_s) || field.to_s.humanize
768 772 NoosferoFormBuilder::output_field(text, super)
769 773 end
... ...
app/models/blog.rb
... ... @@ -55,7 +55,7 @@ class Blog &lt; Folder
55 55 if self.external_feed(true) && self.external_feed.id == self.external_feed_data[:id].to_i
56 56 self.external_feed.attributes = self.external_feed_data
57 57 else
58   - self.build_external_feed(self.external_feed_data)
  58 + self.build_external_feed(self.external_feed_data, :without_protection => true)
59 59 end
60 60 self.external_feed.valid?
61 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 2  
3 3 class Domain < ActiveRecord::Base
4 4  
5   - attr_accessible :name
  5 + attr_accessible :name, :owner
6 6  
7 7 # relationships
8 8 ###############
... ...
app/models/forum.rb
... ... @@ -3,7 +3,7 @@ class Forum &lt; Folder
3 3 acts_as_having_posts :order => 'updated_at DESC'
4 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 8 settings_items :terms_of_use, :type => :string, :default => ""
9 9 settings_items :has_terms_of_use, :type => :boolean, :default => false
... ...
app/models/organization.rb
1 1 # Represents any organization of the system
2 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 6 SEARCH_FILTERS += %w[
7 7 more_popular
... ...
app/models/product_categories_block.rb
... ... @@ -15,7 +15,7 @@ class ProductCategoriesBlock &lt; Block
15 15  
16 16 def content(args={})
17 17 profile = owner
18   - lambda do
  18 + proc do
19 19 if @categories.nil? or @categories.length == 0
20 20 categories = ProductCategory.on_level().order(:name)
21 21 if @categories and @categories.length == 0
... ...
app/models/production_cost.rb
1 1 class ProductionCost < ActiveRecord::Base
2 2  
3   - attr_accessible :name
  3 + attr_accessible :name, :owner
4 4  
5 5 belongs_to :owner, :polymorphic => true
6 6 validates_presence_of :owner
... ...
app/models/profile.rb
... ... @@ -3,7 +3,7 @@
3 3 # which by default is the one returned by Environment:default.
4 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 8 # use for internationalizable human type names in search facets
9 9 # reimplement on subclasses
... ...
app/models/validation_info.rb
1 1 class ValidationInfo < ActiveRecord::Base
2 2  
3   - attr_accessible :validation_methodology, :restrictions
  3 + attr_accessible :validation_methodology, :restrictions, :organization
4 4  
5 5 validates_presence_of :validation_methodology
6 6  
... ...
features/plugins.feature
... ... @@ -18,8 +18,8 @@ Feature: plugins
18 18 | TestPlugin |
19 19 And the following events of TestPlugin
20 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 24 Scenario: a user must see the plugin\'s button in the control panel if the plugin is enabled
25 25 Given plugin Test is enabled on environment
... ...
features/step_definitions/create_community_steps.rb
1 1 include DatesHelper
2 2  
3 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 5 click_link('Manage my groups')
6 6 click_link('Create a new community')
7 7 fill_in("Name", :with => community)
... ... @@ -10,18 +10,18 @@ end
10 10  
11 11 Given /^I approve community "(.+)"$/ do |community|
12 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 14 click_link('Process requests')
15 15 choose("decision-finish-#{task.id}")
16   - click_button('Apply!')
  16 + first(:button, 'Apply!').click
17 17 end
18 18  
19 19 Given /^I reject community "(.+)"$/ do |community|
20 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 22 click_link('Process requests')
23 23 choose("decision-cancel-#{task.id}")
24   - click_button('Apply!')
  24 + first(:button, 'Apply!').click
25 25 end
26 26  
27 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 13 end
14 14  
15 15 Then 'there must be no cookies' do
16   - cookies.should == {}
  16 + cookies.to_hash.should == {}
17 17 end
18 18  
19 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 36 end
37 37 if domain
38 38 d = Domain.new :name => domain, :owner => organization
39   - d.save(false)
  39 + d.save(:validate => false)
40 40 end
41 41 if city
42 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 79 end
80 80 if domain
81 81 d = Domain.new :name => domain, :owner => organization
82   - d.save(false)
  82 + d.save(:validate => false)
83 83 end
84 84 end
85 85 end
... ... @@ -203,7 +203,7 @@ Given /^the following products?$/ do |table|
203 203 qualifier = Qualifier.find_by_name(data.delete("qualifier"))
204 204 data.merge!(:qualifiers => [qualifier])
205 205 end
206   - product = Product.create!(data)
  206 + product = Product.create!(data, :without_protection => true)
207 207 end
208 208 end
209 209  
... ... @@ -216,7 +216,7 @@ Given /^the following inputs?$/ do |table|
216 216 solidary = data.delete("solidary")
217 217 input = Input.create!(data.merge(:product => product, :product_category => category, :unit => unit,
218 218 :is_from_solidarity_economy => solidary), :without_protection => true)
219   - input.update_attributes!(:position => data['position'])
  219 + input.update_attribute(:position, data['position'])
220 220 end
221 221 end
222 222  
... ... @@ -224,7 +224,7 @@ Given /^the following states$/ do |table|
224 224 table.hashes.each do |item|
225 225 data = item.dup
226 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 228 else
229 229 r = State.create!(data.merge(:environment => Environment.default))
230 230 end
... ... @@ -421,7 +421,7 @@ Given /^enterprise &quot;([^\&quot;]*)&quot; is disabled$/ do |enterprise_name|
421 421 end
422 422  
423 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 425 end
426 426  
427 427 Then /^The page should contain "(.*)"$/ do |selector|
... ... @@ -534,7 +534,7 @@ end
534 534  
535 535 Given /^the environment domain is "([^\"]*)"$/ do |domain|
536 536 d = Domain.new :name => domain, :owner => Environment.default
537   - d.save(false)
  537 + d.save(:validate => false)
538 538 end
539 539  
540 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 11  
12 12 module WithinHelpers
13 13 def with_scope(locator)
14   - locator ? first(locator) { yield } : yield
  14 + locator = locator ? first(locator) : locator
  15 + locator ? within(locator) { yield } : yield
15 16 end
16 17 end
17 18 World(WithinHelpers)
... ...
features/support/fixture_path.rb 0 → 100644
... ... @@ -0,0 +1,5 @@
  1 +module FixturePathHelper
  2 + def (ActionDispatch::Integration::Session).fixture_path
  3 + ActionController::TestCase.fixture_path
  4 + end
  5 +end
... ...