Commit 2a6a01bb03af15c7bf41aebd605a1f334bbb8111
Exists in
master
and in
29 other branches
Merge branch 'stable'
Showing
21 changed files
with
159 additions
and
23 deletions
Show diff stats
app/controllers/public/catalog_controller.rb
app/controllers/public/enterprise_registration_controller.rb
... | ... | @@ -16,9 +16,9 @@ class EnterpriseRegistrationController < ApplicationController |
16 | 16 | @create_enterprise.target = Profile.find(params[:create_enterprise][:target_id]) |
17 | 17 | end |
18 | 18 | elsif @validation == :admin || @validation == :none |
19 | - @create_enterprise.target = @create_enterprise.environment | |
19 | + @create_enterprise.target = environment | |
20 | 20 | end |
21 | - @create_enterprise.requestor = current_user.person | |
21 | + @create_enterprise.requestor = user | |
22 | 22 | the_action = |
23 | 23 | if request.post? |
24 | 24 | if @create_enterprise.valid_before_selecting_target? | ... | ... |
app/models/create_enterprise.rb
app/models/environment_statistics_block.rb
... | ... | @@ -17,11 +17,12 @@ class EnvironmentStatisticsBlock < Block |
17 | 17 | enterprises = owner.enterprises.visible.count |
18 | 18 | communities = owner.communities.visible.count |
19 | 19 | |
20 | - info = [ | |
21 | - n_('One user', '%{num} users', users) % { :num => users }, | |
22 | - n__('One enterprise', '%{num} enterprises', enterprises) % { :num => enterprises }, | |
23 | - n__('One community', '%{num} communities', communities) % { :num => communities }, | |
24 | - ] | |
20 | + info = [] | |
21 | + info << (n_('One user', '%{num} users', users) % { :num => users }) | |
22 | + unless owner.enabled?('disable_asset_enterprises') | |
23 | + info << (n__('One enterprise', '%{num} enterprises', enterprises) % { :num => enterprises }) | |
24 | + end | |
25 | + info << (n__('One community', '%{num} communities', communities) % { :num => communities }) | |
25 | 26 | |
26 | 27 | block_title(title) + content_tag('ul', info.map {|item| content_tag('li', item) }.join("\n")) |
27 | 28 | end | ... | ... |
app/views/catalog/index.rhtml
app/views/content_viewer/_comment_form.rhtml
... | ... | @@ -37,7 +37,7 @@ |
37 | 37 | <%= required labelled_form_field(_('Title'), text_field(:comment, :title)) %> |
38 | 38 | <%= required labelled_form_field(_('Enter your comment'), text_area(:comment, :body, :rows => 5)) %> |
39 | 39 | <% button_bar do %> |
40 | - <%= submit_button('add', _('Post comment'), :onclick => "$('confirm').value = 'true'") %> | |
40 | + <%= submit_button('add', _('Post comment'), :onclick => "$('confirm').value = 'true'; this.disabled = true") %> | |
41 | 41 | <% end %> |
42 | 42 | <% end %> |
43 | 43 | ... | ... |
app/views/shared/tiny_mce.rhtml
... | ... | @@ -32,7 +32,7 @@ tinyMCE.init({ |
32 | 32 | paste_insert_word_content_callback : "convertWord", |
33 | 33 | paste_use_dialog: false, |
34 | 34 | apply_source_formatting : true, |
35 | - extended_valid_elements : "applet[style|archive|codebase|code|height|width],comment,iframe[src|style|allowtransparency|frameborder|width|height]", | |
35 | + extended_valid_elements : "applet[style|archive|codebase|code|height|width],comment,iframe[src|style|allowtransparency|frameborder|width|height|scrolling]", | |
36 | 36 | content_css: '/stylesheets/tinymce.css', |
37 | 37 | language: <%= tinymce_language.inspect %>, |
38 | 38 | entity_encoding: 'raw' | ... | ... |
config/environment.rb
... | ... | @@ -72,7 +72,7 @@ Rails::Initializer.run do |config| |
72 | 72 | } |
73 | 73 | |
74 | 74 | # Adds custom attributes to the Set of allowed html attributes for the #sanitize helper |
75 | - config.action_view.sanitized_allowed_attributes = 'align', 'border', 'alt', 'vspace', 'hspace', 'width', 'heigth', 'value', 'type', 'data', 'style', 'target', 'codebase', 'archive', 'classid', 'code', 'flashvars' | |
75 | + config.action_view.sanitized_allowed_attributes = 'align', 'border', 'alt', 'vspace', 'hspace', 'width', 'heigth', 'value', 'type', 'data', 'style', 'target', 'codebase', 'archive', 'classid', 'code', 'flashvars', 'scrolling', 'frameborder' | |
76 | 76 | |
77 | 77 | # Adds custom tags to the Set of allowed html tags for the #sanitize helper |
78 | 78 | config.action_view.sanitized_allowed_tags = 'object', 'embed', 'param', 'table', 'tr', 'th', 'td', 'applet', 'comment', 'iframe' | ... | ... |
db/migrate/20100730141134_set_owner_environment_to_enterprises_environment.rb
0 → 100644
... | ... | @@ -0,0 +1,14 @@ |
1 | +class SetOwnerEnvironmentToEnterprisesEnvironment < ActiveRecord::Migration | |
2 | + def self.up | |
3 | + CreateEnterprise.find_all_by_status(3).each do |t| | |
4 | + if(Enterprise.find_by_identifier(t.data[:identifier])) | |
5 | + update("UPDATE profiles SET environment_id = '%s' WHERE identifier = '%s'" % | |
6 | + [Person.find(t.requestor_id).environment.id, t.data[:identifier]]) | |
7 | + end | |
8 | + end | |
9 | + end | |
10 | + | |
11 | + def self.down | |
12 | + say "this migration can't be reverted" | |
13 | + end | |
14 | +end | ... | ... |
db/schema.rb
... | ... | @@ -9,7 +9,7 @@ |
9 | 9 | # |
10 | 10 | # It's strongly recommended to check this file into your version control system. |
11 | 11 | |
12 | -ActiveRecord::Schema.define(:version => 20100722020357) do | |
12 | +ActiveRecord::Schema.define(:version => 20100730141134) do | |
13 | 13 | |
14 | 14 | create_table "article_versions", :force => true do |t| |
15 | 15 | t.integer "article_id" | ... | ... |
features/comment.feature
... | ... | @@ -57,3 +57,14 @@ Feature: comment |
57 | 57 | When I press "Post comment" |
58 | 58 | Then I should see "Title can't be blank" |
59 | 59 | And I should see "Body can't be blank" |
60 | + | |
61 | + @selenium | |
62 | + Scenario: disable post comment button | |
63 | + Given I am on /booking/article-to-comment | |
64 | + And I fill in "Name" with "Joey Ramone" | |
65 | + And I fill in "e-Mail" with "joey@ramones.com" | |
66 | + And I fill in "Title" with "Hey ho, let's go!" | |
67 | + And I fill in "Enter your comment" with "Hey ho, let's go!" | |
68 | + When I press "Post comment" | |
69 | + Then the "value.Post comment" button should not be enabled | |
70 | + And I should see "Hey ho, let's go" | |
60 | 71 | \ No newline at end of file | ... | ... |
features/manage_products.feature
... | ... | @@ -11,6 +11,38 @@ Feature: manage products |
11 | 11 | | redemoinho | joaosilva | Rede Moinho | true | |
12 | 12 | And feature "disable_products_for_enterprises" is disabled on environment |
13 | 13 | |
14 | + Scenario: paginate public listing products and services | |
15 | + Given the following product_category | |
16 | + | name | | |
17 | + | Bicycle | | |
18 | + And the following products | |
19 | + | owner | category | name | description | | |
20 | + | redemoinho | bicycle | Bike 1 | bicycle 1 | | |
21 | + | redemoinho | bicycle | Bike 2 | bicycle 2 | | |
22 | + | redemoinho | bicycle | Bike 3 | bicycle 3 | | |
23 | + | redemoinho | bicycle | Bike 4 | bicycle 4 | | |
24 | + | redemoinho | bicycle | Bike 5 | bicycle 5 | | |
25 | + | redemoinho | bicycle | Bike 6 | bicycle 6 | | |
26 | + | redemoinho | bicycle | Bike 7 | bicycle 7 | | |
27 | + | redemoinho | bicycle | Bike 8 | bicycle 8 | | |
28 | + | redemoinho | bicycle | Bike 9 | bicycle 9 | | |
29 | + | redemoinho | bicycle | Bike 10| bicycle 10 | | |
30 | + | redemoinho | bicycle | Bike 11| bicycle 11 | | |
31 | + When I go to /catalog/redemoinho | |
32 | + Then I should see "Bike 1" | |
33 | + And I should see "Bike 2" | |
34 | + And I should see "Bike 3" | |
35 | + And I should see "Bike 4" | |
36 | + And I should see "Bike 5" | |
37 | + And I should see "Bike 6" | |
38 | + And I should see "Bike 7" | |
39 | + And I should see "Bike 8" | |
40 | + And I should see "Bike 9" | |
41 | + And I should see "Bike 10" | |
42 | + And I should not see "Bike 11" | |
43 | + When I follow "Next" | |
44 | + Then I should see "Bike 11" | |
45 | + | |
14 | 46 | Scenario: listing products and services |
15 | 47 | Given I am logged in as "joaosilva" |
16 | 48 | And I am on Rede Moinho's control panel | ... | ... |
features/register_enterprise.feature
... | ... | @@ -5,8 +5,8 @@ Feature: register enterprise |
5 | 5 | |
6 | 6 | Background: |
7 | 7 | Given the following users |
8 | - | login | name | | |
9 | - | joaosilva | Joao Silva | | |
8 | + | login | name | email | | |
9 | + | joaosilva | Joao Silva | joaosilva@example.com | | |
10 | 10 | |
11 | 11 | And I am logged in as "joaosilva" |
12 | 12 | And I am on Joao Silva's control panel |
... | ... | @@ -80,22 +80,24 @@ Feature: register enterprise |
80 | 80 | Scenario: a user register an enterprise successfully through the admin |
81 | 81 | validator method and the admin accepts |
82 | 82 | Given organization_approval_method is "admin" on environment |
83 | + And the mailbox is empty | |
83 | 84 | And I follow "Manage my groups" |
84 | 85 | And the following states |
85 | 86 | | name | |
86 | 87 | | Sample State | |
87 | 88 | And I follow "Register a new enterprise" |
88 | 89 | And I fill in the following: |
89 | - | Address | my-enterprise | | |
90 | - | Name | My Enterprise | | |
90 | + | Address | my-enterprise | | |
91 | + | Name | My Enterprise | | |
91 | 92 | And I press "Next" |
92 | 93 | Then I should see "Enterprise registration completed" |
93 | 94 | And I am logged in as admin |
94 | 95 | And I follow "Control panel" |
95 | 96 | When I follow "Tasks" |
96 | 97 | Then I should see /Processing task: Enterprise registration: "My Enterprise"/ |
97 | - And I choose "Ok" | |
98 | + And the first mail is to admin_user@example.com | |
98 | 99 | And I press "Ok" |
100 | + Then the last mail is to joaosilva@example.com | |
99 | 101 | And I am logged in as "joaosilva" |
100 | 102 | And I am on Joao Silva's control panel |
101 | 103 | When I follow "Manage my groups" |
... | ... | @@ -104,23 +106,26 @@ Feature: register enterprise |
104 | 106 | Scenario: a user register an enterprise successfully through the admin |
105 | 107 | validator method and the admin rejects |
106 | 108 | Given organization_approval_method is "admin" on environment |
109 | + And the mailbox is empty | |
107 | 110 | And I follow "Manage my groups" |
108 | 111 | And the following states |
109 | 112 | | name | |
110 | 113 | | Sample State | |
111 | 114 | And I follow "Register a new enterprise" |
112 | 115 | And I fill in the following: |
113 | - | Address | my-enterprise | | |
114 | - | Name | My Enterprise | | |
116 | + | Address | my-enterprise | | |
117 | + | Name | My Enterprise | | |
115 | 118 | And I press "Next" |
116 | 119 | Then I should see "Enterprise registration completed" |
117 | 120 | And I am logged in as admin |
118 | 121 | And I follow "Control panel" |
119 | 122 | When I follow "Tasks" |
120 | 123 | Then I should see /Processing task: Enterprise registration: "My Enterprise"/ |
124 | + And the first mail is to admin_user@example.com | |
121 | 125 | And I choose "Cancel" |
122 | 126 | And I fill in "Rejection explanation" with "This enterprise has some irregularities." |
123 | - And I press "Ok" | |
127 | + When I press "Ok" | |
128 | + Then the last mail is to joaosilva@example.com | |
124 | 129 | And I am logged in as "joaosilva" |
125 | 130 | And I am on Joao Silva's control panel |
126 | 131 | When I follow "Manage my groups" | ... | ... |
features/step_definitions/noosfero_steps.rb
... | ... | @@ -210,3 +210,24 @@ end |
210 | 210 | Then /^The page title should contain "(.*)"$/ do |text| |
211 | 211 | response.should have_selector("title:contains('#{text}')") |
212 | 212 | end |
213 | + | |
214 | +Given /^the mailbox is empty$/ do | |
215 | + ActionMailer::Base.deliveries = [] | |
216 | +end | |
217 | + | |
218 | +Given /^the (.+) mail (?:is|has) (.+) (.+)$/ do |position, field, value| | |
219 | + if(/^[0-9]+$/ =~ position) | |
220 | + ActionMailer::Base.deliveries[position.to_i][field] == value | |
221 | + else | |
222 | + ActionMailer::Base.deliveries.send(position)[field] == value | |
223 | + end | |
224 | +end | |
225 | + | |
226 | +Given /^the (.+) mail (.+) is like (.+)$/ do |position, field, regexp| | |
227 | + re = Regexp.new(regexp) | |
228 | + if(/^[0-9]+$/ =~ position) | |
229 | + re =~ ActionMailer::Base.deliveries[position.to_i][field.to_sym] | |
230 | + else | |
231 | + re =~ ActionMailer::Base.deliveries.send(position)[field.to_sym] | |
232 | + end | |
233 | +end | ... | ... |
test/functional/catalog_controller_test.rb
... | ... | @@ -39,6 +39,17 @@ class CatalogControllerTest < Test::Unit::TestCase |
39 | 39 | assert_kind_of Array, assigns(:products) |
40 | 40 | end |
41 | 41 | |
42 | + should 'paginate enterprise products list' do | |
43 | + 1.upto(12).map do | |
44 | + fast_create(Product, :enterprise_id => @enterprise.id) | |
45 | + end | |
46 | + | |
47 | + assert_equal 12, @enterprise.products.count | |
48 | + get :index, :profile => @enterprise.identifier | |
49 | + assert_equal 10, assigns(:products).count | |
50 | + assert_tag :a, :attributes => {:class => 'next_page'} | |
51 | + end | |
52 | + | |
42 | 53 | should 'not give access if environment do not let' do |
43 | 54 | env = Environment.default |
44 | 55 | env.enable('disable_products_for_enterprises') | ... | ... |
test/functional/enterprise_registration_controller_test.rb
... | ... | @@ -170,4 +170,14 @@ all_fixtures |
170 | 170 | assert_no_tag :tag => 'option', :content => "Region without validator" |
171 | 171 | end |
172 | 172 | |
173 | + should 'set current environment as the task target if approval method is admin' do | |
174 | + environment = Environment.new(:name => "Another environment") | |
175 | + environment.organization_approval_method = :admin | |
176 | + environment.save | |
177 | + @controller.stubs(:environment).returns(environment) | |
178 | + | |
179 | + get :index | |
180 | + assert_equal assigns(:create_enterprise).target, environment | |
181 | + end | |
182 | + | |
173 | 183 | end | ... | ... |
test/functional/enterprise_validation_controller_test.rb
... | ... | @@ -74,6 +74,7 @@ class EnterpriseValidationControllerTest < Test::Unit::TestCase |
74 | 74 | |
75 | 75 | should 'require the user to fill in the explanation for an rejection' do |
76 | 76 | validation = CreateEnterprise.new |
77 | + validation.stubs(:environment).returns(Environment.default) | |
77 | 78 | @org.expects(:find_pending_validation).with('kakakaka').returns(validation) |
78 | 79 | |
79 | 80 | # FIXME: this is not working, but should. Anyway the assert_response and | ... | ... |
test/unit/create_enterprise_test.rb
... | ... | @@ -13,6 +13,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
13 | 13 | |
14 | 14 | should 'accept only numbers as foundation year' do |
15 | 15 | task = CreateEnterprise.new |
16 | + task.stubs(:environment).returns(Environment.default) | |
16 | 17 | |
17 | 18 | task.foundation_year = "test" |
18 | 19 | task.valid? |
... | ... | @@ -25,6 +26,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
25 | 26 | |
26 | 27 | should 'require a requestor' do |
27 | 28 | task = CreateEnterprise.new |
29 | + task.stubs(:environment).returns(Environment.default) | |
28 | 30 | task.valid? |
29 | 31 | |
30 | 32 | assert task.errors.invalid?(:requestor_id) |
... | ... | @@ -35,6 +37,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
35 | 37 | |
36 | 38 | should 'require a target (validator organization)' do |
37 | 39 | task = CreateEnterprise.new |
40 | + task.stubs(:environment).returns(Environment.default) | |
38 | 41 | task.valid? |
39 | 42 | |
40 | 43 | assert task.errors.invalid?(:target_id) |
... | ... | @@ -50,6 +53,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
50 | 53 | validator = fast_create(Organization, :name => "My organization", :identifier => 'myorg', :environment_id => environment.id) |
51 | 54 | |
52 | 55 | task = CreateEnterprise.new |
56 | + task.stubs(:environment).returns(Environment.default) | |
53 | 57 | |
54 | 58 | task.region = region |
55 | 59 | task.target = validator |
... | ... | @@ -71,6 +75,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
71 | 75 | |
72 | 76 | should 'require an explanation for rejecting enterprise creation' do |
73 | 77 | task = CreateEnterprise.new |
78 | + task.stubs(:environment).returns(Environment.default) | |
74 | 79 | task.reject_explanation = nil |
75 | 80 | |
76 | 81 | task.valid? |
... | ... | @@ -98,6 +103,8 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
98 | 103 | validator = fast_create(Organization, :name => "My organization", :identifier => 'myorg', :environment_id => environment.id) |
99 | 104 | region.validators << validator |
100 | 105 | person = create_user('testuser').person |
106 | + person.environment = environment | |
107 | + person.save | |
101 | 108 | |
102 | 109 | task = CreateEnterprise.create!({ |
103 | 110 | :name => 'My new enterprise', |
... | ... | @@ -132,6 +139,8 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
132 | 139 | validator = fast_create(Organization, :name => "My organization", :identifier => 'myorg', :environment_id => environment.id) |
133 | 140 | region.validators << validator |
134 | 141 | person = create_user('testuser').person |
142 | + person.environment = environment | |
143 | + person.save | |
135 | 144 | |
136 | 145 | task = CreateEnterprise.create!({ |
137 | 146 | :name => 'My new enterprise', |
... | ... | @@ -161,6 +170,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
161 | 170 | |
162 | 171 | should 'override message methods from Task' do |
163 | 172 | specific = CreateEnterprise.new |
173 | + specific.stubs(:environment).returns(Environment.default) | |
164 | 174 | %w[ task_created_message task_finished_message task_cancelled_message ].each do |method| |
165 | 175 | assert_nothing_raised NotImplementedError do |
166 | 176 | specific.send(method) |
... | ... | @@ -193,7 +203,9 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
193 | 203 | end |
194 | 204 | |
195 | 205 | should 'provide a message to be sent to the target' do |
196 | - assert_not_nil CreateEnterprise.new.target_notification_message | |
206 | + task = CreateEnterprise.new | |
207 | + task.stubs(:environment).returns(Environment.default) | |
208 | + assert_not_nil task.target_notification_message | |
197 | 209 | end |
198 | 210 | |
199 | 211 | should 'report as approved when approved' do |
... | ... | @@ -210,6 +222,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase |
210 | 222 | |
211 | 223 | should 'refuse to create an enterprise creation request with an identifier already used by another profile' do |
212 | 224 | request = CreateEnterprise.new |
225 | + request.stubs(:environment).returns(Environment.default) | |
213 | 226 | request.identifier = 'testid' |
214 | 227 | request.valid? |
215 | 228 | assert !request.errors.invalid?(:identifier) | ... | ... |
test/unit/environment_statistics_block_test.rb
... | ... | @@ -83,4 +83,14 @@ class EnvironmentStatisticsBlockTest < Test::Unit::TestCase |
83 | 83 | assert_match /One community/, content |
84 | 84 | end |
85 | 85 | |
86 | + should 'not display enterprises if disabled' do | |
87 | + env = Environment.new | |
88 | + env.enable('disable_asset_enterprises') | |
89 | + | |
90 | + block = EnvironmentStatisticsBlock.new | |
91 | + block.stubs(:owner).returns(env) | |
92 | + | |
93 | + assert_no_match /enterprises/i, block.content | |
94 | + end | |
95 | + | |
86 | 96 | end | ... | ... |
test/unit/tiny_mce_article_test.rb
... | ... | @@ -83,4 +83,9 @@ class TinyMceArticleTest < Test::Unit::TestCase |
83 | 83 | assert_match /<!-- .* --> <h1> Wellformed html code <\/h1>/, article.body |
84 | 84 | end |
85 | 85 | |
86 | + should 'allow iframe if it is from tv.softwarelivre.org' do | |
87 | + article = TinyMceArticle.create!(:profile => profile, :name => 'article', :abstract => 'abstract', :body => "<iframe id='player-base' src='http://tv.softwarelivre.org/embed/1170' width='482' height='406' align='right' frameborder='0' scrolling='no'></iframe>") | |
88 | + assert_tag_in_string article.body, :tag => 'iframe', :attributes => { :src => "http://tv.softwarelivre.org/embed/1170", :width => "482", :height => "406", :align => "right", :frameborder => "0", :scrolling => "no"} | |
89 | + end | |
90 | + | |
86 | 91 | end | ... | ... |
vendor/plugins/white_list_sanitizer_unescape_before_reescape/init.rb
... | ... | @@ -13,7 +13,7 @@ HTML::WhiteListSanitizer.module_eval do |
13 | 13 | |
14 | 14 | if final_text =~ /iframe/ |
15 | 15 | itheora_video = /<iframe(.*)src=(.*)itheora.org(.*)<\/iframe>/ |
16 | - sl_video = /<iframe(.*)src=\"http:\/\/stream.softwarelivre.org(.*)<\/iframe>/ | |
16 | + sl_video = /<iframe(.*)src=\"http:\/\/(stream|tv).softwarelivre.org(.*)<\/iframe>/ | |
17 | 17 | unless (final_text =~ itheora_video || final_text =~ sl_video) |
18 | 18 | final_text = final_text.gsub(/<iframe(.*)<\/iframe>/, '') |
19 | 19 | end | ... | ... |