Commit 227284635caecda8f9c99b865692d448607d5866
Exists in
master
and in
29 other branches
Merge branch 'stable'
Conflicts: app/views/profile_editor/_organization.rhtml features/support/selenium.rb
Showing
22 changed files
with
554 additions
and
9 deletions
Show diff stats
app/controllers/application.rb
@@ -124,9 +124,10 @@ class ApplicationController < ActionController::Base | @@ -124,9 +124,10 @@ class ApplicationController < ActionController::Base | ||
124 | render :template => 'shared/not_found.rhtml', :status => 404 | 124 | render :template => 'shared/not_found.rhtml', :status => 404 |
125 | end | 125 | end |
126 | 126 | ||
127 | - def render_access_denied(message = nil) | 127 | + def render_access_denied(message = nil, title = nil) |
128 | @no_design_blocks = true | 128 | @no_design_blocks = true |
129 | @message = message | 129 | @message = message |
130 | + @title = title | ||
130 | render :template => 'shared/access_denied.rhtml', :status => 403 | 131 | render :template => 'shared/access_denied.rhtml', :status => 403 |
131 | end | 132 | end |
132 | 133 |
app/controllers/my_profile/cms_controller.rb
@@ -222,11 +222,18 @@ class CmsController < MyProfileController | @@ -222,11 +222,18 @@ class CmsController < MyProfileController | ||
222 | end | 222 | end |
223 | end.compact unless params[:marked_groups].nil? | 223 | end.compact unless params[:marked_groups].nil? |
224 | if request.post? | 224 | if request.post? |
225 | + @failed = {} | ||
225 | @marked_groups.each do |item| | 226 | @marked_groups.each do |item| |
226 | task = ApproveArticle.create!(:article => @article, :name => item[:name], :target => item[:group], :requestor => profile) | 227 | task = ApproveArticle.create!(:article => @article, :name => item[:name], :target => item[:group], :requestor => profile) |
227 | - task.finish unless item[:group].moderated_articles? | 228 | + begin |
229 | + task.finish unless item[:group].moderated_articles? | ||
230 | + rescue Exception => ex | ||
231 | + @failed[ex.clean_message] ? @failed[ex.clean_message] << item[:group].name : @failed[ex.clean_message] = [item[:group].name] | ||
232 | + end | ||
233 | + end | ||
234 | + if @failed.blank? | ||
235 | + redirect_back | ||
228 | end | 236 | end |
229 | - redirect_back | ||
230 | end | 237 | end |
231 | end | 238 | end |
232 | 239 |
app/controllers/my_profile/tasks_controller.rb
@@ -17,7 +17,11 @@ class TasksController < MyProfileController | @@ -17,7 +17,11 @@ class TasksController < MyProfileController | ||
17 | if request.post? && VALID_DECISIONS.include?(decision) && params[:id] | 17 | if request.post? && VALID_DECISIONS.include?(decision) && params[:id] |
18 | task = profile.find_in_all_tasks(params[:id]) | 18 | task = profile.find_in_all_tasks(params[:id]) |
19 | task.update_attributes!(params[:task]) | 19 | task.update_attributes!(params[:task]) |
20 | - task.send(decision) | 20 | + begin |
21 | + task.send(decision) | ||
22 | + rescue Exception => ex | ||
23 | + flash[:notice] = ex.clean_message | ||
24 | + end | ||
21 | end | 25 | end |
22 | redirect_to :action => 'index' | 26 | redirect_to :action => 'index' |
23 | end | 27 | end |
app/controllers/public/profile_controller.rb
@@ -107,7 +107,7 @@ class ProfileController < PublicController | @@ -107,7 +107,7 @@ class ProfileController < PublicController | ||
107 | 107 | ||
108 | def check_access_to_profile | 108 | def check_access_to_profile |
109 | unless profile.display_info_to?(user) | 109 | unless profile.display_info_to?(user) |
110 | - render :action => 'private_profile', :status => 403, :layout => false | 110 | + render_access_denied(_("Sorry, this profile was defined as private by its owner. You'll not be able to view content here unless the profile owner adds you."), _("Oops ... you cannot go ahead here")) |
111 | end | 111 | end |
112 | end | 112 | end |
113 | 113 |
app/models/approve_article.rb
@@ -64,7 +64,7 @@ class ApproveArticle < Task | @@ -64,7 +64,7 @@ class ApproveArticle < Task | ||
64 | end | 64 | end |
65 | 65 | ||
66 | def perform | 66 | def perform |
67 | - PublishedArticle.create(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted) | 67 | + PublishedArticle.create!(:name => name, :profile => target, :reference_article => article, :parent => article_parent, :highlighted => highlighted) |
68 | end | 68 | end |
69 | 69 | ||
70 | def target_notification_message | 70 | def target_notification_message |
app/models/product.rb
@@ -67,4 +67,36 @@ class Product < ActiveRecord::Base | @@ -67,4 +67,36 @@ class Product < ActiveRecord::Base | ||
67 | enterprise.public_profile | 67 | enterprise.public_profile |
68 | end | 68 | end |
69 | 69 | ||
70 | + def price=(value) | ||
71 | + if value.is_a?(String) | ||
72 | + super(currency_to_float(value)) | ||
73 | + else | ||
74 | + super(value) | ||
75 | + end | ||
76 | + end | ||
77 | + | ||
78 | + def currency_to_float( num ) | ||
79 | + if num.count('.') == 1 && num.count(',') == 0 | ||
80 | + # number like "12.34" | ||
81 | + return num.to_f | ||
82 | + end | ||
83 | + | ||
84 | + if num.count('.') == 0 && num.count(',') == 1 | ||
85 | + # number like "12,34" | ||
86 | + return num.tr(',','.').to_f | ||
87 | + end | ||
88 | + | ||
89 | + if num.count('.') > 0 && num.count(',') > 0 | ||
90 | + # number like "12.345.678,90" or "12,345,678.90" | ||
91 | + dec_sep = num.tr('0-9','')[-1].chr | ||
92 | + return num.tr('^0-9'+dec_sep,'').tr(dec_sep,'.').to_f | ||
93 | + end | ||
94 | + | ||
95 | + # if you are here is because there is only one | ||
96 | + # separator and this appears 2 times or more. | ||
97 | + # number like "12.345.678" or "12,345,678" | ||
98 | + | ||
99 | + return num.tr(',.','').to_f | ||
100 | + end | ||
101 | + | ||
70 | end | 102 | end |
app/models/profile.rb
@@ -264,6 +264,7 @@ class Profile < ActiveRecord::Base | @@ -264,6 +264,7 @@ class Profile < ActiveRecord::Base | ||
264 | 264 | ||
265 | # copy interesting attributes | 265 | # copy interesting attributes |
266 | self.layout_template = template.layout_template | 266 | self.layout_template = template.layout_template |
267 | + self.theme = template.theme | ||
267 | self.custom_footer = template[:custom_footer] | 268 | self.custom_footer = template[:custom_footer] |
268 | self.custom_header = template[:custom_header] | 269 | self.custom_header = template[:custom_header] |
269 | 270 |
app/views/blocks/profile_info_actions/enterprise.rhtml
@@ -5,6 +5,6 @@ | @@ -5,6 +5,6 @@ | ||
5 | <% end %> | 5 | <% end %> |
6 | <% end %> | 6 | <% end %> |
7 | <% if profile.enable_contact? %> | 7 | <% if profile.enable_contact? %> |
8 | - <li> <%= link_to content_tag('span', _('Contact us')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, :class => 'button with-text icon-menu-mail' %> </li> | 8 | + <li> <%= link_to content_tag('span', _('Contact us')), {:profile => profile.identifier, :controller => 'contact', :action => 'new'}, {:id => 'enterprise-contact-button', :class => 'button with-text icon-menu-mail'} %> </li> |
9 | <% end %> | 9 | <% end %> |
10 | </ul> | 10 | </ul> |
app/views/cms/publish.rhtml
1 | <h1><%= _('Select the groups where you want to publish your article') %></h1> | 1 | <h1><%= _('Select the groups where you want to publish your article') %></h1> |
2 | 2 | ||
3 | +<% if !@failed.blank? %> | ||
4 | + <div class="errorExplanation" id="errorExplanation"> | ||
5 | + <p><%=_("There were errors with the following communities: ")%></p> | ||
6 | + <% @failed.each do |error, communities|%> | ||
7 | + <strong> <%= error %>: </strong> | ||
8 | + <ul> | ||
9 | + <% communities.each do |community| %> | ||
10 | + <li> <%= community %> </li> | ||
11 | + <% end %> | ||
12 | + </ul> | ||
13 | + <% end %> | ||
14 | + </div> | ||
15 | +<% end %> | ||
16 | + | ||
3 | <% form_tag do%> | 17 | <% form_tag do%> |
4 | <%= hidden_field_tag :back_to, @back_to %> | 18 | <%= hidden_field_tag :back_to, @back_to %> |
5 | <% @groups.each do |group| %> | 19 | <% @groups.each do |group| %> |
app/views/profile_editor/_organization.rhtml
@@ -2,6 +2,18 @@ | @@ -2,6 +2,18 @@ | ||
2 | 2 | ||
3 | <%= required_fields_message if @profile.required_fields.any? %> | 3 | <%= required_fields_message if @profile.required_fields.any? %> |
4 | 4 | ||
5 | + <%= required f.text_field(:name) %> | ||
6 | + | ||
7 | +<% if @environment.enabled?('enable_organization_url_change') %> | ||
8 | + <script type="text/javascript"> | ||
9 | + function updateUrlField(name_field, id) { | ||
10 | + url_field = $(id); | ||
11 | + url_field.value = convToValidIdentifier(name_field.value, "-"); | ||
12 | + warn_value_change(url_field); | ||
13 | + } | ||
14 | + </script> | ||
15 | +<% end %> | ||
16 | + | ||
5 | <div class="formfieldline"> | 17 | <div class="formfieldline"> |
6 | <label class="formlabel" for="profile_data_nickname"><%= _('Display name') %></label> | 18 | <label class="formlabel" for="profile_data_nickname"><%= _('Display name') %></label> |
7 | <div class="formfield type-text"> | 19 | <div class="formfield type-text"> |
app/views/shared/access_denied.rhtml
@@ -0,0 +1,134 @@ | @@ -0,0 +1,134 @@ | ||
1 | +Feature: activate enterprise | ||
2 | + As an enterprise owner | ||
3 | + I want to activate my enterprise | ||
4 | + In order to publish content | ||
5 | + | ||
6 | + Background: | ||
7 | + Given the following users | ||
8 | + | login | name | | ||
9 | + | joaosilva | Joao Silva | | ||
10 | + | ||
11 | + Scenario: added an unexistent code | ||
12 | + Given feature "enterprise_activation" is enabled on environment | ||
13 | + And I am logged in as "joaosilva" | ||
14 | + And I am on Joao Silva's control panel | ||
15 | + And I fill in "Enterprise activation code" with "abcde" | ||
16 | + When I press "Activate" | ||
17 | + Then I should see "Invalid enterprise code" | ||
18 | + | ||
19 | + Scenario: added a code from an activated enterprise | ||
20 | + Given feature "enterprise_activation" is enabled on environment | ||
21 | + And the following enterprises | ||
22 | + | identifier | name | enabled | | ||
23 | + | products-factory | Products Factory | false | | ||
24 | + And I am logged in as "joaosilva" | ||
25 | + And I am on Joao Silva's control panel | ||
26 | + And enterprise "Products Factory" is enabled | ||
27 | + And I fill in "Enterprise activation code" with code of "Products Factory" | ||
28 | + When I press "Activate" | ||
29 | + Then I should see "This enterprise is already active" | ||
30 | + | ||
31 | + Scenario: added a code from an enterprise with no foundation year or cnpj | ||
32 | + Given feature "enterprise_activation" is enabled on environment | ||
33 | + And the following enterprises | ||
34 | + | identifier | name | enabled | | ||
35 | + | products-factory | Products Factory | false | | ||
36 | + And I am logged in as "joaosilva" | ||
37 | + And I am on Joao Silva's control panel | ||
38 | + And I fill in "Enterprise activation code" with code of "Products Factory" | ||
39 | + When I press "Activate" | ||
40 | + Then I should see "We don't have enough information about your enterprise to identify you." | ||
41 | + And enterprise "Products Factory" should not be blocked | ||
42 | + | ||
43 | + Scenario: filled activation question with wrong foundation year | ||
44 | + Given feature "enterprise_activation" is enabled on environment | ||
45 | + And the following enterprises | ||
46 | + | identifier | name | enabled | foundation_year | | ||
47 | + | services-provider | Services Provider | false | 2000 | | ||
48 | + And I am logged in as "joaosilva" | ||
49 | + And I am on Joao Silva's control panel | ||
50 | + And I fill in "Enterprise activation code" with code of "Services Provider" | ||
51 | + And I press "Activate" | ||
52 | + And I fill in "What year your enterprise was founded? It must have 4 digits, eg 1990." with "1999" | ||
53 | + When I press "Continue" | ||
54 | + Then I should see "There was a failed atempt of activation and the automated activation was disabled for your security." | ||
55 | + And enterprise "Services Provider" should be blocked | ||
56 | + | ||
57 | + Scenario: filled activation question with wrong cnpj | ||
58 | + Given feature "enterprise_activation" is enabled on environment | ||
59 | + And the following enterprises | ||
60 | + | identifier | name | enabled | cnpj | | ||
61 | + | services-provider | Services Provider | false | 00000000000000 | | ||
62 | + And I am logged in as "joaosilva" | ||
63 | + And I am on Joao Silva's control panel | ||
64 | + And I fill in "Enterprise activation code" with code of "Services Provider" | ||
65 | + And I press "Activate" | ||
66 | + And I fill in "What is the CNPJ of your enterprise?" with "12345678912345" | ||
67 | + When I press "Continue" | ||
68 | + Then I should see "There was a failed atempt of activation and the automated activation was disabled for your security." | ||
69 | + And enterprise "Services Provider" should be blocked | ||
70 | + | ||
71 | + @selenium | ||
72 | + Scenario: activate succesffuly an enterprise with foundation_year | ||
73 | + Given feature "enterprise_activation" is enabled on environment | ||
74 | + And the following enterprises | ||
75 | + | identifier | name | enabled | foundation_year | | ||
76 | + | services-provider | Services Provider | false | 2000 | | ||
77 | + And I am logged in as "joaosilva" | ||
78 | + And I am on Joao Silva's control panel | ||
79 | + And I fill in "Enterprise activation code" with code of "Services Provider" | ||
80 | + And I press "Activate" | ||
81 | + And I fill in "enterprise-activation-answer" with "2000" | ||
82 | + And I press "Continue" | ||
83 | + And I check "I read the terms of use and accepted them" | ||
84 | + When I press "Continue" | ||
85 | + Then I should see "Services Provider was successfuly activated. Now you may go to your control panel or to the control panel of your enterprise" | ||
86 | + And enterprise "Services Provider" should be enabled | ||
87 | + And "Joao Silva" is admin of "Services Provider" | ||
88 | + | ||
89 | + @selenium | ||
90 | + Scenario: replace template after enable an enterprise | ||
91 | + Given enterprise template must be replaced after enable | ||
92 | + And feature "enterprise_activation" is enabled on environment | ||
93 | + And the following enterprises | ||
94 | + | identifier | name | enabled | foundation_year | | ||
95 | + | services-provider | Services Provider | false | 2000 | | ||
96 | + | active-template | Active Template | false | 2000 | | ||
97 | + And "Active Template" is the active enterprise template | ||
98 | + And "Services Provider" doesnt have "Active Template" as template | ||
99 | + And I am logged in as "joaosilva" | ||
100 | + And I am on Joao Silva's control panel | ||
101 | + And I fill in "Enterprise activation code" with code of "Services Provider" | ||
102 | + And I press "Activate" | ||
103 | + And I fill in "enterprise-activation-answer" with "2000" | ||
104 | + And I press "Continue" | ||
105 | + And I check "I read the terms of use and accepted them" | ||
106 | + When I press "Continue" | ||
107 | + Then I should see "Services Provider was successfuly activated. Now you may go to your control panel or to the control panel of your enterprise" | ||
108 | + And enterprise "Services Provider" should be enabled | ||
109 | + And "Joao Silva" is admin of "Services Provider" | ||
110 | + And "Services Provider" has "Active Template" as template | ||
111 | + | ||
112 | + @selenium | ||
113 | + Scenario: not replace template after enable an enterprise | ||
114 | + Given enterprise template must not be replaced after enable | ||
115 | + And feature "enterprise_activation" is enabled on environment | ||
116 | + And the following enterprises | ||
117 | + | identifier | name | enabled | foundation_year | | ||
118 | + | services-provider | Services Provider | false | 2000 | | ||
119 | + | active-template | Active Template | false | 2000 | | ||
120 | + And "Active Template" is the active enterprise template | ||
121 | + And "Services Provider" doesnt have "Active Template" as template | ||
122 | + And I am logged in as "joaosilva" | ||
123 | + And I am on Joao Silva's control panel | ||
124 | + And I fill in "Enterprise activation code" with code of "Services Provider" | ||
125 | + And I press "Activate" | ||
126 | + And I fill in "enterprise-activation-answer" with "2000" | ||
127 | + And I press "Continue" | ||
128 | + And I check "I read the terms of use and accepted them" | ||
129 | + When I press "Continue" | ||
130 | + Then I should see "Services Provider was successfuly activated. Now you may go to your control panel or to the control panel of your enterprise" | ||
131 | + And enterprise "Services Provider" should be enabled | ||
132 | + And "Joao Silva" is admin of "Services Provider" | ||
133 | + And "Services Provider" doesnt have "Active Template" as template | ||
134 | + |
@@ -0,0 +1,35 @@ | @@ -0,0 +1,35 @@ | ||
1 | +Feature: change organization name | ||
2 | + As an organization's admin | ||
3 | + I want to change it's name | ||
4 | + In order to keep it's name consistent | ||
5 | + | ||
6 | + Scenario: changing community's name | ||
7 | + Given the following communities | ||
8 | + | identifier | name | | ||
9 | + | sample-community | Sample Community | | ||
10 | + And the following users | ||
11 | + | login | name | | ||
12 | + | joaosilva | Joao Silva | | ||
13 | + And "Joao Silva" is admin of "Sample Community" | ||
14 | + And I am logged in as "joaosilva" | ||
15 | + And I am on Sample Community's control panel | ||
16 | + And I follow "Community Info and settings" | ||
17 | + And I fill in "Name" with "New Sample Community" | ||
18 | + When I press "Save" | ||
19 | + Then I should be on New Sample Community's control panel | ||
20 | + | ||
21 | + | ||
22 | + Scenario: changing enterprise's name | ||
23 | + Given the following enterprises | ||
24 | + | identifier | name | | ||
25 | + | sample-enterprise | Sample Enterprise | | ||
26 | + And the following users | ||
27 | + | login | name | | ||
28 | + | joaosilva | Joao Silva | | ||
29 | + And "Joao Silva" is admin of "Sample Enterprise" | ||
30 | + And I am logged in as "joaosilva" | ||
31 | + And I am on Sample Enterprise's control panel | ||
32 | + And I follow "Enterprise Info and settings" | ||
33 | + And I fill in "Name" with "New Sample Enterprise" | ||
34 | + When I press "Save" | ||
35 | + Then I should be on New Sample Enterprise's control panel |
@@ -0,0 +1,111 @@ | @@ -0,0 +1,111 @@ | ||
1 | +Feature: publish article | ||
2 | + As a user | ||
3 | + I want to publish an article | ||
4 | + In order to share it with other users | ||
5 | + | ||
6 | + Background: | ||
7 | + Given the following users | ||
8 | + | login | name | | ||
9 | + | joaosilva | Joao Silva | | ||
10 | + | mariasilva | Maria Silva | | ||
11 | + And "mariasilva" has no articles | ||
12 | + And "joaosilva" has no articles | ||
13 | + And the following communities | ||
14 | + | identifier | name | | ||
15 | + | sample-community | Sample Community | | ||
16 | + And the following articles | ||
17 | + | owner | name | body | | ||
18 | + | joaosilva | Sample Article | This is the first published article | | ||
19 | + | ||
20 | + Scenario: publishing an article that doesn't exists in the community | ||
21 | + Given I am logged in as "joaosilva" | ||
22 | + And "Joao Silva" is a member of "Sample Community" | ||
23 | + And I am on Joao Silva's control panel | ||
24 | + And I follow "Manage Content" | ||
25 | + And I follow "Spread" | ||
26 | + And I check "Sample Community" | ||
27 | + And I press "Publish" | ||
28 | + And I am on Sample Community's homepage | ||
29 | + And I follow "View profile" | ||
30 | + And I follow "Site map" | ||
31 | + When I follow "Sample Article" | ||
32 | + Then I should see "This is the first published article" | ||
33 | + | ||
34 | + | ||
35 | + Scenario: getting an error message when publishing article with same name | ||
36 | + Given I am logged in as "joaosilva" | ||
37 | + And "Joao Silva" is a member of "Sample Community" | ||
38 | + And I am on Joao Silva's control panel | ||
39 | + And I follow "Manage Content" | ||
40 | + And I follow "Spread" | ||
41 | + And I check "Sample Community" | ||
42 | + And I press "Publish" | ||
43 | + And I am logged in as "mariasilva" | ||
44 | + And "Maria Silva" is a member of "Sample Community" | ||
45 | + And I am on Maria Silva's control panel | ||
46 | + And I follow "Manage Content" | ||
47 | + And I follow "New article" | ||
48 | + And I follow "Text article with Textile markup language" | ||
49 | + And I fill in the following: | ||
50 | + | Title | Sample Article | | ||
51 | + | Text | this is Maria's first published article | | ||
52 | + And I press "Save" | ||
53 | + And I follow "Spread" | ||
54 | + And I check "Sample Community" | ||
55 | + When I press "Publish" | ||
56 | + Then I should see "Validation failed: Slug (the code generated from the article name) is already being used by another article.:" | ||
57 | + | ||
58 | + Scenario: publishing an article in many communities and listing the communities that couldn't publish the article again, | ||
59 | + stills publishing the article in the other communities. | ||
60 | + Given the following communities | ||
61 | + | identifier | name | | ||
62 | + | another-community1 | Another Community1 | | ||
63 | + | another-community2 | Another Community2 | | ||
64 | + And I am logged in as "joaosilva" | ||
65 | + And "Joao Silva" is a member of "Sample Community" | ||
66 | + And "Joao Silva" is a member of "Another Community1" | ||
67 | + And "Joao Silva" is a member of "Another Community2" | ||
68 | + And I am on Joao Silva's control panel | ||
69 | + And I follow "Manage Content" | ||
70 | + And I follow "Spread" | ||
71 | + And I check "Sample Community" | ||
72 | + And I press "Publish" | ||
73 | + And I should not see "This article name is already in use in the following community(ies):" | ||
74 | + And I follow "Spread" | ||
75 | + And I check "Sample Community" | ||
76 | + And I check "Another Community1" | ||
77 | + And I check "Another Community2" | ||
78 | + When I press "Publish" | ||
79 | + Then I should see "Validation failed: Slug (the code generated from the article name) is already being used by another article.:" | ||
80 | + And I am on Another Community1's homepage | ||
81 | + And I follow "View profile" | ||
82 | + When I follow "Site map" | ||
83 | + Then I should see "Sample Article" | ||
84 | + And I am on Another Community2's homepage | ||
85 | + And I follow "View profile" | ||
86 | + When I follow "Site map" | ||
87 | + Then I should see "Sample Article" | ||
88 | + | ||
89 | + Scenario: publishing articles with the same name in a moderated community | ||
90 | + Given I am logged in as "joaosilva" | ||
91 | + And "Joao Silva" is a member of "Sample Community" | ||
92 | + And "Joao Silva" is admin of "Sample Community" | ||
93 | + And I am on Sample Community's control panel | ||
94 | + And I follow "Community Info and settings" | ||
95 | + And I choose "profile_data_moderated_articles_true" | ||
96 | + And I press "Save" | ||
97 | + And I am on Joao Silva's control panel | ||
98 | + And I follow "Manage Content" | ||
99 | + And I follow "Spread" | ||
100 | + And I check "Sample Community" | ||
101 | + And I press "Publish" | ||
102 | + And I follow "Spread" | ||
103 | + And I check "Sample Community" | ||
104 | + And I press "Publish" | ||
105 | + And I am on Sample Community's control panel | ||
106 | + And I follow "Tasks" | ||
107 | + And I press "Ok!" | ||
108 | + And I should not see "Validation failed: Slug (the code generated from the article name) is already being used by another article.:" | ||
109 | + When I press "Ok!" | ||
110 | + Then I should see "Validation failed: Slug (the code generated from the article name) is already being used by another article." | ||
111 | + |
@@ -0,0 +1,69 @@ | @@ -0,0 +1,69 @@ | ||
1 | +Given /^I fill in "([^\"]*)" with code of "([^\"]*)"$/ do |field, enterprise| | ||
2 | + enterprise = Enterprise.find_by_name(enterprise) | ||
3 | + value = EnterpriseActivation.all.select { |task| task.enterprise == enterprise}.first.code | ||
4 | + fill_in(field, :with => value) | ||
5 | +end | ||
6 | + | ||
7 | +Given /^enterprise "([^\"]*)" should be enabled$/ do |enterprise| | ||
8 | + Enterprise.find_by_name(enterprise).enabled?.should be_true | ||
9 | +end | ||
10 | + | ||
11 | +Given /^"([^\"]*)" is the active enterprise template$/ do |enterprise| | ||
12 | + template = Enterprise.find_by_name(enterprise) | ||
13 | + template.boxes.destroy_all | ||
14 | + template.boxes << Box.new | ||
15 | + template.layout_template = 'leftbar' | ||
16 | + template.theme = 'template_theme' | ||
17 | + template.custom_header = 'template header' | ||
18 | + template.custom_footer = 'template_footer' | ||
19 | + template.save! | ||
20 | + | ||
21 | + e = Environment.default | ||
22 | + e.enterprise_template = template | ||
23 | + e.save | ||
24 | +end | ||
25 | + | ||
26 | +Given /^"([^\"]*)" has "([^\"]*)" as template$/ do |ent, templ| | ||
27 | + template = Enterprise.find_by_name(templ) | ||
28 | + enterprise = Enterprise.find_by_name(ent) | ||
29 | + (template.boxes.size == enterprise.boxes.size).should be_true | ||
30 | + (template.layout_template == enterprise.layout_template).should be_true | ||
31 | + (template.theme == enterprise.theme).should be_true | ||
32 | + (template.custom_header == enterprise.custom_header).should be_true | ||
33 | + (template.custom_footer == enterprise.custom_footer).should be_true | ||
34 | +end | ||
35 | + | ||
36 | +Given /^"([^\"]*)" doesnt have "([^\"]*)" as template$/ do |ent, templ| | ||
37 | + template = Enterprise.find_by_name(templ) | ||
38 | + enterprise = Enterprise.find_by_name(ent) | ||
39 | + (template.boxes.size == enterprise.boxes.size).should be_false | ||
40 | + (template.layout_template == enterprise.layout_template).should be_false | ||
41 | + (template.theme == enterprise.theme).should be_false | ||
42 | + (template.custom_header == enterprise.custom_header).should be_false | ||
43 | + (template.custom_footer == enterprise.custom_footer).should be_false | ||
44 | +end | ||
45 | + | ||
46 | +Given /^enterprise "([^\"]*)" is enabled$/ do |enterprise| | ||
47 | + Enterprise.find_by_name(enterprise).update_attribute(:enabled,true) | ||
48 | + Enterprise.find_by_name(enterprise).enabled?.should be_true | ||
49 | +end | ||
50 | + | ||
51 | +Given /^enterprise "([^\"]*)" should be blocked$/ do |enterprise| | ||
52 | + Enterprise.find_by_name(enterprise).blocked?.should be_true | ||
53 | +end | ||
54 | + | ||
55 | +Given /^enterprise "([^\"]*)" should not be blocked$/ do |enterprise| | ||
56 | + Enterprise.find_by_name(enterprise).blocked?.should_not be_true | ||
57 | +end | ||
58 | + | ||
59 | +Given /^enterprise template must be replaced after enable$/ do | ||
60 | + e = Environment.default | ||
61 | + e.replace_enterprise_template_when_enable = true | ||
62 | + e.save | ||
63 | +end | ||
64 | + | ||
65 | +Given /^enterprise template must not be replaced after enable$/ do | ||
66 | + e = Environment.default | ||
67 | + e.replace_enterprise_template_when_enable = false | ||
68 | + e.save | ||
69 | +end |
features/step_definitions/noosfero_steps.rb
@@ -94,6 +94,20 @@ Given /^feature "(.+)" is disabled on environment$/ do |feature| | @@ -94,6 +94,20 @@ Given /^feature "(.+)" is disabled on environment$/ do |feature| | ||
94 | e.save | 94 | e.save |
95 | end | 95 | end |
96 | 96 | ||
97 | +Given /^"(.+)" is a member of "(.+)"$/ do |person,profile| | ||
98 | + Profile.find_by_name(profile).add_member(Profile.find_by_name(person)) | ||
99 | +end | ||
100 | + | ||
97 | Given /^"(.+)" should be a member of "(.+)"$/ do |person,profile| | 101 | Given /^"(.+)" should be a member of "(.+)"$/ do |person,profile| |
98 | Profile.find_by_name(profile).members.should include(Person.find_by_name(person)) | 102 | Profile.find_by_name(profile).members.should include(Person.find_by_name(person)) |
99 | end | 103 | end |
104 | + | ||
105 | +Given /^"(.+)" is admin of "(.+)"$/ do |person, organization| | ||
106 | + org = Profile.find_by_name(organization) | ||
107 | + user = Profile.find_by_name(person) | ||
108 | + org.add_admin(user) | ||
109 | +end | ||
110 | + | ||
111 | +Given /^"([^\"]*)" has no articles$/ do |profile| | ||
112 | + (Profile[profile] || Profile.find_by_name(profile)).articles.delete_all | ||
113 | +end |
features/support/selenium.rb
@@ -15,6 +15,7 @@ Before do | @@ -15,6 +15,7 @@ Before do | ||
15 | fixtures_folder = File.join(RAILS_ROOT, 'test', 'fixtures') | 15 | fixtures_folder = File.join(RAILS_ROOT, 'test', 'fixtures') |
16 | fixtures = ['environments', 'roles'] | 16 | fixtures = ['environments', 'roles'] |
17 | Fixtures.create_fixtures(fixtures_folder, fixtures) | 17 | Fixtures.create_fixtures(fixtures_folder, fixtures) |
18 | + ENV['LANG'] = 'C' | ||
18 | DatabaseCleaner.start | 19 | DatabaseCleaner.start |
19 | end | 20 | end |
20 | 21 |
lib/noosfero.rb
1 | module Noosfero | 1 | module Noosfero |
2 | PROJECT = 'noosfero' | 2 | PROJECT = 'noosfero' |
3 | - VERSION = '0.20.0' | 3 | + VERSION = '0.20.2' |
4 | SVN_ROOT = 'https://svn.colivre.coop.br/svn/noosfero' | 4 | SVN_ROOT = 'https://svn.colivre.coop.br/svn/noosfero' |
5 | 5 | ||
6 | def self.pattern_for_controllers_in_directory(dir) | 6 | def self.pattern_for_controllers_in_directory(dir) |
@@ -0,0 +1,92 @@ | @@ -0,0 +1,92 @@ | ||
1 | +#!/bin/sh | ||
2 | + | ||
3 | +set -e | ||
4 | + | ||
5 | +export RAILS_ENV=production | ||
6 | + | ||
7 | +get_value(){ | ||
8 | + ruby -ryaml -e "puts YAML.load_file('config/database.yml')['$RAILS_ENV']['$1']" | ||
9 | +} | ||
10 | + | ||
11 | +usage(){ | ||
12 | + echo "usage: $0 [OPTIONS]" | ||
13 | + echo | ||
14 | + echo "Options:" | ||
15 | + echo | ||
16 | + echo " -s, --shell Opens a shell just after upgrading code and" | ||
17 | + echo " database to make manual steps if needed" | ||
18 | + echo | ||
19 | + echo " -h, --help Displays the help (this screen)" | ||
20 | + echo | ||
21 | + echo " -v, --version Displays Noosfero current version" | ||
22 | + echo | ||
23 | + exit $1 | ||
24 | +} | ||
25 | + | ||
26 | +version(){ | ||
27 | + version=$(ruby -Ilib -rnoosfero -e 'puts Noosfero::VERSION') | ||
28 | + echo "Noosfero version $version" | ||
29 | + exit 0 | ||
30 | +} | ||
31 | + | ||
32 | +shell=no | ||
33 | +while test $# -gt 0; do | ||
34 | + case "$1" in | ||
35 | + --shell) | ||
36 | + shell=yes | ||
37 | + ;; | ||
38 | + --help) | ||
39 | + usage 0 | ||
40 | + ;; | ||
41 | + --version) | ||
42 | + version | ||
43 | + ;; | ||
44 | + *) | ||
45 | + usage 1 | ||
46 | + ;; | ||
47 | + esac | ||
48 | + shift | ||
49 | +done | ||
50 | + | ||
51 | + | ||
52 | +./script/production stop || echo "Stop failed, trying to continue anyway" | ||
53 | + | ||
54 | +sudo /etc/init.d/memcached restart | ||
55 | + | ||
56 | +rake backup | ||
57 | + | ||
58 | +database=$(get_value database) | ||
59 | +adapter=$(get_value adapter) | ||
60 | + | ||
61 | +if [ "$adapter" = "postgresql" ]; then | ||
62 | + mkdir -p backups/ | ||
63 | + backup=backups/dump-$(date +%Y-%m-%d-%H-%M).sql | ||
64 | + pg_dump "$database" > "$backup" | ||
65 | +fi | ||
66 | + | ||
67 | +git pull | ||
68 | + | ||
69 | +for dir in public/designs/themes/*; do | ||
70 | + (cd $dir && test -e .git/config && git pull) | ||
71 | +done | ||
72 | + | ||
73 | +rake db:migrate | ||
74 | + | ||
75 | +if test "$shell" = "yes"; then | ||
76 | + echo "################################################" | ||
77 | + echo "# Noosfero upgrade shell #" | ||
78 | + echo "################################################" | ||
79 | + echo "# #" | ||
80 | + echo "# If you need to do any manual steps during #" | ||
81 | + echo "# this upgrade, now is the time. #" | ||
82 | + echo "# #" | ||
83 | + echo "# After you finish, just exit this shell and #" | ||
84 | + echo "# the upgrade will proceed #" | ||
85 | + echo "################################################" | ||
86 | + export PS1="[Noosfero upgrade] $PS1" | ||
87 | + bash --rcfile config/bashrc | ||
88 | +fi | ||
89 | + | ||
90 | +rake makemo | ||
91 | + | ||
92 | +./script/production start |
test/fixtures/roles.yml
@@ -41,6 +41,7 @@ profile_admin: | @@ -41,6 +41,7 @@ profile_admin: | ||
41 | system: true | 41 | system: true |
42 | permissions: | 42 | permissions: |
43 | - edit_profile_design | 43 | - edit_profile_design |
44 | + - edit_profile | ||
44 | - moderate_comments | 45 | - moderate_comments |
45 | - destroy_profile | 46 | - destroy_profile |
46 | - perform_task | 47 | - perform_task |
test/unit/product_test.rb
@@ -178,4 +178,19 @@ class ProductTest < Test::Unit::TestCase | @@ -178,4 +178,19 @@ class ProductTest < Test::Unit::TestCase | ||
178 | assert !p1.public? | 178 | assert !p1.public? |
179 | end | 179 | end |
180 | 180 | ||
181 | + should 'accept prices in american\'s or brazilian\'s currency format' do | ||
182 | + [ | ||
183 | + [12.34, 12.34], | ||
184 | + ["12.34", 12.34], | ||
185 | + ["12,34", 12.34], | ||
186 | + ["12.345.678,90", 12345678.90], | ||
187 | + ["12,345,678.90", 12345678.90], | ||
188 | + ["12.345.678", 12345678.00], | ||
189 | + ["12,345,678", 12345678.00] | ||
190 | + ].each do |input, output| | ||
191 | + product = Product.new(:price => input) | ||
192 | + assert_equal output, product.price | ||
193 | + end | ||
194 | + end | ||
195 | + | ||
181 | end | 196 | end |