Commit e7d2150da3ce8738c321ddd6ceef0c380df180a0

Authored by Daniela Feitosa
2 parents 85a2cfa4 fbe9c876

Merge branch 'stable'

Conflicts:
	features/step_definitions/noosfero_steps.rb
	test/functional/profile_design_controller_test.rb
app/helpers/application_helper.rb
... ... @@ -1119,11 +1119,11 @@ module ApplicationHelper
1119 1119 pending_tasks_count = link_to(user.all_pending_tasks.count.to_s, '/myprofile/{login}/tasks', :id => 'pending-tasks-count', :title => _("Manage your pending tasks"))
1120 1120 end
1121 1121  
1122   - (_('Welcome, %s') % link_to('<i></i><strong>{login}</strong>', '/{login}', :id => "homepage-link", :title => _('Go to your homepage'))) +
  1122 + (_('Welcome, %s') % link_to('<i></i><strong>{login}</strong>', @environment.top_url + '/{login}', :id => "homepage-link", :title => _('Go to your homepage'))) +
1123 1123 render_environment_features(:usermenu) +
1124 1124 link_to('<i class="icon-menu-admin"></i><strong>' + _('Administration') + '</strong>', { :controller => 'admin_panel', :action => 'index' }, :id => "controlpanel", :title => _("Configure the environment"), :class => 'admin-link', :style => 'display: none') +
1125 1125 manage_enterprises.to_s +
1126   - link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', '/myprofile/{login}', :id => "controlpanel", :title => _("Configure your personal account and content")) +
  1126 + link_to('<i class="icon-menu-ctrl-panel"></i><strong>' + _('Control panel') + '</strong>', @environment.top_url + '/myprofile/{login}', :id => "controlpanel", :title => _("Configure your personal account and content")) +
1127 1127 pending_tasks_count +
1128 1128 link_to('<i class="icon-menu-logout"></i><strong>' + _('Logout') + '</strong>', { :controller => 'account', :action => 'logout'} , :id => "logout", :title => _("Leave the system"))
1129 1129 end
... ...
app/models/domain.rb
... ... @@ -10,7 +10,7 @@ class Domain &lt; ActiveRecord::Base
10 10  
11 11 # <tt>name</tt> must be a sequence of word characters (a to z, plus 0 to 9,
12 12 # plus '_'). Letters must be lowercase
13   - validates_format_of :name, :with => /^([a-z0-9_]+\.)+[a-z0-9_]+$/, :message => N_('%{fn} must be composed only of lowercase latters (a to z), numbers (0 to 9) and "_"')
  13 + validates_format_of :name, :with => /^([a-z0-9_-]+\.)+[a-z0-9_-]+$/, :message => N_('%{fn} must be composed only of lowercase latters (a to z), numbers (0 to 9), "_" and "-"')
14 14  
15 15 # checks validations that could not be expressed using Rails' predefined
16 16 # validations. In particular:
... ...
app/models/link_list_block.rb
... ... @@ -57,7 +57,7 @@ class LinkListBlock &lt; Block
57 57 def link_html(link)
58 58 klass = 'icon-' + link[:icon] if link[:icon]
59 59 sanitize_link(
60   - link_to(_(link[:name]), expand_address(link[:address]), :class => klass)
  60 + link_to(link[:name], expand_address(link[:address]), :class => klass)
61 61 )
62 62 end
63 63  
... ...
app/views/blocks/profile_image.rhtml
... ... @@ -20,5 +20,5 @@
20 20  
21 21 </div><!-- end class="vcard" -->
22 22 <script type="text/javascript">
23   - <%= remote_function :url => { :controller => 'profile', :action => 'profile_info', :block_id => block.id } %>
  23 + <%= remote_function :url => { :controller => 'profile', :profile => profile.identifier, :action => 'profile_info', :block_id => block.id } %>
24 24 </script>
... ...
app/views/blocks/profile_info.rhtml
... ... @@ -41,5 +41,5 @@
41 41  
42 42 </div><!-- end class="vcard" -->
43 43 <script type="text/javascript">
44   - <%= remote_function :url => { :controller => 'profile', :action => 'profile_info', :block_id => block.id } %>
  44 + <%= remote_function :url => { :controller => 'profile', :profile => profile.identifier, :action => 'profile_info', :block_id => block.id } %>
45 45 </script>
... ...
app/views/box_organizer/_article_block.rhtml
... ... @@ -5,6 +5,6 @@
5 5 </p>
6 6 <% else %>
7 7 <% articles = @block.available_articles.select {|article| !article.folder? } %>
8   - <%= select_tag('block[article_id]', options_for_select_with_title(articles.map {|item| [item.path, item.id]})) %>
  8 + <%= select_tag('block[article_id]', options_for_select_with_title(articles.map {|item| [item.path, item.id]}, @block.article ? @block.article.id : nil)) %>
9 9 <% end %>
10 10 </div>
... ...
app/views/layouts/chat.rhtml
... ... @@ -26,7 +26,7 @@
26 26 </head>
27 27 <body id='chat'>
28 28 <div id='title-bar'>
29   - <h1 class='title'><%= _("%s - Friends in chat (<span id='friends-online'>%d</span>)") % [h(page_title), 0] %></h1>
  29 + <h1 class='title'><%= _("%s - Friends online (<span id='friends-online'>%d</span>)") % [h(page_title), 0] %></h1>
30 30 </div>
31 31 <div id='buddy-list'>
32 32 <div id='environment-logo'>
... ...
app/views/shared/logged_in/xmpp_chat.rhtml
... ... @@ -6,6 +6,6 @@
6 6 </div>
7 7 </div>
8 8 <a href='#' id='chat-online-users-title' onclick='return false;'>
9   - <div class='header'><i class='icon-chat'></i><span><%= _("Online friends <span class='amount_of_friends'>(%{amount})</span>") %></span></div>
  9 + <div class='header'><i class='icon-chat'></i><span><%= _("Friends in chat <span class='amount_of_friends'>(%{amount})</span>") %></span></div>
10 10 </a>
11 11 </div>
... ...
app/views/shared/not_found.rhtml
... ... @@ -6,6 +6,6 @@
6 6 </p>
7 7 <% button_bar do %>
8 8 <%= button :back, _('Go back'), :back %>
9   - <%= button :home, _('Go to %s home page') % environment.name, :controller => 'home' %>
  9 + <%= button :home, _('Go to the home page'), '/' %>
10 10 <% end %>
11 11 </div>
... ...
features/chat.feature
... ... @@ -23,7 +23,7 @@ Feature: chat
23 23 Scenario: provide the chat online users content
24 24 Given feature "xmpp_chat" is enabled on environment
25 25 And I am logged in as "tame"
26   - Then I should see "Online friends "
  26 + Then I should see "Friends in chat "
27 27  
28 28 @selenium
29 29 Scenario: provide the chat online users list
... ... @@ -46,7 +46,7 @@ Feature: chat
46 46 @selenium
47 47 Scenario: not provide the chat online users list when environment not support that
48 48 Given I am logged in as "tame"
49   - Then I should not see "Online friends "
  49 + Then I should not see "Friends in chat "
50 50  
51 51 Scenario: block access to chat when environment not support that
52 52 Given I am logged in as "tame"
... ... @@ -64,7 +64,7 @@ Feature: chat
64 64 And I am logged in as "tame"
65 65 When I follow "Open chat"
66 66 And I select window "noosfero_chat"
67   - Then I should see "Chat - Colivre.net - Friends in chat (0)"
  67 + Then I should see "Chat - Colivre.net - Friends online (0)"
68 68  
69 69 @selenium
70 70 Scenario: open chat with an online user in a new window
... ... @@ -75,7 +75,7 @@ Feature: chat
75 75 When I click "#chat-online-users-title"
76 76 And I follow "Maria Silva"
77 77 And I select window "noosfero_chat"
78   - Then I should see "Chat - Colivre.net - Friends in chat (0)"
  78 + Then I should see "Chat - Colivre.net - Friends online (0)"
79 79  
80 80 @selenium
81 81 Scenario: chat starts disconnected by default
... ... @@ -141,4 +141,4 @@ Feature: chat
141 141 When I go to Autoramas's profile
142 142 And I follow "Enter chat room"
143 143 And I select window "noosfero_chat"
144   - Then I should see "Chat - Colivre.net - Friends in chat (0)"
  144 + Then I should see "Chat - Colivre.net - Friends online (0)"
... ...
features/profile_domain.feature 0 → 100644
... ... @@ -0,0 +1,66 @@
  1 +Feature: domain for profile
  2 + As a user
  3 + I want access a profile by its own domain
  4 +
  5 + Background:
  6 + Given the following user
  7 + | login | name |
  8 + | joaosilva | Joao Silva |
  9 + And the following communities
  10 + | identifier | name | domain |
  11 + | sample-community | Sample Community | localhost |
  12 + And the following blocks
  13 + | owner | type |
  14 + | sample-community | ProfileImageBlock |
  15 + | sample-community | ProfileInfoBlock |
  16 + And the environment domain is "127.0.0.1"
  17 + And "Joao Silva" is admin of "Sample Community"
  18 +
  19 + @selenium
  20 + Scenario: access profile control panel through profile blocks
  21 + Given I am logged in as "joaosilva"
  22 + When I visit "/" and wait
  23 + And I follow "Control panel" within "div.profile-info-block" and wait
  24 + Then I should see "Sample Community" within "span.control-panel-title"
  25 + When I visit "/" and wait
  26 + And I follow "Control panel" within "div.profile-image-block" and wait
  27 + Then I should see "Sample Community" within "span.control-panel-title"
  28 +
  29 + @selenium
  30 + Scenario: access user control panel
  31 + Given I am logged in as "joaosilva"
  32 + When I visit "/" and wait
  33 + And I follow "joaosilva" and wait
  34 + And I follow "Login"
  35 + And I fill in "joaosilva" for "Username"
  36 + And I fill in "123456" for "Password"
  37 + And I press "Log in" and wait
  38 + And I follow "Control panel" within "div#user" and wait
  39 + Then I should see "Joao Silva" within "span.control-panel-title"
  40 +
  41 + @selenium
  42 + Scenario: access user page
  43 + Given I am logged in as "joaosilva"
  44 + When I visit "/" and wait
  45 + And I follow "joaosilva" and wait
  46 + Then The page title should contain "Joao Silva"
  47 +
  48 + @selenium
  49 + Scenario: access community by domain
  50 + When I go to the homepage
  51 + Then The page title should contain "Sample Community"
  52 +
  53 + @selenium
  54 + Scenario: Go to profile homepage after clicking on home button on not found page
  55 + Given I am on the homepage
  56 + When I go to /something-that-does-not-exist
  57 + And I follow "Go to the home page"
  58 + Then the page title should be "Sample Community - Colivre.net"
  59 +
  60 + @selenium
  61 + Scenario: Go to environment homepage after clicking on home button on not found page
  62 + Given I am on the homepage
  63 + And I click on the logo
  64 + When I open /something-that-does-not-exist
  65 + And I follow "Go to the home page"
  66 + Then the page title should be "Colivre.net"
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -20,10 +20,15 @@ Given /^the following (community|communities|enterprises?|organizations?)$/ do |
20 20 klass = kind.singularize.camelize.constantize
21 21 table.hashes.each do |row|
22 22 owner = row.delete("owner")
  23 + domain = row.delete("domain")
23 24 organization = klass.create!(row)
24 25 if owner
25 26 organization.add_admin(Profile[owner])
26 27 end
  28 + if domain
  29 + d = Domain.new :name => domain, :owner => organization
  30 + d.save(false)
  31 + end
27 32 end
28 33 end
29 34  
... ... @@ -421,3 +426,8 @@ Given /^that the default environment have (.+) templates?$/ do |option|
421 426 env.inactive_enterprise_template && env.inactive_enterprise_template.destroy
422 427 end
423 428 end
  429 +
  430 +Given /^the environment domain is "([^\"]*)"$/ do |domain|
  431 + d = Domain.new :name => domain, :owner => Environment.default
  432 + d.save(false)
  433 +end
... ...
features/step_definitions/selenium_steps.rb
... ... @@ -103,6 +103,19 @@ When /^I refresh the page$/ do
103 103 response.selenium.refresh
104 104 end
105 105  
  106 +When /^I click on the logo$/ do
  107 + selenium.click("css=h1#site-title a")
  108 + selenium.wait_for_page_to_load(10000)
  109 +end
  110 +
  111 +When /^I open (.*)$/ do |url|
  112 + selenium.open(URI.join(response.selenium.get_location, url))
  113 +end
  114 +
  115 +Then /^the page title should be "([^"]+)"$/ do |text|
  116 + selenium.get_text("//title").should == text
  117 +end
  118 +
106 119 #### Noosfero specific steps ####
107 120  
108 121 Then /^the select for category "([^\"]*)" should be visible$/ do |name|
... ...
test/functional/profile_design_controller_test.rb
... ... @@ -432,4 +432,11 @@ class ProfileDesignControllerTest &lt; Test::Unit::TestCase
432 432 assert_no_tag :tag => 'input', :attributes => { :id => 'type_rawhtmlblock', :value => 'RawHTMLBlock' }
433 433 end
434 434  
  435 + should 'editing article block displays right selected article' do
  436 + selected_article = fast_create(Article, :profile_id => profile.id)
  437 + ArticleBlock.any_instance.stubs(:article).returns(selected_article)
  438 + get :edit, :profile => 'designtestuser', :id => @b1.id
  439 + assert_tag :tag => 'option', :attributes => {:value => selected_article.id, :selected => 'selected'}
  440 + end
  441 +
435 442 end
... ...
test/integration/manage_documents_test.rb
... ... @@ -5,10 +5,10 @@ class ManageDocumentsTest &lt; ActionController::IntegrationTest
5 5 all_fixtures
6 6  
7 7 def test_creation_of_a_new_article
8   - create_user('myuser')
  8 + user = create_user('myuser')
9 9  
10 10 login('myuser', 'myuser')
11   - assert_tag :tag => 'a', :attributes => { :href => '/myprofile/{login}' }
  11 + assert_tag :tag => 'a', :attributes => { :href => "#{user.environment.top_url}/myprofile\/{login}" }
12 12  
13 13 get '/myprofile/myuser'
14 14 assert_response :success
... ... @@ -38,7 +38,7 @@ class ManageDocumentsTest &lt; ActionController::IntegrationTest
38 38 article.save!
39 39  
40 40 login('myuser', 'myuser')
41   - assert_tag :tag => 'a', :attributes => { :href => '/myprofile/{login}' }
  41 + assert_tag :tag => 'a', :attributes => { :href => "#{profile.environment.top_url}\/myprofile\/{login}" }
42 42  
43 43 get '/myprofile/myuser'
44 44 assert_response :success
... ... @@ -72,7 +72,7 @@ class ManageDocumentsTest &lt; ActionController::IntegrationTest
72 72  
73 73 login('myuser', 'myuser')
74 74  
75   - assert_tag :tag => 'a', :attributes => { :href => '/myprofile/{login}' }
  75 + assert_tag :tag => 'a', :attributes => { :href => "#{profile.environment.top_url}\/myprofile\/{login}" }
76 76 get '/myprofile/myuser'
77 77 assert_response :success
78 78  
... ...
test/unit/domain_test.rb
... ... @@ -7,23 +7,40 @@ class DomainTest &lt; Test::Unit::TestCase
7 7 Domain.clear_cache
8 8 end
9 9  
10   - # Replace this with your real tests.
11   - def test_domain_name_format
12   - c = Domain.new
13   - assert !c.valid?
14   - assert c.errors.invalid?(:name)
15   -
16   - c.name = 'bliblibli'
17   - assert !c.valid?
18   - assert c.errors.invalid?(:name)
19   -
20   - c.name = 'EXAMPLE.NET'
21   - assert !c.valid?
22   - assert c.errors.invalid?(:name)
23   -
24   - c.name = 'test.net'
25   - c.valid?
26   - assert !c.errors.invalid?(:name)
  10 + should 'not allow domains without name' do
  11 + domain = Domain.new
  12 + domain.valid?
  13 + assert domain.errors.invalid?(:name)
  14 + end
  15 +
  16 + should 'not allow domain without dot' do
  17 + domain = Domain.new(:name => 'test')
  18 + domain.valid?
  19 + assert domain.errors.invalid?(:name)
  20 + end
  21 +
  22 + should 'allow domains with dot' do
  23 + domain = Domain.new(:name => 'test.org')
  24 + domain.valid?
  25 + assert !domain.errors.invalid?(:name)
  26 + end
  27 +
  28 + should 'not allow domains with upper cased letters' do
  29 + domain = Domain.new(:name => 'tEst.org')
  30 + domain.valid?
  31 + assert domain.errors.invalid?(:name)
  32 + end
  33 +
  34 + should 'allow domains with hyphen' do
  35 + domain = Domain.new(:name => 'test-domain.org')
  36 + domain.valid?
  37 + assert !domain.errors.invalid?(:name)
  38 + end
  39 +
  40 + should 'allow domains with underscore' do
  41 + domain = Domain.new(:name => 'test_domain.org')
  42 + domain.valid?
  43 + assert !domain.errors.invalid?(:name)
27 44 end
28 45  
29 46 def test_owner
... ...