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
@@ -4,7 +4,7 @@ class CatalogController < PublicController | @@ -4,7 +4,7 @@ class CatalogController < PublicController | ||
4 | before_filter :check_enterprise_and_environment | 4 | before_filter :check_enterprise_and_environment |
5 | 5 | ||
6 | def index | 6 | def index |
7 | - @products = @profile.products | 7 | + @products = @profile.products.paginate(:per_page => 10, :page => params[:page]) |
8 | end | 8 | end |
9 | 9 | ||
10 | protected | 10 | protected |
app/controllers/public/enterprise_registration_controller.rb
@@ -16,9 +16,9 @@ class EnterpriseRegistrationController < ApplicationController | @@ -16,9 +16,9 @@ class EnterpriseRegistrationController < ApplicationController | ||
16 | @create_enterprise.target = Profile.find(params[:create_enterprise][:target_id]) | 16 | @create_enterprise.target = Profile.find(params[:create_enterprise][:target_id]) |
17 | end | 17 | end |
18 | elsif @validation == :admin || @validation == :none | 18 | elsif @validation == :admin || @validation == :none |
19 | - @create_enterprise.target = @create_enterprise.environment | 19 | + @create_enterprise.target = environment |
20 | end | 20 | end |
21 | - @create_enterprise.requestor = current_user.person | 21 | + @create_enterprise.requestor = user |
22 | the_action = | 22 | the_action = |
23 | if request.post? | 23 | if request.post? |
24 | if @create_enterprise.valid_before_selecting_target? | 24 | if @create_enterprise.valid_before_selecting_target? |
app/models/create_enterprise.rb
@@ -91,7 +91,7 @@ class CreateEnterprise < Task | @@ -91,7 +91,7 @@ class CreateEnterprise < Task | ||
91 | end | 91 | end |
92 | 92 | ||
93 | def environment | 93 | def environment |
94 | - region ? region.environment : self.requestor ? self.requestor.environment : Environment.default | 94 | + requestor.environment |
95 | end | 95 | end |
96 | 96 | ||
97 | def available_regions | 97 | def available_regions |
app/models/environment_statistics_block.rb
@@ -17,11 +17,12 @@ class EnvironmentStatisticsBlock < Block | @@ -17,11 +17,12 @@ class EnvironmentStatisticsBlock < Block | ||
17 | enterprises = owner.enterprises.visible.count | 17 | enterprises = owner.enterprises.visible.count |
18 | communities = owner.communities.visible.count | 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 | block_title(title) + content_tag('ul', info.map {|item| content_tag('li', item) }.join("\n")) | 27 | block_title(title) + content_tag('ul', info.map {|item| content_tag('li', item) }.join("\n")) |
27 | end | 28 | end |
app/views/catalog/index.rhtml
app/views/content_viewer/_comment_form.rhtml
@@ -37,7 +37,7 @@ | @@ -37,7 +37,7 @@ | ||
37 | <%= required labelled_form_field(_('Title'), text_field(:comment, :title)) %> | 37 | <%= required labelled_form_field(_('Title'), text_field(:comment, :title)) %> |
38 | <%= required labelled_form_field(_('Enter your comment'), text_area(:comment, :body, :rows => 5)) %> | 38 | <%= required labelled_form_field(_('Enter your comment'), text_area(:comment, :body, :rows => 5)) %> |
39 | <% button_bar do %> | 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 | <% end %> | 41 | <% end %> |
42 | <% end %> | 42 | <% end %> |
43 | 43 |
app/views/shared/tiny_mce.rhtml
@@ -32,7 +32,7 @@ tinyMCE.init({ | @@ -32,7 +32,7 @@ tinyMCE.init({ | ||
32 | paste_insert_word_content_callback : "convertWord", | 32 | paste_insert_word_content_callback : "convertWord", |
33 | paste_use_dialog: false, | 33 | paste_use_dialog: false, |
34 | apply_source_formatting : true, | 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 | content_css: '/stylesheets/tinymce.css', | 36 | content_css: '/stylesheets/tinymce.css', |
37 | language: <%= tinymce_language.inspect %>, | 37 | language: <%= tinymce_language.inspect %>, |
38 | entity_encoding: 'raw' | 38 | entity_encoding: 'raw' |
config/environment.rb
@@ -72,7 +72,7 @@ Rails::Initializer.run do |config| | @@ -72,7 +72,7 @@ Rails::Initializer.run do |config| | ||
72 | } | 72 | } |
73 | 73 | ||
74 | # Adds custom attributes to the Set of allowed html attributes for the #sanitize helper | 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 | # Adds custom tags to the Set of allowed html tags for the #sanitize helper | 77 | # Adds custom tags to the Set of allowed html tags for the #sanitize helper |
78 | config.action_view.sanitized_allowed_tags = 'object', 'embed', 'param', 'table', 'tr', 'th', 'td', 'applet', 'comment', 'iframe' | 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 @@ | @@ -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,7 +9,7 @@ | ||
9 | # | 9 | # |
10 | # It's strongly recommended to check this file into your version control system. | 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 | create_table "article_versions", :force => true do |t| | 14 | create_table "article_versions", :force => true do |t| |
15 | t.integer "article_id" | 15 | t.integer "article_id" |
features/comment.feature
@@ -57,3 +57,14 @@ Feature: comment | @@ -57,3 +57,14 @@ Feature: comment | ||
57 | When I press "Post comment" | 57 | When I press "Post comment" |
58 | Then I should see "Title can't be blank" | 58 | Then I should see "Title can't be blank" |
59 | And I should see "Body can't be blank" | 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 | \ No newline at end of file | 71 | \ No newline at end of file |
features/manage_products.feature
@@ -11,6 +11,38 @@ Feature: manage products | @@ -11,6 +11,38 @@ Feature: manage products | ||
11 | | redemoinho | joaosilva | Rede Moinho | true | | 11 | | redemoinho | joaosilva | Rede Moinho | true | |
12 | And feature "disable_products_for_enterprises" is disabled on environment | 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 | Scenario: listing products and services | 46 | Scenario: listing products and services |
15 | Given I am logged in as "joaosilva" | 47 | Given I am logged in as "joaosilva" |
16 | And I am on Rede Moinho's control panel | 48 | And I am on Rede Moinho's control panel |
features/register_enterprise.feature
@@ -5,8 +5,8 @@ Feature: register enterprise | @@ -5,8 +5,8 @@ Feature: register enterprise | ||
5 | 5 | ||
6 | Background: | 6 | Background: |
7 | Given the following users | 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 | And I am logged in as "joaosilva" | 11 | And I am logged in as "joaosilva" |
12 | And I am on Joao Silva's control panel | 12 | And I am on Joao Silva's control panel |
@@ -80,22 +80,24 @@ Feature: register enterprise | @@ -80,22 +80,24 @@ Feature: register enterprise | ||
80 | Scenario: a user register an enterprise successfully through the admin | 80 | Scenario: a user register an enterprise successfully through the admin |
81 | validator method and the admin accepts | 81 | validator method and the admin accepts |
82 | Given organization_approval_method is "admin" on environment | 82 | Given organization_approval_method is "admin" on environment |
83 | + And the mailbox is empty | ||
83 | And I follow "Manage my groups" | 84 | And I follow "Manage my groups" |
84 | And the following states | 85 | And the following states |
85 | | name | | 86 | | name | |
86 | | Sample State | | 87 | | Sample State | |
87 | And I follow "Register a new enterprise" | 88 | And I follow "Register a new enterprise" |
88 | And I fill in the following: | 89 | And I fill in the following: |
89 | - | Address | my-enterprise | | ||
90 | - | Name | My Enterprise | | 90 | + | Address | my-enterprise | |
91 | + | Name | My Enterprise | | ||
91 | And I press "Next" | 92 | And I press "Next" |
92 | Then I should see "Enterprise registration completed" | 93 | Then I should see "Enterprise registration completed" |
93 | And I am logged in as admin | 94 | And I am logged in as admin |
94 | And I follow "Control panel" | 95 | And I follow "Control panel" |
95 | When I follow "Tasks" | 96 | When I follow "Tasks" |
96 | Then I should see /Processing task: Enterprise registration: "My Enterprise"/ | 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 | And I press "Ok" | 99 | And I press "Ok" |
100 | + Then the last mail is to joaosilva@example.com | ||
99 | And I am logged in as "joaosilva" | 101 | And I am logged in as "joaosilva" |
100 | And I am on Joao Silva's control panel | 102 | And I am on Joao Silva's control panel |
101 | When I follow "Manage my groups" | 103 | When I follow "Manage my groups" |
@@ -104,23 +106,26 @@ Feature: register enterprise | @@ -104,23 +106,26 @@ Feature: register enterprise | ||
104 | Scenario: a user register an enterprise successfully through the admin | 106 | Scenario: a user register an enterprise successfully through the admin |
105 | validator method and the admin rejects | 107 | validator method and the admin rejects |
106 | Given organization_approval_method is "admin" on environment | 108 | Given organization_approval_method is "admin" on environment |
109 | + And the mailbox is empty | ||
107 | And I follow "Manage my groups" | 110 | And I follow "Manage my groups" |
108 | And the following states | 111 | And the following states |
109 | | name | | 112 | | name | |
110 | | Sample State | | 113 | | Sample State | |
111 | And I follow "Register a new enterprise" | 114 | And I follow "Register a new enterprise" |
112 | And I fill in the following: | 115 | And I fill in the following: |
113 | - | Address | my-enterprise | | ||
114 | - | Name | My Enterprise | | 116 | + | Address | my-enterprise | |
117 | + | Name | My Enterprise | | ||
115 | And I press "Next" | 118 | And I press "Next" |
116 | Then I should see "Enterprise registration completed" | 119 | Then I should see "Enterprise registration completed" |
117 | And I am logged in as admin | 120 | And I am logged in as admin |
118 | And I follow "Control panel" | 121 | And I follow "Control panel" |
119 | When I follow "Tasks" | 122 | When I follow "Tasks" |
120 | Then I should see /Processing task: Enterprise registration: "My Enterprise"/ | 123 | Then I should see /Processing task: Enterprise registration: "My Enterprise"/ |
124 | + And the first mail is to admin_user@example.com | ||
121 | And I choose "Cancel" | 125 | And I choose "Cancel" |
122 | And I fill in "Rejection explanation" with "This enterprise has some irregularities." | 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 | And I am logged in as "joaosilva" | 129 | And I am logged in as "joaosilva" |
125 | And I am on Joao Silva's control panel | 130 | And I am on Joao Silva's control panel |
126 | When I follow "Manage my groups" | 131 | When I follow "Manage my groups" |
features/step_definitions/noosfero_steps.rb
@@ -210,3 +210,24 @@ end | @@ -210,3 +210,24 @@ end | ||
210 | Then /^The page title should contain "(.*)"$/ do |text| | 210 | Then /^The page title should contain "(.*)"$/ do |text| |
211 | response.should have_selector("title:contains('#{text}')") | 211 | response.should have_selector("title:contains('#{text}')") |
212 | end | 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,6 +39,17 @@ class CatalogControllerTest < Test::Unit::TestCase | ||
39 | assert_kind_of Array, assigns(:products) | 39 | assert_kind_of Array, assigns(:products) |
40 | end | 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 | should 'not give access if environment do not let' do | 53 | should 'not give access if environment do not let' do |
43 | env = Environment.default | 54 | env = Environment.default |
44 | env.enable('disable_products_for_enterprises') | 55 | env.enable('disable_products_for_enterprises') |
test/functional/enterprise_registration_controller_test.rb
@@ -170,4 +170,14 @@ all_fixtures | @@ -170,4 +170,14 @@ all_fixtures | ||
170 | assert_no_tag :tag => 'option', :content => "Region without validator" | 170 | assert_no_tag :tag => 'option', :content => "Region without validator" |
171 | end | 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 | end | 183 | end |
test/functional/enterprise_validation_controller_test.rb
@@ -74,6 +74,7 @@ class EnterpriseValidationControllerTest < Test::Unit::TestCase | @@ -74,6 +74,7 @@ class EnterpriseValidationControllerTest < Test::Unit::TestCase | ||
74 | 74 | ||
75 | should 'require the user to fill in the explanation for an rejection' do | 75 | should 'require the user to fill in the explanation for an rejection' do |
76 | validation = CreateEnterprise.new | 76 | validation = CreateEnterprise.new |
77 | + validation.stubs(:environment).returns(Environment.default) | ||
77 | @org.expects(:find_pending_validation).with('kakakaka').returns(validation) | 78 | @org.expects(:find_pending_validation).with('kakakaka').returns(validation) |
78 | 79 | ||
79 | # FIXME: this is not working, but should. Anyway the assert_response and | 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,6 +13,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
13 | 13 | ||
14 | should 'accept only numbers as foundation year' do | 14 | should 'accept only numbers as foundation year' do |
15 | task = CreateEnterprise.new | 15 | task = CreateEnterprise.new |
16 | + task.stubs(:environment).returns(Environment.default) | ||
16 | 17 | ||
17 | task.foundation_year = "test" | 18 | task.foundation_year = "test" |
18 | task.valid? | 19 | task.valid? |
@@ -25,6 +26,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | @@ -25,6 +26,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
25 | 26 | ||
26 | should 'require a requestor' do | 27 | should 'require a requestor' do |
27 | task = CreateEnterprise.new | 28 | task = CreateEnterprise.new |
29 | + task.stubs(:environment).returns(Environment.default) | ||
28 | task.valid? | 30 | task.valid? |
29 | 31 | ||
30 | assert task.errors.invalid?(:requestor_id) | 32 | assert task.errors.invalid?(:requestor_id) |
@@ -35,6 +37,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | @@ -35,6 +37,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
35 | 37 | ||
36 | should 'require a target (validator organization)' do | 38 | should 'require a target (validator organization)' do |
37 | task = CreateEnterprise.new | 39 | task = CreateEnterprise.new |
40 | + task.stubs(:environment).returns(Environment.default) | ||
38 | task.valid? | 41 | task.valid? |
39 | 42 | ||
40 | assert task.errors.invalid?(:target_id) | 43 | assert task.errors.invalid?(:target_id) |
@@ -50,6 +53,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | @@ -50,6 +53,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
50 | validator = fast_create(Organization, :name => "My organization", :identifier => 'myorg', :environment_id => environment.id) | 53 | validator = fast_create(Organization, :name => "My organization", :identifier => 'myorg', :environment_id => environment.id) |
51 | 54 | ||
52 | task = CreateEnterprise.new | 55 | task = CreateEnterprise.new |
56 | + task.stubs(:environment).returns(Environment.default) | ||
53 | 57 | ||
54 | task.region = region | 58 | task.region = region |
55 | task.target = validator | 59 | task.target = validator |
@@ -71,6 +75,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | @@ -71,6 +75,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
71 | 75 | ||
72 | should 'require an explanation for rejecting enterprise creation' do | 76 | should 'require an explanation for rejecting enterprise creation' do |
73 | task = CreateEnterprise.new | 77 | task = CreateEnterprise.new |
78 | + task.stubs(:environment).returns(Environment.default) | ||
74 | task.reject_explanation = nil | 79 | task.reject_explanation = nil |
75 | 80 | ||
76 | task.valid? | 81 | task.valid? |
@@ -98,6 +103,8 @@ class CreateEnterpriseTest < Test::Unit::TestCase | @@ -98,6 +103,8 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
98 | validator = fast_create(Organization, :name => "My organization", :identifier => 'myorg', :environment_id => environment.id) | 103 | validator = fast_create(Organization, :name => "My organization", :identifier => 'myorg', :environment_id => environment.id) |
99 | region.validators << validator | 104 | region.validators << validator |
100 | person = create_user('testuser').person | 105 | person = create_user('testuser').person |
106 | + person.environment = environment | ||
107 | + person.save | ||
101 | 108 | ||
102 | task = CreateEnterprise.create!({ | 109 | task = CreateEnterprise.create!({ |
103 | :name => 'My new enterprise', | 110 | :name => 'My new enterprise', |
@@ -132,6 +139,8 @@ class CreateEnterpriseTest < Test::Unit::TestCase | @@ -132,6 +139,8 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
132 | validator = fast_create(Organization, :name => "My organization", :identifier => 'myorg', :environment_id => environment.id) | 139 | validator = fast_create(Organization, :name => "My organization", :identifier => 'myorg', :environment_id => environment.id) |
133 | region.validators << validator | 140 | region.validators << validator |
134 | person = create_user('testuser').person | 141 | person = create_user('testuser').person |
142 | + person.environment = environment | ||
143 | + person.save | ||
135 | 144 | ||
136 | task = CreateEnterprise.create!({ | 145 | task = CreateEnterprise.create!({ |
137 | :name => 'My new enterprise', | 146 | :name => 'My new enterprise', |
@@ -161,6 +170,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | @@ -161,6 +170,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
161 | 170 | ||
162 | should 'override message methods from Task' do | 171 | should 'override message methods from Task' do |
163 | specific = CreateEnterprise.new | 172 | specific = CreateEnterprise.new |
173 | + specific.stubs(:environment).returns(Environment.default) | ||
164 | %w[ task_created_message task_finished_message task_cancelled_message ].each do |method| | 174 | %w[ task_created_message task_finished_message task_cancelled_message ].each do |method| |
165 | assert_nothing_raised NotImplementedError do | 175 | assert_nothing_raised NotImplementedError do |
166 | specific.send(method) | 176 | specific.send(method) |
@@ -193,7 +203,9 @@ class CreateEnterpriseTest < Test::Unit::TestCase | @@ -193,7 +203,9 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
193 | end | 203 | end |
194 | 204 | ||
195 | should 'provide a message to be sent to the target' do | 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 | end | 209 | end |
198 | 210 | ||
199 | should 'report as approved when approved' do | 211 | should 'report as approved when approved' do |
@@ -210,6 +222,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | @@ -210,6 +222,7 @@ class CreateEnterpriseTest < Test::Unit::TestCase | ||
210 | 222 | ||
211 | should 'refuse to create an enterprise creation request with an identifier already used by another profile' do | 223 | should 'refuse to create an enterprise creation request with an identifier already used by another profile' do |
212 | request = CreateEnterprise.new | 224 | request = CreateEnterprise.new |
225 | + request.stubs(:environment).returns(Environment.default) | ||
213 | request.identifier = 'testid' | 226 | request.identifier = 'testid' |
214 | request.valid? | 227 | request.valid? |
215 | assert !request.errors.invalid?(:identifier) | 228 | assert !request.errors.invalid?(:identifier) |
test/unit/environment_statistics_block_test.rb
@@ -83,4 +83,14 @@ class EnvironmentStatisticsBlockTest < Test::Unit::TestCase | @@ -83,4 +83,14 @@ class EnvironmentStatisticsBlockTest < Test::Unit::TestCase | ||
83 | assert_match /One community/, content | 83 | assert_match /One community/, content |
84 | end | 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 | end | 96 | end |
test/unit/tiny_mce_article_test.rb
@@ -83,4 +83,9 @@ class TinyMceArticleTest < Test::Unit::TestCase | @@ -83,4 +83,9 @@ class TinyMceArticleTest < Test::Unit::TestCase | ||
83 | assert_match /<!-- .* --> <h1> Wellformed html code <\/h1>/, article.body | 83 | assert_match /<!-- .* --> <h1> Wellformed html code <\/h1>/, article.body |
84 | end | 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 | end | 91 | end |
vendor/plugins/white_list_sanitizer_unescape_before_reescape/init.rb
@@ -13,7 +13,7 @@ HTML::WhiteListSanitizer.module_eval do | @@ -13,7 +13,7 @@ HTML::WhiteListSanitizer.module_eval do | ||
13 | 13 | ||
14 | if final_text =~ /iframe/ | 14 | if final_text =~ /iframe/ |
15 | itheora_video = /<iframe(.*)src=(.*)itheora.org(.*)<\/iframe>/ | 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 | unless (final_text =~ itheora_video || final_text =~ sl_video) | 17 | unless (final_text =~ itheora_video || final_text =~ sl_video) |
18 | final_text = final_text.gsub(/<iframe(.*)<\/iframe>/, '') | 18 | final_text = final_text.gsub(/<iframe(.*)<\/iframe>/, '') |
19 | end | 19 | end |