Commit 6ee575f14a67dd175035143ec9c1e1847af25d16

Authored by Braulio Bhavamitra
1 parent 7e00c87c

rails4: fix init (upgrade cucumber) and fix some scenarios

Gemfile
... ... @@ -53,9 +53,10 @@ group :test do
53 53 end
54 54  
55 55 group :cucumber do
56   - gem 'cucumber-rails', '~> 1.0.6', :require => false
57 56 gem 'capybara', '~> 2.1.0'
58   - gem 'cucumber', '~> 1.0.6'
  57 + gem 'launchy'
  58 + gem 'cucumber', '~> 1.3.20'
  59 + gem 'cucumber-rails', '~> 1.4.2', :require => false
59 60 gem 'database_cleaner', '~> 1.2.0'
60 61 gem 'selenium-webdriver', '~> 2.39.0'
61 62 end
... ...
app/views/search/_article_description.html.erb
... ... @@ -6,7 +6,7 @@
6 6 <% if !article.body.blank? %>
7 7 <% description = strip_tags(article.body.to_s) %>
8 8 <% description.gsub!(/\s{2,}/, ' ') %>
9   - <% description = excerpt(description, description.first(3), 200) %>
  9 + <% description = excerpt description, description.first(3), radius: 200 %>
10 10  
11 11 <td class="search-article-body"><%= description %></td>
12 12 <% else %>
... ...
app/views/search/_full_enterprise.html.erb
... ... @@ -12,7 +12,7 @@
12 12 <% elsif enterprise.home_page and enterprise.home_page.body %>
13 13 <% body_stripped = strip_tags(enterprise.home_page.body) %>
14 14 <% end %>
15   - <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %>
  15 + <%= excerpt body_stripped, body_stripped.first(3), radius: 200 if body_stripped %>
16 16 </div>
17 17 <div class="search-enterprise-region">
18 18 <span class="search-enterprise-region-label"><%= _("City") %></span>
... ...
app/views/search/_full_product.html.erb
... ... @@ -49,7 +49,7 @@
49 49 <div class="search-product-description">
50 50 <% if product.description %>
51 51 <% desc_stripped = strip_tags(product.description) %>
52   - <span class="search-field-label"><%= _('Description') %> </span><%= excerpt(desc_stripped, desc_stripped.first(3), 300) %>
  52 + <span class="search-field-label"><%= _('Description') %> </span><%= excerpt desc_stripped, desc_stripped.first(3), radius: 300 %>
53 53 <% end %>
54 54 </div>
55 55 </div>
... ...
app/views/search/_image.html.erb
... ... @@ -26,7 +26,7 @@
26 26 <% end %>
27 27 <% elsif image.is_a? Gallery %>
28 28 <div class="search-gallery-items">
29   - <% r = image.children.order(updated_at).where('type = ?', 'UploadedFile').last(3) %>
  29 + <% r = image.children.order(:updated_at).where('type = ?', 'UploadedFile').last(3) %>
30 30 <% if r.length > 0 %>
31 31 <% r.each_index do |i| img = r[i] %>
32 32 <%= link_to '', img.view_url, :class => "search-image-pic pic-num#{i+1}",
... ...
features/step_definitions/content_steps.rb
... ... @@ -3,7 +3,7 @@ When /^I create a content of type &quot;([^\&quot;]*)&quot; with the following data$/ do |conte
3 3 click_link content_type
4 4  
5 5 fields.rows_hash.each do |name, value|
6   - When %{I fill in "#{name}" with "#{value}"}
  6 + step %{I fill in "#{name}" with "#{value}"}
7 7 end
8 8  
9 9 click_button "Save"
... ... @@ -19,4 +19,4 @@ And /^I add to &quot;([^\&quot;]*)&quot; the following exception &quot;([^\&quot;]*)&quot;$/ do |article_name,
19 19  
20 20 article.article_privacy_exceptions << my_user
21 21 article.save
22   -end
23 22 \ No newline at end of file
  23 +end
... ...
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)
... ... @@ -9,19 +9,19 @@ Given /^I create community &quot;(.+)&quot;$/ do |community|
9 9 end
10 10  
11 11 Given /^I approve community "(.+)"$/ do |community|
12   - task = CreateCommunity.all.select {|c| c.name == community}.first
13   - Given %{I go to admin_user's control panel}
14   - click_link('Process requests')
15   - choose("decision-finish-#{task.id}")
16   - first(:button, 'Apply!').click
  12 + task = CreateCommunity.all.select {|c| c.name == community}.first
  13 + step %{I go to admin_user's control panel}
  14 + click_link('Process requests')
  15 + choose("decision-finish-#{task.id}")
  16 + first(:button, 'Apply!').click
17 17 end
18 18  
19 19 Given /^I reject community "(.+)"$/ do |community|
20   - task = CreateCommunity.all.select {|c| c.name == community}.first
21   - Given %{I go to admin_user's control panel}
22   - click_link('Process requests')
23   - choose("decision-cancel-#{task.id}")
24   - first(:button, 'Apply!').click
  20 + task = CreateCommunity.all.select {|c| c.name == community}.first
  21 + step %{I go to admin_user's control panel}
  22 + click_link('Process requests')
  23 + choose("decision-cancel-#{task.id}")
  24 + first(:button, 'Apply!').click
25 25 end
26 26  
27 27 Then /^I should see "([^\"]*)"'s creation date$/ do |community|
... ...
features/step_definitions/documentation_steps.rb
1   -require File.join(Rails.root, 'test', 'noosfero_doc_test')
  1 +require File.join(Rails.root, 'test', 'support', 'noosfero_doc_test')
2 2 include Noosfero::DocTest
3 3  
4 4 Given 'the documentation is built' do
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -286,13 +286,13 @@ Given /^the following price details?$/ do |table|
286 286 end
287 287  
288 288 Given /^I am logged in as "(.+)"$/ do |username|
289   - Given %{I go to logout page}
290   - And %{I go to login page}
291   - And %{I fill in "main_user_login" with "#{username}"}
292   - And %{I fill in "user_password" with "123456"}
293   - When %{I press "Log in"}
294   - And %{I go to #{username}'s control panel}
295   - Then %{I should be on #{username}'s control panel}
  289 + step %{I go to logout page}
  290 + step %{I go to login page}
  291 + step %{I fill in "main_user_login" with "#{username}"}
  292 + step %{I fill in "user_password" with "123456"}
  293 + step %{I press "Log in"}
  294 + step %{I go to #{username}'s control panel}
  295 + step %{I should be on #{username}'s control panel}
296 296 @current_user = username
297 297 end
298 298  
... ... @@ -331,8 +331,9 @@ Given /^organization_approval_method is &quot;(.+)&quot; on environment$/ do |approval_met
331 331 e.save
332 332 end
333 333  
334   -Given /^"(.+)" is a member of "(.+)"$/ do |person,profile|
335   - Profile.find_by_name(profile).add_member(Profile.find_by_name(person))
  334 +Given /^"(.+)" is a member of "(.+)"$/ do |person, profile|
  335 + person, profile = Profile.where(name: person).first, Profile.where(name: profile).first
  336 + profile.affiliate person, Profile::Roles.member(profile.environment.id)
336 337 end
337 338  
338 339 Then /^"(.+)" should be a member of "(.+)"$/ do |person,profile|
... ... @@ -459,13 +460,13 @@ Given /^the following environment configuration$/ do |table|
459 460 end
460 461  
461 462 Then /^I should be logged in as "(.+)"$/ do |username|
462   - When %{I go to #{username}'s control panel}
463   - Then %{I should be on #{username}'s control panel}
  463 + step %{I go to #{username}'s control panel}
  464 + step %{I should be on #{username}'s control panel}
464 465 end
465 466  
466 467 Then /^I should not be logged in as "(.+)"$/ do |username|
467   - When %{I go to #{username}'s control panel}
468   - Then %{I should be on login page}
  468 + step %{I go to #{username}'s control panel}
  469 + step %{I should be on login page}
469 470 end
470 471  
471 472 Given /^the profile "(.+)" has no blocks$/ do |profile|
... ... @@ -637,9 +638,9 @@ Given /^the following tags$/ do |table|
637 638 end
638 639  
639 640 When /^I search ([^\"]*) for "([^\"]*)"$/ do |asset, query|
640   - When %{I go to the search #{asset} page}
641   - And %{I fill in "search-input" with "#{query}"}
642   - And %{I press "Search"}
  641 + step %{I go to the search #{asset} page}
  642 + step %{I fill in "search-input" with "#{query}"}
  643 + step %{I press "Search"}
643 644 end
644 645  
645 646 Then /^I should see ([^\"]*)'s product image$/ do |product_name|
... ...
features/step_definitions/web_steps.rb
... ... @@ -69,7 +69,7 @@ end
69 69 When /^(?:|I )fill in the following(?: within "([^"]*)")?:$/ do |selector, fields|
70 70 with_scope(selector) do
71 71 fields.rows_hash.each do |name, value|
72   - When %{I fill in "#{name}" with "#{value}"}
  72 + step %{I fill in "#{name}" with "#{value}"}
73 73 end
74 74 end
75 75 end
... ...
features/support/debug.rb 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +
  2 +# `LAUNCHY=1 cucumber` to open page on failure
  3 +After do |scenario|
  4 + save_and_open_page if ENV['LAUNCHY'] and scenario.failed?
  5 +end
  6 +
  7 +# `FAST=1 cucumber` to stop on first failure
  8 +After do |scenario|
  9 + Cucumber.wants_to_quit = ENV['FAST'] and scenario.failed?
  10 +end
  11 +
  12 +# `DEBUG=1 cucumber` to drop into debugger
  13 +Before do |scenario|
  14 + next unless ENV['DEBUG']
  15 + puts "Debugging scenario: #{scenario.title}"
  16 + if respond_to? :debugger
  17 + debugger
  18 + elsif binding.respond_to? :pry
  19 + binding.pry
  20 + else
  21 + puts "Can't find debugger or pry to debug"
  22 + end
  23 +end
... ...
features/support/env.rb
... ... @@ -4,9 +4,8 @@
4 4 # instead of editing this one. Cucumber will automatically load all features/**/*.rb
5 5 # files.
6 6  
7   -require 'cucumber/rails'
8   -
9 7 require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
  8 +require 'cucumber/rails'
10 9  
11 10 Capybara.ignore_hidden_elements = true
12 11  
... ... @@ -16,8 +15,8 @@ Capybara.ignore_hidden_elements = true
16 15 # Capybara.default_selector = :xpath
17 16  
18 17 # By default, any exception happening in your Rails application will bubble up
19   -# to Cucumber so that your scenario will fail. This is a different from how
20   -# your application behaves in the production environment, where an error page will
  18 +# to Cucumber so that your scenario will fail. This is a different from how
  19 +# your application behaves in the production environment, where an error page will
21 20 # be rendered instead.
22 21 #
23 22 # Sometimes we want to override this default behaviour and allow Rails to rescue
... ...
plugins/community_track/lib/community_track_plugin/track_helper.rb
... ... @@ -8,7 +8,7 @@ module CommunityTrackPlugin::TrackHelper
8 8  
9 9 def track_card_lead(track)
10 10 lead_stripped = strip_tags(track.lead)
11   - excerpt(lead_stripped, lead_stripped.first(3), track.image ? 180 : 300)
  11 + excerpt lead_stripped, lead_stripped.first(3), radius: if track.image then 180 else 300 end
12 12 end
13 13  
14 14 def track_color_style(track)
... ...
plugins/sub_organizations/views/sub_organizations_plugin_profile/_full_related_organizations.html.erb
... ... @@ -17,7 +17,7 @@
17 17 <% elsif organization.home_page and organization.home_page.body %>
18 18 <% body_stripped = strip_tags(organization.home_page.body) %>
19 19 <% end %>
20   - <%= excerpt(body_stripped, body_stripped.first(3), 200) if body_stripped %>
  20 + <%= excerpt body_stripped, body_stripped.first(3), radius: 200 if body_stripped %>
21 21 </div>
22 22 <div class="related-organizations-region">
23 23 <span class="related-organizations-region-label"><%= c_("City") %></span>
... ...