Commit fb92dd6e4ea08844c2290d590688bc6c485a7d14

Authored by Victor Costa
2 parents 141aded0 f6e59824

Merge branch 'fix_role_edition' into stable

AUTHORS.md
... ... @@ -198,6 +198,7 @@ Martín Olivera <molivera@solar.org.ar>
198 198 Moises Machado <moises@colivre.coop.br>
199 199 Naíla Alves <naila@colivre.coop.br>
200 200 Nanda Lopes <nanda.listas+psl@gmail.com>
  201 +Parley Martins <parleypachecomartins@gmail.com>
201 202 Paulo Meirelles + Alessandro Palmeira + João M. M. da Silva <paulo@softwarelivre.org>
202 203 Paulo Meirelles + Alessandro Palmeira <paulo@softwarelivre.org>
203 204 Paulo Meirelles + Carlos Morais <paulo@softwarelivre.org>
... ...
app/helpers/role_helper.rb
1 1 module RoleHelper
  2 +
  3 + def role_available_permissions(role)
  4 + role.kind == "Environment" ? ['Environment', 'Profile'] : [role.kind]
  5 + end
  6 +
2 7 end
... ...
app/views/role/_form.html.erb
... ... @@ -6,10 +6,14 @@
6 6  
7 7 <%= required f.text_field(:name) %>
8 8  
9   - <p><%= _('Permissions:') %><p>
10   - <% permissions.keys.each do |p| %>
11   - <%= check_box_tag("role[permissions][]", p, role.has_permission?(p), { :id => p }) %>
12   - <%= content_tag(:label, permission_name(p), { :for => p }) %><br/>
  9 + <% permissions.each do |key| %>
  10 + <div class="permissions <%= key.downcase %>">
  11 + <h4><%= _('%s Permissions:' % key) %></h4>
  12 + <% ActiveRecord::Base::PERMISSIONS[key].keys.each do |p| %>
  13 + <%= check_box_tag("role[permissions][]", p, role.has_permission?(p), { :id => p }) %>
  14 + <%= content_tag(:label, permission_name(p), { :for => p }) %><br/>
  15 + <% end %>
  16 + </div>
13 17 <% end %>
14 18  
15 19 <% button_bar do %>
... ...
app/views/role/edit.html.erb
1 1 <h2> <%= _("Editing #{@role.name}") %> </h2>
2 2  
3   -<%= render :partial => 'form', :locals => { :mode => :edit, :role => @role, :permissions => ActiveRecord::Base::PERMISSIONS[@role.kind] } %>
  3 +<%= render :partial => 'form', :locals => { :mode => :edit, :role => @role, :permissions => role_available_permissions(@role) } %>
... ...
app/views/role/new.html.erb
1 1 <h2> <%= _("Create a new role") %> </h2>
2 2  
3   -<%= render :partial => 'form', :locals => { :mode => :create, :role => @role, :permissions => ActiveRecord::Base::PERMISSIONS[@role.kind] } %>
  3 +<%= render :partial => 'form', :locals => { :mode => :create, :role => @role, :permissions => role_available_permissions(@role) } %>
... ...
debian/bundle/config
... ... @@ -1,3 +0,0 @@
1   ----
2   -BUNDLE_WITHOUT: test:cucumber
3   -
debian/changelog
  1 +noosfero (1.0~rc4) wheezy-test; urgency=low
  2 +
  3 + * Fourth release candidate
  4 +
  5 + -- Antonio Terceiro <vagrant@wheezy-base> Wed, 19 Nov 2014 10:31:16 -0300
  6 +
1 7 noosfero (1.0~rc3) wheezy-test; urgency=low
2 8  
3 9 * Third release candidate to Noosfero 1.0
... ...
debian/filter-gemfile 0 → 100755
... ... @@ -0,0 +1,5 @@
  1 +#!/bin/sh
  2 +
  3 +set -e
  4 +
  5 +sed -e '/^group\s*:\(test\|cucumber\)/,/^end/ d' Gemfile
... ...
debian/noosfero.install
... ... @@ -7,9 +7,6 @@ util usr/share/noosfero
7 7 Rakefile usr/share/noosfero
8 8 vendor usr/share/noosfero
9 9  
10   -Gemfile usr/share/noosfero
11   -debian/bundle/config usr/share/noosfero/.bundle
12   -
13 10 config/application.rb usr/share/noosfero/config
14 11 config/boot.rb usr/share/noosfero/config
15 12 config/environment.rb usr/share/noosfero/config
... ...
debian/rules
... ... @@ -20,6 +20,10 @@ override_dh_link:
20 20 dh_link usr/lib/noosfero/dbinstall usr/share/dbconfig-common/scripts/noosfero/install/$$db; \
21 21 done
22 22  
  23 +override_dh_auto_install:
  24 + dh_auto_install
  25 + debian/filter-gemfile > $(CURDIR)/debian/noosfero/usr/share/noosfero/Gemfile
  26 +
23 27 override_dh_installinit:
24 28 dh_installinit -pnoosfero --onlyscripts
25 29  
... ...
features/gallery_navigation.feature
... ... @@ -1,86 +0,0 @@
1   -Feature: gallery_navigation
2   - As a noosfero user
3   - I want to navigate over image gallery
4   -
5   - Background:
6   - Given the following users
7   - | login |
8   - | marciopunk |
9   - And the following galleries
10   - | owner | name |
11   - | marciopunk | my-gallery |
12   - | marciopunk | other-gallery |
13   - And the following files
14   - | owner | file | mime | parent |
15   - | marciopunk | rails.png | image/png | my-gallery |
16   - | marciopunk | rails.png | image/png | other-gallery |
17   - | marciopunk | other-pic.jpg | image/jpeg | my-gallery |
18   -
19   - Scenario: provide link to go to next image
20   - Given I am on /marciopunk/my-gallery/other-pic.jpg?view=true
21   - Then I should see "Next »"
22   -
23   - @selenium
24   - Scenario: view next image when follow next link
25   - Given I am on /marciopunk/my-gallery/other-pic.jpg?view=true
26   - When I follow "Next »"
27   - Then I should see "rails.png" within ".title"
28   -
29   - Scenario: not link to next when in last image
30   - When I am on /marciopunk/my-gallery/rails.png?view=true
31   - Then I should see "« Previous" within ".gallery-navigation a"
32   - And I should not see "Next »" within ".gallery-navigation a"
33   -
34   - Scenario: provide link to go to previous image
35   - Given I am on /marciopunk/my-gallery/other-pic.jpg?view=true
36   - Then I should see "« Previous"
37   -
38   - @selenium
39   - Scenario: view previous image when follow previous link
40   - Given I am on /marciopunk/my-gallery/rails.png?view=true
41   - When I follow "« Previous"
42   - Then I should see "other-pic.jpg" within ".title"
43   -
44   - Scenario: not link to previous when in first image
45   - When I am on /marciopunk/my-gallery/other-pic.jpg?view=true
46   - Then I should see "Next »" within ".gallery-navigation a"
47   - And I should not see "« Previous" within ".gallery-navigation a"
48   -
49   - Scenario: display number of current and total of images
50   - Given I am on /marciopunk/my-gallery/other-pic.jpg?view=true
51   - Then I should see "image 1 of 2" within ".gallery-navigation"
52   -
53   - Scenario: increment current number when follow next
54   - Given I am on /marciopunk/my-gallery/other-pic.jpg?view=true
55   - Then I should see "image 1 of 2" within ".gallery-navigation"
56   - When I follow "Next »"
57   - Then I should see "image 2 of 2" within ".gallery-navigation"
58   -
59   - Scenario: decrement current number when follow next
60   - Given I am on /marciopunk/my-gallery/rails.png?view=true
61   - Then I should see "image 2 of 2" within ".gallery-navigation"
62   - When I follow "« Previous"
63   - Then I should see "image 1 of 2" within ".gallery-navigation"
64   -
65   - Scenario: provide button to go back to gallery
66   - Given I am on /marciopunk/my-gallery/rails.png?view=true
67   - Then I should see "Go back to my-gallery"
68   - When I follow "Go back to my-gallery"
69   - Then I should be on /marciopunk/my-gallery
70   -
71   - # Looking for page title is problematic on selenium since it considers the
72   - # title to be invibible. Checkout some information about this:
73   - # * https://github.com/jnicklas/capybara/issues/863
74   - # * https://github.com/jnicklas/capybara/pull/953
75   - @selenium
76   - Scenario: image title in window title
77   - Given I am logged in as "marciopunk"
78   - When I go to /marciopunk/other-gallery/rails.png?view=true
79   - Then I should see "rails.png" within any "h1"
80   -# And the page title should be "rails.png"
81   - And I follow "Edit"
82   - And I fill in "Title" with "Rails is cool"
83   - And I press "Save"
84   - When I go to /marciopunk/other-gallery/rails.png?view=true
85   - Then I should see "Rails is cool" within any "h1"
86   - #Then the page title should be "Rails is cool"
features/signup.feature
... ... @@ -278,29 +278,6 @@ Feature: signup
278 278 Then "José da Silva" should be a member of "Free Software"
279 279  
280 280 @selenium
281   - Scenario: join community on direct signup
282   - Given the following users
283   - | login | name |
284   - | mariasilva | Maria Silva |
285   - And the following communities
286   - | name | identifier | owner |
287   - | Free Software | freesoftware | mariasilva |
288   - And feature "skip_new_user_email_confirmation" is enabled on environment
289   - And I am on /freesoftware
290   - When I follow "Join"
291   - And I follow "New user"
292   - And I fill in the following within ".no-boxes":
293   - | e-Mail | josesilva@example.com |
294   - | Username | josesilva |
295   - | Password | secret |
296   - | Password confirmation | secret |
297   - | Full name | José da Silva |
298   - And wait for the captcha signup time
299   - And I press "Create my account"
300   - Then I should see "Control panel"
301   - And "José da Silva" should be a member of "Free Software"
302   -
303   - @selenium
304 281 Scenario: user registration is moderated by admin
305 282 Given feature "admin_must_approve_new_users" is enabled on environment
306 283 And feature "skip_new_user_email_confirmation" is disabled on environment
... ...
lib/noosfero/version.rb
1 1 module Noosfero
2 2 PROJECT = 'noosfero'
3   - VERSION = '1.0~rc3'
  3 + VERSION = '1.0~rc4'
4 4 end
... ...
lib/tasks/plugins_tests.rake
  1 +@broken_plugins = %w[
  2 + anti_spam
  3 + bsc
  4 + comment_classification
  5 + ldap
  6 + send_email
  7 + shopping_cart
  8 + solr
  9 + tolerance_time
  10 +]
  11 +
1 12 @all_plugins = Dir.glob('plugins/*').map { |f| File.basename(f) } - ['template']
2 13 @all_plugins.sort!
3 14 @all_tasks = [:units, :functionals, :integration, :cucumber, :selenium]
... ... @@ -167,6 +178,7 @@ def test_sequence(plugins, tasks)
167 178 end
168 179 end
169 180 rollback_plugins_state
  181 + yield(failed) if block_given?
170 182 fail 'There are broken tests to be fixed!' if fail_flag
171 183 end
172 184  
... ... @@ -195,13 +207,39 @@ namespace :test do
195 207 @all_tasks.each do |taskname|
196 208 desc "Run #{taskname} tests for all plugins"
197 209 task taskname do
198   - test_sequence(@all_plugins, taskname)
  210 + test_sequence(@all_plugins - @broken_plugins, taskname)
199 211 end
200 212 end
201 213 end
202 214  
203 215 desc "Run all tests for all plugins"
204 216 task :noosfero_plugins do
205   - test_sequence(@all_plugins, @all_tasks)
  217 + test_sequence(@all_plugins - @broken_plugins, @all_tasks) do |failed|
  218 + plugins_status_report(failed)
  219 + end
206 220 end
207 221 end
  222 +
  223 +def plugins_status_report(failed)
  224 + w = @all_plugins.map { |s| s.size }.max
  225 +
  226 + puts
  227 + printf ('=' * (w + 21)) + "\n"
  228 + puts 'Plugins status report'
  229 + printf ('=' * (w + 21)) + "\n"
  230 + printf "%-#{w}s %s\n", "Plugin", "Status"
  231 + printf ('-' * w) + ' ' + ('-' * 20) + "\n"
  232 +
  233 + @all_plugins.each do |plugin|
  234 + if @broken_plugins.include?(plugin)
  235 + status = "SKIP"
  236 + elsif !failed[plugin] || failed[plugin].empty?
  237 + status = "PASS"
  238 + else
  239 + status = "FAIL: #{failed[plugin].join(', ')}"
  240 + end
  241 + printf "%-#{w}s %s\n", plugin, status
  242 + end
  243 + printf ('=' * (w + 21)) + "\n"
  244 + puts
  245 +end
... ...
test/functional/role_controller_test.rb
... ... @@ -78,4 +78,24 @@ class RoleControllerTest &lt; ActionController::TestCase
78 78 get :edit, :id => role.id
79 79 end
80 80 end
  81 +
  82 + should 'display permissions for both environment and profile when editing a environment role' do
  83 + role = Role.create!(:name => 'environment_role', :key => 'environment_role', :environment => Environment.default)
  84 + get :edit, :id => role.id
  85 + ['Environment', 'Profile'].each do |key|
  86 + ActiveRecord::Base::PERMISSIONS[key].each do |permission, value|
  87 + assert_select ".permissions.#{key.downcase} input##{permission}"
  88 + end
  89 + end
  90 + end
  91 +
  92 + should 'display permissions only for profile when editing a profile role' do
  93 + role = Role.create!(:name => 'profile_role', :key => 'profile_role', :environment => Environment.default)
  94 + get :edit, :id => role.id
  95 + ActiveRecord::Base::PERMISSIONS['Profile'].each do |permission, value|
  96 + assert_select "input##{permission}"
  97 + end
  98 + assert_select ".permissions.environment", false
  99 + end
  100 +
81 101 end
... ...
util/debian-install/.gitignore 0 → 100644
... ... @@ -0,0 +1 @@
  1 +*.deb
... ...
util/debian-install/README.md 0 → 100644
... ... @@ -0,0 +1,3 @@
  1 +This directory contains the basic structure to test the installation of
  2 +Noosfero debian packages, using a fresh Vagrant VM and packages built in
  3 +${NOOSFEROROOT}/pkg/.
... ...
util/debian-install/Vagrantfile 0 → 100644
... ... @@ -0,0 +1,30 @@
  1 +# -*- mode: ruby -*-
  2 +# vi: set ft=ruby :
  3 +
  4 +# Vagrantfile API/syntax version. Don't touch unless you know what you're doing!
  5 +VAGRANTFILE_API_VERSION = "2"
  6 +
  7 +require 'fileutils'
  8 +debs = `find ../../pkg/ -name '*.deb' | sort -t _ -V | tail -2`.split
  9 +if debs.empty?
  10 + puts "W: no debs built in ../../pkg/; will either install existing local"
  11 + puts " ones, or the ones from the remote repository"
  12 +else
  13 + local_debs = Dir.glob('*.deb')
  14 + debs.each do |f|
  15 + fn = File.basename(f)
  16 + if local_debs.include?(fn)
  17 + local_debs.delete(fn)
  18 + else
  19 + FileUtils::Verbose.ln f, '.'
  20 + end
  21 + end
  22 + local_debs.each do |f|
  23 + FileUtils::Verbose.rm_f f
  24 + end
  25 +end
  26 +
  27 +Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
  28 + config.vm.box = "debian-wheezy"
  29 + config.vm.provision :shell, path: 'install'
  30 +end
... ...
util/debian-install/install 0 → 100755
... ... @@ -0,0 +1,78 @@
  1 +#!/bin/sh
  2 +
  3 +set -e
  4 +sudo apt-get install -qy netcat-traditional
  5 +
  6 +# apt-cacher-ng running on the host
  7 +# 10.0.2.2 = host ip on virtualbox/qemu
  8 +# 192.168.122.1 = host ip on default libvirt bridge
  9 +for ip in 10.0.2.2 192.168.122.1; do
  10 + if nc -z -w 1 $ip 3142; then
  11 + echo "Acquire::http::Proxy \"http://$ip:3142\";" | sudo tee /etc/apt/apt.conf.d/01proxy
  12 + fi
  13 +done
  14 +
  15 +apt-key add - <<EOF
  16 +-----BEGIN PGP PUBLIC KEY BLOCK-----
  17 +Version: GnuPG v1.4.9 (GNU/Linux)
  18 +
  19 +mQGiBE1HCIURBADw6SnRbc1qCHdTV9wD0rxSMIWevzUX+bnDgvV455yudqtVFUhX
  20 +2QYvtlwclllbLWKzRdiM7GsBi+2DyWli4B17xl86A5RBQNdc1v1vWZG3QwURxd4E
  21 +46fC6mR/K09mJl7aD0yq1rFFLt8pq8aCn6geslqqwAkQHR1gXEL8ftqcpwCg7EkU
  22 +n/yivf3qPX03zWBDmdQZog0D/2z0JGdVqLZJHAKjndKHSCuQlP+8d8NF0d27kStN
  23 +hJjX8WcBLFKo9BeZUZnc0Kgq7+6p3wuvI1MzyqSEVEi2YxSB0zXU59HGrXtRQlQ2
  24 +YksppP2Hwe30/qrLgWJnNP4pxmWjv0F3PFSD4Om07hGxJ2ldWdBlfh2mAwOPtSXK
  25 +yYTZA/93+OvQSyneVEBNMH58cCB98tbn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FgM3CQR9mRh56p
  41 +EWorsDpd08puRFoPevEGe99+McZ29pR6f3RbrcFe2ws7lw2w8AJbHgelXRbeEie+
  42 +x/4Nfu/UATsAAwUP+gN2nSgLAS2Md3awg9mBI6VufflMbsuZJxjemJ9Phdyx5PR2
  43 +PvRvyZffaqZltTbBxPiOA1wAIpeWNVJehCpiZgXih93HMTrucBvYyLlbxr7Or7ex
  44 +t1/K7TZo5Si+yJ6zNCNXewPimZCV1oUWE8P2uy8iyMUhgpFc7q7xeQCOkvqYphlA
  45 +bUT8BcD6Coo4s98gOfgetch0fgCdiCYTNbT0+7jOw8sTx7DmlQHKSmQ6NXOZypI7
  46 +lk3OwZIGB6t+Os2Q8uLYxoWzK6fqc8CSSgQPpL4wd4w9/etwzav3/SiZJN3NE0UL
  47 +RoayneyD0bC83w2HAEcYb8qDsF85pPkjXSXZdlXulTZC89/4yq8h6hJODOQ7hKTx
  48 +TvEE5i3LmAYj+uTbuoauYBJMiU2oXrqfCGR+tmxz5V7QSwLdy0d95w0F/Rj1sesO
  49 +SfBRGyxqSqQsO9KDMJdmi/FyjiPBVKE3i9YFWsePLnHs3JNCRehDt3xpap3YrjBW
  50 +MAMb36KpZ9M6Cj2nRjB4pfVNno0hmsQ3+8So2vBW/UAbHUW/izQPRFVp+HXVxDf6
  51 +xjIi9gyocstFCkKrD7NFL/7u6fWginUNXIjYAdqbqRIihzfW7Et2QiPL4tnQrQey
  52 +4P8Y7+gThn0CWeJw4leCueYr/yYUJ7lelYCd9q2uphC/2KinUxBSInKjQ7+8iEkE
  53 +GBECAAkFAk1HCIUCGwwACgkQul5LTJ8ebae2qgCeOMvYOOVDVtchTRhD56VlYKOi
  54 +FPQAoNmiMgP6zGF9rgOEWMEiFEryayrz
  55 +=70DR
  56 +-----END PGP PUBLIC KEY BLOCK-----
  57 +EOF
  58 +
  59 +cat > /etc/apt/sources.list.d/noosfero.list <<EOF
  60 +deb http://download.noosfero.org/debian/wheezy ./
  61 +deb-src http://download.noosfero.org/debian/wheezy ./
  62 +deb http://download.noosfero.org/debian/wheezy-test ./
  63 +deb-src http://download.noosfero.org/debian/wheezy-test ./
  64 +EOF
  65 +
  66 +export DEBIAN_FRONTEND=noninteractive
  67 +
  68 +apt-get update
  69 +apt-get dist-upgrade -qy
  70 +apt-get install -qy postgresql ruby1.8
  71 +
  72 +if dpkg --unpack /vagrant/noosfero_*.deb /vagrant/noosfero-apache_*.deb; then
  73 + apt-cache policy noosfero
  74 + apt-get install -qyf
  75 +else
  76 + apt-cache policy noosfero
  77 + apt-get install -qy noosfero noosfero-apache
  78 +fi
... ...