Commit a03f0c92fac497a540d17168d944d100d4a21e7f

Authored by Victor Costa
1 parent 3b68729e

rails3: fix some cucumber tests

app/models/article.rb
... ... @@ -2,7 +2,7 @@ require 'hpricot'
2 2  
3 3 class Article < ActiveRecord::Base
4 4  
5   - attr_accessible :name, :body, :abstract, :profile, :tag_list, :parent, :allow_members_to_edit, :translation_of_id, :language, :license_id, :parent_id, :display_posts_in_current_language, :category_ids, :posts_per_page, :moderate_comments, :accept_comments, :feed, :published, :source, :highlighted, :notify_comments, :display_hits
  5 + attr_accessible :name, :body, :abstract, :profile, :tag_list, :parent, :allow_members_to_edit, :translation_of_id, :language, :license_id, :parent_id, :display_posts_in_current_language, :category_ids, :posts_per_page, :moderate_comments, :accept_comments, :feed, :published, :source, :highlighted, :notify_comments, :display_hits, :slug, :external_feed_builder
6 6  
7 7 acts_as_having_image
8 8  
... ...
app/models/block.rb
1 1 class Block < ActiveRecord::Base
2 2  
3   - attr_accessible :title, :display, :limit, :box_id
  3 + attr_accessible :title, :display, :limit, :box_id, :posts_per_page, :visualization_format, :language
4 4  
5 5 # to be able to generate HTML
6 6 include ActionView::Helpers::UrlHelper
... ...
app/models/event.rb
... ... @@ -3,7 +3,7 @@ require &#39;builder&#39;
3 3  
4 4 class Event < Article
5 5  
6   - attr_accessible :start_date, :end_date, :link
  6 + attr_accessible :start_date, :end_date, :link, :address
7 7  
8 8 def self.type_name
9 9 _('Event')
... ...
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
  4 + attr_accessible :moderated_articles, :foundation_year, :contact_person, :acronym, :legal_form, :economic_activity, :management_information, :cnpj, :display_name
5 5  
6 6 SEARCH_FILTERS += %w[
7 7 more_popular
... ...
app/models/product.rb
... ... @@ -11,7 +11,7 @@ class Product &lt; ActiveRecord::Base
11 11  
12 12 SEARCH_DISPLAYS = %w[map full]
13 13  
14   - attr_accessible :name, :product_category, :highlighted, :price, :enterprise, :image_builder, :description
  14 + attr_accessible :name, :product_category, :highlighted, :price, :enterprise, :image_builder, :description, :available, :qualifiers
15 15  
16 16 def self.default_search_display
17 17 'full'
... ...
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
  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
7 7  
8 8 # use for internationalizable human type names in search facets
9 9 # reimplement on subclasses
... ...
config/routes.rb
... ... @@ -61,7 +61,7 @@ Noosfero::Application.routes.draw do
61 61 match 'profile/:profile/events', :controller => 'events', :action => 'events', :profile => /#{Noosfero.identifier_format}/
62 62  
63 63 # catalog
64   - match 'catalog/:profile', :controller => 'catalog', :action => 'index', :profile => /#{Noosfero.identifier_format}/
  64 + match 'catalog/:profile', :controller => 'catalog', :action => 'index', :profile => /#{Noosfero.identifier_format}/, :as => :catalog
65 65  
66 66 # invite
67 67 match 'profile/:profile/invite/friends', :controller => 'invite', :action => 'select_address_book', :profile => /#{Noosfero.identifier_format}/
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -14,7 +14,7 @@ Given /^the following users?$/ do |table|
14 14 end
15 15  
16 16 Given /^"(.+)" is (invisible|visible)$/ do |user, visibility|
17   - User.find_by_login(user).person.update_attributes(:visible => (visibility == 'visible'))
  17 + User.find_by_login(user).person.update_attributes({:visible => (visibility == 'visible')}, :without_protection => true)
18 18 end
19 19  
20 20 Given /^"(.+)" is (online|offline|busy) in chat$/ do |user, status|
... ... @@ -30,7 +30,7 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do |
30 30 category = row.delete("category")
31 31 img_name = row.delete("img")
32 32 city = row.delete("region")
33   - organization = klass.create!(row)
  33 + organization = klass.create!(row, :without_protection => true)
34 34 if owner
35 35 organization.add_admin(Profile[owner])
36 36 end
... ... @@ -215,7 +215,7 @@ Given /^the following inputs?$/ do |table|
215 215 unit = Unit.find_by_singular(data.delete("unit"))
216 216 solidary = data.delete("solidary")
217 217 input = Input.create!(data.merge(:product => product, :product_category => category, :unit => unit,
218   - :is_from_solidarity_economy => solidary))
  218 + :is_from_solidarity_economy => solidary), :without_protection => true)
219 219 input.update_attributes!(:position => data['position'])
220 220 end
221 221 end
... ... @@ -247,13 +247,13 @@ Given /^the following (product_categories|product_category|category|categories|r
247 247 parent = Category.find_by_slug(parent.to_slug)
248 248 row.merge!({:parent_id => parent.id})
249 249 end
250   - category = klass.create!({:environment_id => Environment.default.id}.merge(row))
  250 + category = klass.create!({:environment => Environment.default}.merge(row))
251 251 end
252 252 end
253 253  
254 254 Given /^the following qualifiers$/ do |table|
255 255 table.hashes.each do |row|
256   - Qualifier.create!(row.merge(:environment_id => 1))
  256 + Qualifier.create!(row.merge(:environment_id => 1), :without_protection => true)
257 257 end
258 258 end
259 259  
... ... @@ -264,7 +264,7 @@ Given /^the following certifiers$/ do |table|
264 264 if qualifiers_list
265 265 row["qualifiers"] = qualifiers_list.split(', ').map{|i| Qualifier.find_by_name(i)}
266 266 end
267   - Certifier.create!(row.merge(:environment_id => 1))
  267 + Certifier.create!(row.merge(:environment_id => 1), :without_protection => true)
268 268 end
269 269 end
270 270  
... ... @@ -285,18 +285,18 @@ Given /^the following price details?$/ do |table|
285 285 end
286 286  
287 287 Given /^I am logged in as "(.+)"$/ do |username|
288   - Given %{I go to logout page}
289   - And %{I go to login page}
290   - And %{I fill in "main_user_login" with "#{username}"}
291   - And %{I fill in "user_password" with "123456"}
292   - When %{I press "Log in"}
  288 + step %{I go to logout page}
  289 + step %{I go to login page}
  290 + step %{I fill in "main_user_login" with "#{username}"}
  291 + step %{I fill in "user_password" with "123456"}
  292 + step %{I press "Log in"}
293 293 # FIXME:
294 294 # deveria apenas verificar que esta no myprofile do usuario
295 295 # nao conseguir fazer funcionar sem essa reduntancia no capybara
296 296 # acho que e algum problema com o http_referer
297 297 # olhar account_controller#store_location
298   - And %{I go to #{username}'s control panel}
299   - Then %{I should be on #{username}'s control panel}
  298 + step %{I go to #{username}'s control panel}
  299 + step %{I should be on #{username}'s control panel}
300 300 end
301 301  
302 302 Given /^"([^"]*)" is environment admin$/ do |person|
... ... @@ -512,7 +512,7 @@ end
512 512  
513 513 Given /^the following units?$/ do |table|
514 514 table.hashes.each do |row|
515   - Unit.create!(row.merge(:environment_id => 1))
  515 + Unit.create!(row.merge(:environment_id => 1), :without_protection => true)
516 516 end
517 517 end
518 518  
... ... @@ -640,9 +640,9 @@ Given /^the following tags$/ do |table|
640 640 end
641 641  
642 642 When /^I search ([^\"]*) for "([^\"]*)"$/ do |asset, query|
643   - When %{I go to the search #{asset} page}
644   - And %{I fill in "search-input" with "#{query}"}
645   - And %{I press "Search"}
  643 + step %{I go to the search #{asset} page}
  644 + step %{I fill in "search-input" with "#{query}"}
  645 + step %{I press "Search"}
646 646 end
647 647  
648 648 Then /^I should see ([^\"]*)'s product image$/ do |product_name|
... ...
features/step_definitions/web_steps.rb
... ... @@ -11,7 +11,7 @@ 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 ? within(locator) { yield } : yield
  14 + locator ? first(locator) { yield } : yield
15 15 end
16 16 end
17 17 World(WithinHelpers)
... ... @@ -26,13 +26,13 @@ end
26 26  
27 27 When /^(?:|I )press "([^"]*)"(?: within "([^"]*)")?$/ do |button, selector|
28 28 with_scope(selector) do
29   - click_button(button)
  29 + first(:button, button).click
30 30 end
31 31 end
32 32  
33 33 When /^(?:|I )follow "([^"]*)"(?: within "([^"]*)")?$/ do |link, selector|
34 34 with_scope(selector) do
35   - click_link(link)
  35 + first(:link, link).click
36 36 end
37 37 end
38 38  
... ... @@ -62,7 +62,7 @@ end
62 62 When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
63 63 with_scope(selector) do
64 64 fields.rows_hash.each do |name, value|
65   - When %{I fill in "#{name}" with "#{value}"}
  65 + step %{I fill in "#{name}" with "#{value}"}
66 66 end
67 67 end
68 68 end
... ...