Commit a9ffbc6e796603f45a96cd4559c6a3d7eda79618

Authored by Victor Costa
2 parents af6238af bad8766a

Merge branch 'master' into rails3

app/controllers/public/content_viewer_controller.rb
... ... @@ -33,6 +33,7 @@ class ContentViewerController < ApplicationController
33 33 process_forum_terms_of_use(user, params[:terms_accepted])
34 34 elsif is_a_forum_topic?(@page)
35 35 redirect_to @page.parent.url unless @page.parent.agrees_with_terms?(user)
  36 + return
36 37 end
37 38  
38 39 # At this point the page will be showed
... ...
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, :slug, :external_feed_builder, :display_versions
  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, :display_versions, :external_link
6 6  
7 7 acts_as_having_image
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, :terms_of_use
  6 + attr_accessible :has_terms_of_use, :terms_of_use, :allows_members_to_create_topics
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/input.rb
1 1 class Input < ActiveRecord::Base
2 2  
3   - attr_accessible :product, :product_category
  3 + attr_accessible :product, :product_category, :product_category_id, :amount_used, :unit_id, :price_per_unit, :relevant_to_price
4 4  
5 5 belongs_to :product
6 6 belongs_to :product_category
... ...
app/views/comment/_comment_form.html.erb
... ... @@ -46,14 +46,16 @@ function check_captcha(button, confirm_action) {
46 46 }
47 47 </script>
48 48  
49   -<% if @comment && @comment.errors.any? %>
  49 +<% @comment ||= Comment.new %>
  50 +
  51 +<% if @comment.errors.any? %>
50 52 <%= error_messages_for :comment %>
51 53 <% end %>
52 54  
53 55 <div class="post_comment_box <%= ((defined? show_form) && show_form) ? 'opened' : 'closed' %>">
54 56  
55 57 <%= link_to(_('Post a comment'), '#', :class => 'display-comment-form') if display_link && @comment.reply_of_id.blank? %>
56   -<%= remote_form_for(:comment, comment, :url => {:profile => profile.identifier, :controller => 'comment', :action => (edition_mode ? 'update' : 'create'), :id => (edition_mode ? comment.id : @page.id)}, :html => { :class => 'comment_form' } ) do |f| %>
  58 +<%= remote_form_for(:comment, @comment, :url => {:profile => profile.identifier, :controller => 'comment', :action => (edition_mode ? 'update' : 'create'), :id => (edition_mode ? @comment.id : @page.id)}, :html => { :class => 'comment_form' } ) do |f| %>
57 59  
58 60 <%= required_fields_message %>
59 61  
... ...
app/views/content_viewer/view_page.html.erb
... ... @@ -80,7 +80,7 @@
80 80 </h3>
81 81 <% end %>
82 82  
83   - <% if @page.accept_comments? && @comments.count > 1 %>
  83 + <% if @page.accept_comments? && @comments.present? && @comments.count > 1 %>
84 84 <%= link_to(_('Post a comment'), '#', :class => 'display-comment-form', :id => 'top-post-comment-button', :onclick => "jQuery('#page-comment-form .display-comment-form').first().click();") %>
85 85  
86 86 <%= hidden_field_tag("page_url", url_for(:controller=>'content_viewer', :action=>'view_page', :profile=>profile.identifier, :page => @page.explode_path)) %>
... ... @@ -90,15 +90,15 @@
90 90 <%= select_tag 'comment_order', options_for_select({_('Oldest first')=>'oldest', _('Newest first')=>'newest'}, @comment_order) %>
91 91 <% end %>
92 92 </div>
93   - <% end %>
94 93  
95   - <ul class="article-comments-list">
96   - <%= render :partial => 'comment/comment', :collection => @comments %>
97   - <%= pagination_links @comments, :param_name => 'comment_page' %>
98   - </ul>
  94 + <ul class="article-comments-list">
  95 + <%= render :partial => 'comment/comment', :collection => @comments %>
  96 + <%= pagination_links @comments, :param_name => 'comment_page' %>
  97 + </ul>
  98 + <% end %>
99 99  
100 100 <% if @page.accept_comments? %>
101   - <div id='page-comment-form' class='page-comment-form'><%= render :partial => 'comment/comment_form', :locals =>{:comment => Comment.new, :url => {:controller => :comment, :action => :create}, :display_link => true, :cancel_triggers_hide => true}%></div>
  101 + <div id='page-comment-form' class='page-comment-form'><%= render :partial => 'comment/comment_form', :locals =>{:url => {:controller => :comment, :action => :create}, :display_link => true, :cancel_triggers_hide => true}%></div>
102 102 <% end %>
103 103 </div><!-- end class="comments" -->
104 104  
... ...
app/views/invite/_dialog_wait_loading.html.erb
1   -<% javascript_tag do %>
  1 +<%= javascript_tag do %>
2 2 jQuery(function($) {
3 3 $("#loading-dialog").dialog({
4 4 height: 160,
... ...
app/views/invite/select_friends.html.erb
... ... @@ -32,9 +32,7 @@
32 32  
33 33 <br/>
34 34  
35   - <%= link_to_function(_('Personalize invitation mail'), nil) do |page|
36   - page['invitation-mail_template'].show
37   - end %>
  35 + <%= link_to ('Personalize invitation mail'), nil, :onclick => "jQuery('#invitation-mail_template').show(); return false;" %>
38 36  
39 37 <div id='invitation-mail_template' style='display:none'>
40 38 <%= h _("Now enter an invitation message. You must keep the <url> code in your invitation text. When your friends receive the invitation e-mail, <url> will be replaced by a link that they need to click to activate their account. <user> and <friend> codes will be replaced by your name and friend name, but they are optional.") %>
... ...
app/views/manage_products/_add_input.html.erb
1 1 <div id='request_result_message' style='display: none'></div>
2 2  
3   -<%= form_for(@input,
  3 +<%= form_for(:input,
4 4 :url => {:action => 'add_input', :id => @product},
5 5 :html => {:method => 'post', :id => 'input-category-form'}
6 6 ) do |f| %>
... ...
app/views/manage_products/_categories_for_selection.html.erb
1 1 <%= select_for_categories(categories, level) %>
2 2  
3   -<% javascript_tag do %>
  3 +<%= javascript_tag do %>
4 4 jQuery('#categories_container_wrapper').scrollTo('100%', 1000)
5 5 $('selected_category_id').value = <%= @category && @category.id %>
6 6 $('hierarchy_navigation').update('<%= escape_javascript(hierarchy_category_navigation(@category, :make_links => true)) %>')
... ...
app/views/manage_products/_certifiers_for_selection.html.erb
1 1 <%= select_certifiers(@qualifier) + remove_qualifier_button %>
2   -<% javascript_tag do %>
  2 +<%= javascript_tag do %>
3 3 jQuery('#product-qualifiers-list *').removeClass('small-loading')
4 4 <% end %>
... ...
app/views/manage_products/_display_name.html.erb
... ... @@ -2,7 +2,7 @@
2 2 <h2><%= @product.name_with_unit %></h2>
3 3 <%= edit_product_link_to_remote(@product, 'name', _('Edit name and unit'), :title => _('Click here to edit the name of your product and the unit')) %>
4 4 </div>
5   -<% javascript_tag do %>
  5 +<%= javascript_tag do %>
6 6 $$('#display-product-category .hierarchy-category')[0].update('<%=
7 7 escape_javascript(hierarchy_category_navigation(
8 8 @product.product_category,
... ...
app/views/manage_products/_edit_input.html.erb
1   -<%= form_for(@input, :url => {:controller => 'manage_products', :action => 'edit_input', :id => @input},
  1 +<%= form_for(:input, :url => {:controller => 'manage_products', :action => 'edit_input', :id => @input},
2 2 :html => {:method => 'post', :id => "edit-input-#{ @input.id }-form"}) do |f| %>
3 3  
4 4 <%= hidden_field_tag 'input-bar-update-url', @input.product.price_composition_bar_display_url, :class => 'bar-update-url' %>
... ...
app/views/manage_products/_form.html.erb
1 1 <%= error_messages_for :product %> <br/>
2 2  
3   -<%= form_for :product, @product, :html => {:multipart => true }, :url => {:action => mode} do |f| %>
  3 +<%= form_for :product, :html => {:multipart => true }, :url => {:action => mode} do |f| %>
4 4 <%= required_fields_message %>
5 5  
6 6 <%= display_form_field( _('Name:'), f.text_field(:name) ) %>
... ...
app/views/manage_products/_price_composition_bar.html.erb
1   -<% javascript_tag do %>
  1 +<%= javascript_tag do %>
2 2 var value = <%= @product.price_description_percentage %>;
3 3 var total_cost = <%= @product.total_production_cost %>;
4 4 var price = '<%= @product.formatted_value(:price) %>';
... ...
app/views/manage_products/new.html.erb
... ... @@ -25,6 +25,6 @@
25 25  
26 26 <% end %>
27 27  
28   -<% javascript_tag do %>
  28 +<%= javascript_tag do %>
29 29 toggleDisabled(<%= @category && @category.accept_products? ? 'true' : 'false' %>, $('save_and_continue'))
30 30 <% end %>
... ...
app/views/profile/report_abuse.html.erb
1   -<%= form_for @abuse_report, :url => {:action => 'register_report'},
  1 +<%= form_for :abuse_report, :url => {:action => 'register_report'},
2 2 :html => {:onsubmit => "return send_request(this)", :id => 'report-abuse-form'} do |f| %>
3 3 <%= labelled_form_field('* ' + _('Report reasons'), f.text_area(:reason, :rows => 6, :cols => 60, :class => 'required')) %>
4 4 <%= hidden_field_tag(:content_type, params[:content_type]) %>
... ...
app/views/search/_image.html.erb
... ... @@ -5,7 +5,7 @@
5 5 <% if ['jpg', 'jpeg', 'gif', 'png', 'tiff', 'svg'].include? extension %>
6 6 <%= link_to '', image.view_url, :class => "search-image-pic", :style => 'background-image: url(%s)'% image.public_filename(:thumb) %>
7 7 <% if image.width && image.height %>
8   - <% javascript_tag do %>
  8 + <%= javascript_tag do %>
9 9 image = jQuery('script').last().parent().find('.search-image-pic');
10 10 des_width = parseInt(image.css('width'));
11 11 des_height = parseInt(image.css('height'));
... ...
app/views/search/search_page.html.erb
... ... @@ -11,7 +11,7 @@
11 11 <div style="clear: both"></div>
12 12  
13 13 <% if @asset == :product %>
14   - <% javascript_tag do %>
  14 + <%= javascript_tag do %>
15 15 jQuery('.search-product-price-details').altBeautify();
16 16 <% end %>
17 17 <% end %>
... ...
app/views/shared/_dialog_error_messages.html.erb
1   -<% javascript_tag do %>
  1 +<%= javascript_tag do %>
2 2 close_loading()
3 3 jQuery('#errorExplanation h2').hide()
4 4 jQuery('#errorExplanation p').hide()
... ...
app/views/shared/_numbers_only_javascript.html.erb
1   -<% javascript_tag do %>
  1 +<%= javascript_tag do %>
2 2 jQuery(".numbers-only").keypress(function(event) {
3 3 var separator = "<%= environment.currency_separator %>"
4 4 return numbersonly(event, separator)
... ...
app/views/shared/_redirect_via_javascript.html.erb
1   -<% javascript_tag do %>
  1 +<%= javascript_tag do %>
2 2 update_loading('<%= _('redirecting...') %>')
3 3 redirect_to('<%= url %>')
4 4 <% end %>
... ...
features/edit_profile.feature
... ... @@ -34,11 +34,12 @@ Feature: edit profile
34 34 | identifier | name | owner |
35 35 | o-rappa | O Rappa | joao |
36 36 And feature "enable_organization_url_change" is enabled on environment
37   - When I go to o-rappa's control panel
38   - And I follow "Community Info and settings"
39   - And I should not see "identifier-change-confirmation"
40   - When I fill in "Address" with "banda-o-rappa"
41   - And I should see "identifier-change-confirmation"
  37 + And I go to o-rappa's control panel
  38 + When I follow "Community Info and settings"
  39 + Then I should not see "WARNING" within "#identifier-change-confirmation"
  40 + And I fill in "Address" with "banda-o-rappa"
  41 + When I leave the "#profile_data_identifier" field
  42 + Then I should see "WARNING" within "#identifier-change-confirmation"
42 43  
43 44 @selenium
44 45 Scenario: Confirm url change
... ... @@ -46,12 +47,13 @@ Feature: edit profile
46 47 | identifier | name | owner |
47 48 | o-rappa | O Rappa | joao |
48 49 And feature "enable_organization_url_change" is enabled on environment
49   - When I go to o-rappa's control panel
  50 + And I go to o-rappa's control panel
50 51 And I follow "Community Info and settings"
51   - When I fill in "Address" with "banda-o-rappa"
52   - Then I should see "identifier-change-confirmation"
  52 + And I fill in "Address" with "banda-o-rappa"
  53 + When I leave the "#profile_data_identifier" field
  54 + Then I should see "WARNING" within "#identifier-change-confirmation"
53 55 When I follow "Yes"
54   - Then "identifier-change-confirmation" should not be visible within "profile-identifier-formitem"
  56 + Then I should not see "WARNING" within "#identifier-change-confirmation"
55 57  
56 58 @selenium
57 59 Scenario: Cancel url change
... ... @@ -59,9 +61,10 @@ Feature: edit profile
59 61 | identifier | name | owner |
60 62 | o-rappa | O Rappa | joao |
61 63 And feature "enable_organization_url_change" is enabled on environment
62   - When I go to o-rappa's control panel
  64 + And I go to o-rappa's control panel
63 65 And I follow "Community Info and settings"
64   - When I fill in "Address" with "banda-o-rappa"
65   - Then I should see "identifier-change-confirmation"
  66 + And I fill in "Address" with "banda-o-rappa"
  67 + When I leave the "#profile_data_identifier" field
  68 + Then I should see "WARNING" within "#identifier-change-confirmation"
66 69 When I follow "No"
67   - Then "identifier-change-confirmation" should not be visible within "profile-identifier-formitem"
  70 + Then I should not see "WARNING" within "#identifier-change-confirmation"
... ...
features/forum.feature
... ... @@ -14,7 +14,9 @@ Feature: forum
14 14 Scenario: create a forum
15 15 Given I am on joaosilva's control panel
16 16 And I follow "Manage Content"
  17 + And I should see "New content"
17 18 And I follow "New content"
  19 + And I should see "Forum"
18 20 When I follow "Forum"
19 21 And I fill in "Title" with "My Forum"
20 22 And I press "Save"
... ... @@ -97,6 +99,7 @@ Feature: forum
97 99 And I check "Has terms of use:"
98 100 And I press "Save"
99 101 When I follow "New discussion topic"
  102 + And I should see "Text article with visual editor"
100 103 And I follow "Text article with visual editor"
101 104 And I fill in "Title" with "Topic"
102 105 And I press "Save"
... ... @@ -249,6 +252,7 @@ Feature: forum
249 252 And I am logged in as "mariasilva"
250 253 And I go to /sample-community/forum
251 254 And I follow "New discussion topic"
  255 + And I should see "Text article with visual editor"
252 256 And I follow "Text article with visual editor"
253 257 And I fill in "Title" with "Test"
254 258 And I press "Save"
... ... @@ -274,11 +278,13 @@ Feature: forum
274 278 And I am logged in as "mariasilva"
275 279 And I go to /sample-community/forum
276 280 And I follow "New discussion topic"
  281 + And I should see "Text article with visual editor"
277 282 And I follow "Text article with visual editor"
278 283 And I fill in "Title" with "Test"
279 284 And I press "Save"
280 285 And I go to /sample-community/forum/test
281 286 And I follow "New discussion topic"
  287 + And I should see "Text article with visual editor"
282 288 And I follow "Text article with visual editor"
283 289 And I fill in "Title" with "Test inside the topic page"
284 290 And I press "Save"
... ...
features/manage_fields.feature
... ... @@ -58,6 +58,7 @@ Feature: check all manage fields
58 58 Given I follow "Community's fields"
59 59 And I check "community_active"
60 60 And I press "save_community_fields"
  61 + And I follow "Community's fields"
61 62 And I uncheck "community_active"
62 63 And I press "save_community_fields"
63 64 When I go to mycommunity's control panel
... ... @@ -69,6 +70,7 @@ Feature: check all manage fields
69 70 Given I follow "Enterprise's fields"
70 71 And I check "enterprise_active"
71 72 And I press "save_enterprise_fields"
  73 + And I follow "Enterprise's fields"
72 74 And I uncheck "enterprise_active"
73 75 And I press "save_enterprise_fields"
74 76 When I go to paper-street's control panel
... ...
features/manage_inputs.feature
... ... @@ -58,6 +58,7 @@ Feature: manage inputs
58 58 When I go to Rede Moinho's page of product Abbey Road
59 59 And I follow "Inputs"
60 60 And I follow "Add the inputs or raw material used by this product"
  61 + And I should see "Cancel" within "#categories_selection_actionbar"
61 62 And I follow "Cancel" within "#categories_selection_actionbar"
62 63 Then I should see "Abbey Road"
63 64 And I should see "Add the inputs or raw material used by this product"
... ... @@ -199,6 +200,7 @@ Feature: manage inputs
199 200 When I go to Rede Moinho's page of product Abbey Road
200 201 And I follow "Inputs"
201 202 And I follow "Edit" within ".input-details"
  203 + And I should see "Cancel" within ".edit_input"
202 204 And I follow "Cancel" within ".edit_input"
203 205 And I follow "Edit" within ".input-details"
204 206 Then I should see "Amount used"
... ... @@ -218,25 +220,6 @@ Feature: manage inputs
218 220 And I confirm the browser dialog
219 221 Then I should see "Add the inputs or raw material used by this product"
220 222  
221   - @selenium
222   - Scenario: Remember in which tab I was
223   - Given the following products
224   - | owner | category | name |
225   - | redemoinho | Music | Depeche Mode |
226   - | redemoinho | Music | Manu Chao |
227   - And I am logged in as "joaosilva"
228   - When I go to Rede Moinho's page of product Depeche Mode
229   - Then I should see "Add some description to your product"
230   - And "Add the inputs or raw material used by this product" should not be visible within "#show_product"
231   - When I follow "Inputs and raw material"
232   - Then I should see "Add the inputs or raw material used by this product"
233   - And "Add some description to your product" should not be visible within "#show_product"
234   - When I go to Rede Moinho's page of product Manu Chao
235   - Then I should see "Add some description to your product"
236   - When I go to Rede Moinho's page of product Depeche Mode
237   - Then I should see "Add the inputs or raw material used by this product"
238   - And "Add some description to your product" should not be visible within "#show_product"
239   -
240 223 @selenium-fixme
241 224 Scenario: Order input list
242 225 Given the following product_category
... ...
features/step_definitions/invitation_steps.rb
1 1 Given /^I invite email "(.+)" to join community "(.+)"$/ do |email, community|
2 2 identifier = Community.find_by_name(community).identifier
3 3 visit("/myprofile/#{identifier}/profile_members")
4   - click_link('Invite your friends to join 26 Bsslines')
  4 + first(:link, "Invite your friends to join #{community}").click
5 5 click_button('Next')
6 6 fill_in('manual_import_addresses', :with => "#{email}")
7 7 click_link('Personalize invitation mail')
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -4,7 +4,8 @@ Given /^the following users?$/ do |table|
4 4 person_data = item.dup
5 5 person_data.delete("login")
6 6 category = Category.find_by_slug person_data.delete("category")
7   - user = User.create!(:login => item[:login], :password => '123456', :password_confirmation => '123456', :email => item[:login] + "@example.com", :person_data => person_data)
  7 + email = item[:email] || item[:login] + "@example.com"
  8 + user = User.create!(:login => item[:login], :password => '123456', :password_confirmation => '123456', :email => email, :person_data => person_data)
8 9 user.activate
9 10 p = user.person
10 11 p.categories << category if category
... ...
script/install-dependencies/debian-wheezy.sh
... ... @@ -131,4 +131,4 @@ packages=$(grep-dctrl -n -s Build-Depends,Depends,Recommends -S -X noosfero debi
131 131 run sudo apt-get -y install $packages
132 132 sudo apt-get -y install iceweasel || sudo apt-get -y install firefox
133 133  
134   -run bundle --local
  134 +run bundle install
... ...