Commit d1300777121421c513974b14f6ff8fc1c190c4fa
Exists in
staging
and in
4 other branches
fixing conflit with api branch
Showing
45 changed files
with
706 additions
and
774 deletions
Show diff stats
AUTHORS.md
| ... | ... | @@ -83,6 +83,9 @@ Carlos Morais + Eduardo Morais <carlos88morais@gmail.com> |
| 83 | 83 | Carlos Morais + Paulo Meirelles <carlos88morais@gmail.com> |
| 84 | 84 | Carlos Morais + Pedro Leal <carlos88morais@gmail.com> |
| 85 | 85 | Carlos Morais <carlos88morais@gmail.com> |
| 86 | +Christophe DANIEL <papaeng@gmail.com> | |
| 87 | +Daniel Alves + Diego Araújo <danpaulalves@gmail.com> | |
| 88 | +Daniel Alves + Diego Araújo <diegoamc90@gmail.com> | |
| 86 | 89 | Daniel Alves + Diego Araújo + Guilherme Rojas <danpaulalves@gmail.com> |
| 87 | 90 | Daniel Alves + Diego Araújo + Guilherme Rojas <diegoamc90@gmail.com> |
| 88 | 91 | Daniel Alves + Diego Araújo + Guilherme Rojas <guilhermehrojas@gmail.com> |
| ... | ... | @@ -128,6 +131,7 @@ Eduardo Vital <vitaldu@gmail.com> |
| 128 | 131 | Evandro Jr <evandrojr@gmail.com> |
| 129 | 132 | Evandro Junior <evandrojr@gmail.com> |
| 130 | 133 | Evandro Magalhaes Leite Junior <evandro.leite@serpro.gov.br> |
| 134 | +Fabio Teixeira <fabio1079@gmail.com> | |
| 131 | 135 | FAMMA TV NOTICIAS MEDIOS DE CO <revistafammatvmusic.oficial@gmail.com> |
| 132 | 136 | Fabio Teixeira <fabio1079@gmail.com> |
| 133 | 137 | Fernanda Lopes <nanda.listas+psl@gmail.com> | ... | ... |
Gemfile
| ... | ... | @@ -18,6 +18,7 @@ gem 'exception_notification', '~> 4.0.1' |
| 18 | 18 | gem 'gettext', '~> 2.2.1', :require => false |
| 19 | 19 | gem 'locale', '~> 2.0.5' |
| 20 | 20 | gem 'whenever', :require => false |
| 21 | +gem 'eita-jrails', '~> 0.9.5', require: 'jrails' | |
| 21 | 22 | gem 'grape', '~> 0.11.0' |
| 22 | 23 | gem 'grape-entity' |
| 23 | 24 | gem 'grape-swagger' |
| ... | ... | @@ -30,7 +31,9 @@ gem 'liquid', '~> 3.0.3' |
| 30 | 31 | |
| 31 | 32 | # FIXME list here all actual dependencies (i.e. the ones in debian/control), |
| 32 | 33 | # with their GEM names (not the Debian package names) |
| 33 | -gem 'eita-jrails', '~> 0.9.5', require: 'jrails' | |
| 34 | + | |
| 35 | +# FIXME list here all actual dependencies (i.e. the ones in debian/control), | |
| 36 | +# with their GEM names (not the Debian package names) | |
| 34 | 37 | |
| 35 | 38 | # asset pipeline |
| 36 | 39 | gem 'uglifier', '>= 1.0.3' | ... | ... |
app/models/add_friend.rb
| ... | ... | @@ -14,6 +14,9 @@ class AddFriend < Task |
| 14 | 14 | alias :friend :target |
| 15 | 15 | alias :friend= :target= |
| 16 | 16 | |
| 17 | + validates :requestor, :kind_of => { :kind => Person } | |
| 18 | + validates :target, :kind_of => { :kind => Person } | |
| 19 | + | |
| 17 | 20 | after_create do |task| |
| 18 | 21 | TaskMailer.invitation_notification(task).deliver unless task.friend |
| 19 | 22 | remove_from_suggestion_list(task) | ... | ... |
app/models/add_member.rb
app/models/approve_article.rb
| 1 | 1 | class ApproveArticle < Task |
| 2 | 2 | validates_presence_of :requestor_id, :target_id |
| 3 | 3 | |
| 4 | + validates :requestor, kind_of: {kind: Person} | |
| 5 | + validate :allowed_requestor | |
| 6 | + | |
| 7 | + def allowed_requestor | |
| 8 | + if target | |
| 9 | + if target.person? && requestor != target | |
| 10 | + self.errors.add(:requestor, _('You can not post articles to other users.')) | |
| 11 | + end | |
| 12 | + if target.organization? && !target.members.include?(requestor) && target.environment.portal_community != target | |
| 13 | + self.errors.add(:requestor, _('Only members can post articles on communities.')) | |
| 14 | + end | |
| 15 | + end | |
| 16 | + end | |
| 17 | + | |
| 4 | 18 | def article_title |
| 5 | 19 | article ? article.title : _('(The original text was removed)') |
| 6 | 20 | end |
| 7 | - | |
| 21 | + | |
| 8 | 22 | def article |
| 9 | 23 | Article.find_by_id data[:article_id] |
| 10 | 24 | end |
| ... | ... | @@ -124,4 +138,9 @@ class ApproveArticle < Task |
| 124 | 138 | message |
| 125 | 139 | end |
| 126 | 140 | |
| 141 | + def request_is_member_of_target | |
| 142 | + unless requestor.is_member_of?(target) | |
| 143 | + errors.add(:approve_article, N_('Requestor must be a member of target.')) | |
| 144 | + end | |
| 145 | + end | |
| 127 | 146 | end | ... | ... |
app/models/change_password.rb
app/models/create_community.rb
| ... | ... | @@ -3,6 +3,9 @@ class CreateCommunity < Task |
| 3 | 3 | validates_presence_of :requestor_id, :target_id |
| 4 | 4 | validates_presence_of :name |
| 5 | 5 | |
| 6 | + validates :requestor, kind_of: {kind: Person} | |
| 7 | + validates :target, kind_of: {kind: Environment} | |
| 8 | + | |
| 6 | 9 | alias :environment :target |
| 7 | 10 | alias :environment= :target= |
| 8 | 11 | ... | ... |
app/models/create_enterprise.rb
| ... | ... | @@ -27,6 +27,8 @@ class CreateEnterprise < Task |
| 27 | 27 | # checks for actual attributes |
| 28 | 28 | validates_presence_of :requestor_id, :target_id |
| 29 | 29 | |
| 30 | + validates :requestor, kind_of: {kind: Person} | |
| 31 | + | |
| 30 | 32 | # checks for admins required attributes |
| 31 | 33 | DATA_FIELDS.each do |attribute| |
| 32 | 34 | validates_presence_of attribute, :if => lambda { |obj| obj.environment.required_enterprise_fields.include?(attribute) } | ... | ... |
app/models/email_activation.rb
| 1 | 1 | class EmailActivation < Task |
| 2 | 2 | |
| 3 | 3 | validates_presence_of :requestor_id, :target_id |
| 4 | + | |
| 5 | + validates :requestor, kind_of: {kind: Person} | |
| 6 | + validates :target, kind_of: {kind: Environment} | |
| 7 | + | |
| 4 | 8 | validate :already_requested, :on => :create |
| 5 | 9 | |
| 6 | 10 | alias :environment :target |
| 7 | 11 | alias :person :requestor |
| 8 | 12 | |
| 9 | 13 | def already_requested |
| 10 | - if !self.requestor.nil? && self.requestor.user.email_activation_pending? | |
| 14 | + if !self.requestor.nil? && self.requestor.person? && self.requestor.user.email_activation_pending? | |
| 11 | 15 | self.errors.add(:base, _('You have already requested activation of your mailbox.')) |
| 12 | 16 | end |
| 13 | 17 | end | ... | ... |
app/models/enterprise_activation.rb
app/models/invitation.rb
| ... | ... | @@ -6,6 +6,8 @@ class Invitation < Task |
| 6 | 6 | |
| 7 | 7 | validates_presence_of :target_id, :if => Proc.new{|invite| invite.friend_email.blank?} |
| 8 | 8 | |
| 9 | + validates :requestor, kind_of: {kind: Person} | |
| 10 | + | |
| 9 | 11 | validates_presence_of :friend_email, :if => Proc.new{|invite| invite.target_id.blank?} |
| 10 | 12 | validates_format_of :friend_email, :with => Noosfero::Constants::EMAIL_FORMAT, :if => Proc.new{|invite| invite.target_id.blank?} |
| 11 | 13 | |
| ... | ... | @@ -34,7 +36,7 @@ class Invitation < Task |
| 34 | 36 | end |
| 35 | 37 | |
| 36 | 38 | def not_invite_yourself |
| 37 | - email = friend ? friend.user.email : friend_email | |
| 39 | + email = friend && friend.person? ? friend.user.email : friend_email | |
| 38 | 40 | if person && email && person.user.email == email |
| 39 | 41 | self.errors.add(:base, _("You can't invite youself")) |
| 40 | 42 | end |
| ... | ... | @@ -136,7 +138,11 @@ class Invitation < Task |
| 136 | 138 | end |
| 137 | 139 | |
| 138 | 140 | def environment |
| 139 | - self.requestor.environment | |
| 141 | + if self.requestor | |
| 142 | + self.requestor.environment | |
| 143 | + else | |
| 144 | + nil | |
| 145 | + end | |
| 140 | 146 | end |
| 141 | 147 | |
| 142 | 148 | end | ... | ... |
app/models/moderate_user_registration.rb
app/models/profile.rb
| ... | ... | @@ -204,9 +204,9 @@ class Profile < ActiveRecord::Base |
| 204 | 204 | Profile.column_names.map{|n| [Profile.table_name, n].join('.')}.join(',') |
| 205 | 205 | end |
| 206 | 206 | |
| 207 | - scope :visible, :conditions => { :visible => true } | |
| 207 | + scope :visible, :conditions => { :visible => true, :secret => false } | |
| 208 | 208 | scope :disabled, :conditions => { :visible => false } |
| 209 | - scope :public, :conditions => { :visible => true, :public_profile => true } | |
| 209 | + scope :public, :conditions => { :visible => true, :public_profile => true, :secret => false } | |
| 210 | 210 | scope :enabled, :conditions => { :enabled => true } |
| 211 | 211 | |
| 212 | 212 | # Subclasses must override this method | ... | ... |
app/models/suggest_article.rb
app/models/task.rb
| ... | ... | @@ -133,6 +133,51 @@ class Task < ActiveRecord::Base |
| 133 | 133 | end |
| 134 | 134 | end |
| 135 | 135 | |
| 136 | + class KindOfValidator < ActiveModel::EachValidator | |
| 137 | + def validate_each(record, attribute, value) | |
| 138 | + environment = record.environment || Environment.default | |
| 139 | + klass = options[:kind] | |
| 140 | + group = klass.to_s.downcase.pluralize | |
| 141 | + id = attribute.to_s + "_id" | |
| 142 | + if environment.respond_to?(group) | |
| 143 | + attrb = value || environment.send(group).find_by_id(record.send(id)) | |
| 144 | + else | |
| 145 | + attrb = value || klass.find_by_id(record.send(id)) | |
| 146 | + end | |
| 147 | + if attrb.respond_to?(klass.to_s.downcase + "?") | |
| 148 | + unless attrb.send(klass.to_s.downcase + "?") | |
| 149 | + record.errors[attribute] << (options[:message] || "should be "+ klass.to_s.downcase) | |
| 150 | + end | |
| 151 | + else | |
| 152 | + unless attrb.class == klass | |
| 153 | + record.errors[attribute] << (options[:message] || "should be "+ klass.to_s.downcase) | |
| 154 | + end | |
| 155 | + end | |
| 156 | + end | |
| 157 | + end | |
| 158 | + | |
| 159 | + def requestor_is_of_kind(klass, message = nil) | |
| 160 | + error_message = message ||= _('Task requestor must be '+klass.to_s.downcase) | |
| 161 | + group = klass.to_s.downcase.pluralize | |
| 162 | + if environment.respond_to?(group) and requestor_id | |
| 163 | + requestor = requestor ||= environment.send(klass.to_s.downcase.pluralize).find_by_id(requestor_id) | |
| 164 | + end | |
| 165 | + unless requestor.class == klass | |
| 166 | + errors.add(error_message) | |
| 167 | + end | |
| 168 | + end | |
| 169 | + | |
| 170 | + def target_is_of_kind(klass, message = nil) | |
| 171 | + error_message = message ||= _('Task target must be '+klass.to_s.downcase) | |
| 172 | + group = klass.to_s.downcase.pluralize | |
| 173 | + if environment.respond_to?(group) and target_id | |
| 174 | + target = target ||= environment.send(klass.to_s.downcase.pluralize).find_by_id(target_id) | |
| 175 | + end | |
| 176 | + unless target.class == klass | |
| 177 | + errors.add(error_message) | |
| 178 | + end | |
| 179 | + end | |
| 180 | + | |
| 136 | 181 | def close(status, closed_by) |
| 137 | 182 | self.status = status |
| 138 | 183 | self.end_date = Time.now | ... | ... |
app/views/api/playground.html.erb
| ... | ... | @@ -12,7 +12,11 @@ endpoints.map do |endpoint| |
| 12 | 12 | } |
| 13 | 13 | end |
| 14 | 14 | end |
| 15 | -end.flatten.compact.sort{|a,b| a[:path]=='/api/v1/login' ? -1:1}.to_json %>; | |
| 15 | +end.flatten.compact.sort{|a,b| | |
| 16 | + a[:path]=='/api/v1/login' ? -1 : | |
| 17 | + b[:path]=='/api/v1/login' ? 1 : | |
| 18 | + a[:path] <=> b[:path] | |
| 19 | +}.to_json %>; | |
| 16 | 20 | </script> |
| 17 | 21 | |
| 18 | 22 | <form id="api-form"> | ... | ... |
config.ru
| ... | ... | @@ -6,6 +6,13 @@ require ::File.expand_path('../config/environment', __FILE__) |
| 6 | 6 | #use Rails::Rack::Static |
| 7 | 7 | #run ActionController::Dispatcher.new |
| 8 | 8 | |
| 9 | +use Rack::Cors do | |
| 10 | + allow do | |
| 11 | + origins '*' | |
| 12 | + resource '/api/*', :headers => :any, :methods => [:get, :post] | |
| 13 | + end | |
| 14 | +end | |
| 15 | + | |
| 9 | 16 | rails_app = Rack::Builder.new do |
| 10 | 17 | run Noosfero::Application |
| 11 | 18 | end | ... | ... |
config/application.rb
| ... | ... | @@ -135,12 +135,5 @@ module Noosfero |
| 135 | 135 | |
| 136 | 136 | Noosfero::Plugin.setup(config) |
| 137 | 137 | |
| 138 | - config.middleware.use Rack::Cors do | |
| 139 | - allow do | |
| 140 | - origins '*' | |
| 141 | - resource '/api/*', :headers => :any, :methods => [:get, :post] | |
| 142 | - end | |
| 143 | - end | |
| 144 | - | |
| 145 | 138 | end |
| 146 | 139 | end | ... | ... |
| ... | ... | @@ -0,0 +1 @@ |
| 1 | +Rails.application.eager_load! | ... | ... |
debian/changelog
| 1 | -noosfero (1.2~1) UNRELEASED; urgency=medium | |
| 2 | - | |
| 3 | - [ Antonio Terceiro ] | |
| 4 | - * Temporary version in heavy development | |
| 1 | +noosfero (1.2~rc1) wheezy; urgency=medium | |
| 5 | 2 | |
| 6 | 3 | [ Joenio Costa ] |
| 7 | 4 | * Build noosfero-chat package |
| 8 | 5 | |
| 9 | - [ root ] | |
| 10 | - * Api test | |
| 6 | + [ Antonio Terceiro ] | |
| 7 | + * Noosfero 1.2 RC1 | |
| 11 | 8 | |
| 12 | - -- root <root@17edebf1ae91> Mon, 06 Jul 2015 14:39:06 +0000 | |
| 9 | + -- Antonio Terceiro <terceiro@colivre.coop.br> Mon, 13 Jul 2015 15:44:17 -0300 | |
| 13 | 10 | |
| 14 | 11 | noosfero (1.1) wheezy; urgency=low |
| 15 | 12 | ... | ... |
lib/noosfero/api/helpers.rb
| ... | ... | @@ -52,7 +52,8 @@ |
| 52 | 52 | end |
| 53 | 53 | end |
| 54 | 54 | |
| 55 | - ARTICLE_TYPES = Article.descendants.map{|a| a.to_s} | |
| 55 | + ARTICLE_TYPES = ['Article'] + Article.descendants.map{|a| a.to_s} | |
| 56 | + TASK_TYPES = ['Task'] + Task.descendants.map{|a| a.to_s} | |
| 56 | 57 | |
| 57 | 58 | def find_article(articles, id) |
| 58 | 59 | article = articles.find(id) |
| ... | ... | @@ -97,11 +98,39 @@ |
| 97 | 98 | if params[:categories_ids] |
| 98 | 99 | articles = articles.joins(:categories).where('category_id in (?)', params[:categories_ids]) |
| 99 | 100 | end |
| 101 | + articles | |
| 100 | 102 | end |
| 101 | 103 | |
| 102 | - def find_task(tasks, id) | |
| 103 | - task = tasks.find(id) | |
| 104 | - task.display_to?(current_user.person) ? task : forbidden! | |
| 104 | + def find_task(asset, id) | |
| 105 | + task = asset.tasks.find(id) | |
| 106 | + current_person.has_permission?(task.permission, asset) ? task : forbidden! | |
| 107 | + end | |
| 108 | + | |
| 109 | + def post_task(asset, params) | |
| 110 | + klass_type= params[:content_type].nil? ? 'Task' : params[:content_type] | |
| 111 | + return forbidden! unless TASK_TYPES.include?(klass_type) | |
| 112 | + | |
| 113 | + task = klass_type.constantize.new(params[:task]) | |
| 114 | + task.requestor_id = current_person.id | |
| 115 | + task.target_id = asset.id | |
| 116 | + task.target_type = 'Profile' | |
| 117 | + | |
| 118 | + if !task.save | |
| 119 | + render_api_errors!(task.errors.full_messages) | |
| 120 | + end | |
| 121 | + present task, :with => Entities::Task, :fields => params[:fields] | |
| 122 | + end | |
| 123 | + | |
| 124 | + def present_task(asset) | |
| 125 | + task = find_task(asset, params[:id]) | |
| 126 | + present task, :with => Entities::Task, :fields => params[:fields] | |
| 127 | + end | |
| 128 | + | |
| 129 | + def present_tasks(asset) | |
| 130 | + tasks = select_filtered_collection_of(asset, 'tasks', params) | |
| 131 | + tasks = tasks.select {|t| current_person.has_permission?(t.permission, asset)} | |
| 132 | + return forbidden! if tasks.empty? && !current_person.has_permission?(:perform_task, asset) | |
| 133 | + present tasks, :with => Entities::Task, :fields => params[:fields] | |
| 105 | 134 | end |
| 106 | 135 | |
| 107 | 136 | def make_conditions_with_parameter(params = {}) |
| ... | ... | @@ -318,7 +347,13 @@ |
| 318 | 347 | https.use_ssl = true |
| 319 | 348 | request = Net::HTTP::Post.new(uri.path) |
| 320 | 349 | request.set_form_data(verify_hash) |
| 321 | - body = https.request(request).body | |
| 350 | + begin | |
| 351 | + body = https.request(request).body | |
| 352 | + rescue Exception => e | |
| 353 | + logger.error e | |
| 354 | + return _("Google recaptcha error: #{e.message}") | |
| 355 | + end | |
| 356 | + body = JSON.parse(body) | |
| 322 | 357 | body == "true\nsuccess" ? true : body |
| 323 | 358 | end |
| 324 | 359 | |
| ... | ... | @@ -337,20 +372,36 @@ |
| 337 | 372 | https.use_ssl = true |
| 338 | 373 | request = Net::HTTP::Post.new(uri.path) |
| 339 | 374 | request.set_form_data(verify_hash) |
| 340 | - captcha_result = JSON.parse(https.request(request).body) | |
| 375 | + begin | |
| 376 | + body = https.request(request).body | |
| 377 | + rescue Exception => e | |
| 378 | + logger.error e | |
| 379 | + return _("Google recaptcha error: #{e.message}") | |
| 380 | + end | |
| 381 | + captcha_result = JSON.parse(body) | |
| 341 | 382 | captcha_result["success"] ? true : captcha_result |
| 342 | 383 | end |
| 343 | 384 | |
| 344 | 385 | def verify_serpro_captcha(client_id, token, captcha_text, verify_uri) |
| 345 | - if token == nil || captcha_text == nil | |
| 346 | - return _('Missing captcha data') | |
| 347 | - end | |
| 386 | + return _('Missing Serpro Captcha token') if token == nil | |
| 387 | + return _('Captcha text has not been filled') if captcha_text == nil | |
| 348 | 388 | uri = URI(verify_uri) |
| 349 | 389 | http = Net::HTTP.new(uri.host, uri.port) |
| 350 | 390 | request = Net::HTTP::Post.new(uri.path) |
| 351 | 391 | verify_string = "#{client_id}&#{token}&#{captcha_text}" |
| 352 | 392 | request.body = verify_string |
| 393 | +<<<<<<< HEAD | |
| 353 | 394 | body = http.request(request).body |
| 395 | +======= | |
| 396 | + begin | |
| 397 | + body = http.request(request).body | |
| 398 | + rescue Exception => e | |
| 399 | + logger.error e | |
| 400 | + return _("Serpro captcha error: #{e.message}") | |
| 401 | + end | |
| 402 | + return _("Wrong captcha text, please try again") if body == 0 | |
| 403 | + return _("Token not found") if body == 2 | |
| 404 | +>>>>>>> serpro_api | |
| 354 | 405 | body == '1' ? true : body |
| 355 | 406 | end |
| 356 | 407 | ... | ... |
lib/noosfero/api/v1/tasks.rb
| ... | ... | @@ -18,146 +18,41 @@ module Noosfero |
| 18 | 18 | # Example Request: |
| 19 | 19 | # GET host/api/v1/tasks?from=2013-04-04-14:41:43&until=2015-04-04-14:41:43&limit=10&private_token=e96fff37c2238fdab074d1dcea8e6317 |
| 20 | 20 | get do |
| 21 | - #FIXME check for permission | |
| 22 | 21 | tasks = select_filtered_collection_of(environment, 'tasks', params) |
| 22 | + tasks = tasks.select {|t| current_person.has_permission?(t.permission, environment)} | |
| 23 | 23 | present tasks, :with => Entities::Task, :fields => params[:fields] |
| 24 | 24 | end |
| 25 | 25 | |
| 26 | 26 | desc "Return the task id" |
| 27 | 27 | get ':id' do |
| 28 | - task = find_task(environment.tasks, params[:id]) | |
| 28 | + task = find_task(environment, params[:id]) | |
| 29 | 29 | present task, :with => Entities::Task, :fields => params[:fields] |
| 30 | 30 | end |
| 31 | - | |
| 32 | - | |
| 33 | 31 | end |
| 34 | 32 | |
| 35 | - resource :communities do | |
| 36 | - segment '/:community_id' do | |
| 37 | - resource :tasks do | |
| 38 | - get do | |
| 39 | - #FIXME check for permission | |
| 40 | - community = environment.communities.find(params[:community_id]) | |
| 41 | - tasks = select_filtered_collection_of(community, 'tasks', params) | |
| 42 | - present tasks, :with => Entities::Task, :fields => params[:fields] | |
| 43 | - end | |
| 44 | - | |
| 45 | - get ':id' do | |
| 46 | - community = environment.communities.find(params[:community_id]) | |
| 47 | - task = find_task(community.tasks, params[:id]) | |
| 48 | - present task, :with => Entities::Task, :fields => params[:fields] | |
| 49 | - end | |
| 50 | - | |
| 51 | - # Example Request: | |
| 52 | - # POST api/v1/communites/:community_id/articles?private_token=234298743290432&article[name]=title&article[body]=body | |
| 53 | - post do | |
| 54 | - community = environment.communities.find(params[:community_id]) | |
| 55 | -#FIXME see the correct permission | |
| 56 | - return forbidden! unless current_person.can_post_content?(community) | |
| 57 | -#FIXME check the task type before create | |
| 58 | - klass_type= params[:content_type].nil? ? 'Task' : params[:content_type] | |
| 59 | -# return forbidden! unless ARTICLE_TYPES.include?(klass_type) | |
| 60 | -# | |
| 61 | - task = klass_type.constantize.new(params[:task]) | |
| 62 | - task.requestor = current_person | |
| 63 | - task.target = community | |
| 64 | - | |
| 65 | - if !task.save | |
| 66 | - render_api_errors!(task.errors.full_messages) | |
| 33 | + kinds = %w[community person enterprise] | |
| 34 | + kinds.each do |kind| | |
| 35 | + resource kind.pluralize.to_sym do | |
| 36 | + segment "/:#{kind}_id" do | |
| 37 | + resource :tasks do | |
| 38 | + get do | |
| 39 | + profile = environment.send(kind.pluralize).find(params["#{kind}_id"]) | |
| 40 | + present_tasks(profile) | |
| 67 | 41 | end |
| 68 | - present task, :with => Entities::Task, :fields => params[:fields] | |
| 69 | - end | |
| 70 | - | |
| 71 | - end | |
| 72 | - end | |
| 73 | - | |
| 74 | - end | |
| 75 | - | |
| 76 | - resource :people do | |
| 77 | - segment '/:person_id' do | |
| 78 | - resource :tasks do | |
| 79 | - get do | |
| 80 | -# person = environment.people.find(params[:person_id]) | |
| 81 | -# articles = select_filtered_collection_of(person, 'articles', params) | |
| 82 | -# articles = articles.display_filter(current_person, person) | |
| 83 | -tasks = Task.all | |
| 84 | - present tasks, :with => Entities::Task, :fields => params[:fields] | |
| 85 | - end | |
| 86 | - | |
| 87 | - get ':id' do | |
| 88 | -# person = environment.people.find(params[:person_id]) | |
| 89 | -# article = find_article(person.articles, params[:id]) | |
| 90 | -task = Task.first | |
| 91 | - present task, :with => Entities::Task, :fields => params[:fields] | |
| 92 | - end | |
| 93 | 42 | |
| 94 | - post do | |
| 95 | -# person = environment.people.find(params[:person_id]) | |
| 96 | -# return forbidden! unless current_person.can_post_content?(person) | |
| 97 | -# | |
| 98 | -# klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] | |
| 99 | -# return forbidden! unless ARTICLE_TYPES.include?(klass_type) | |
| 100 | -# | |
| 101 | -# article = klass_type.constantize.new(params[:article]) | |
| 102 | -# article.last_changed_by = current_person | |
| 103 | -# article.created_by= current_person | |
| 104 | -# article.profile = person | |
| 105 | -# | |
| 106 | -# if !article.save | |
| 107 | -# render_api_errors!(article.errors.full_messages) | |
| 108 | -# end | |
| 109 | -task = Task.first | |
| 110 | - present task, :with => Entities::Task, :fields => params[:fields] | |
| 111 | - end | |
| 112 | - | |
| 113 | - end | |
| 114 | - end | |
| 115 | - | |
| 116 | - end | |
| 117 | - | |
| 118 | - resource :enterprises do | |
| 119 | - segment '/:enterprise_id' do | |
| 120 | - resource :tasks do | |
| 121 | - get do | |
| 122 | -# enterprise = environment.enterprises.find(params[:enterprise_id]) | |
| 123 | -# articles = select_filtered_collection_of(enterprise, 'articles', params) | |
| 124 | -# articles = articles.display_filter(current_person, enterprise) | |
| 125 | -tasks = Task.all | |
| 126 | - present tasks, :with => Entities::Task, :fields => params[:fields] | |
| 127 | - end | |
| 128 | - | |
| 129 | - get ':id' do | |
| 130 | -# enterprise = environment.enterprises.find(params[:enterprise_id]) | |
| 131 | -# article = find_article(enterprise.articles, params[:id]) | |
| 132 | -task = Task.first | |
| 133 | - present task, :with => Entities::Task, :fields => params[:fields] | |
| 134 | - end | |
| 43 | + get ':id' do | |
| 44 | + profile = environment.send(kind.pluralize).find(params["#{kind}_id"]) | |
| 45 | + present_task(profile) | |
| 46 | + end | |
| 135 | 47 | |
| 136 | - post do | |
| 137 | -# enterprise = environment.enterprises.find(params[:enterprise_id]) | |
| 138 | -# return forbidden! unless current_person.can_post_content?(enterprise) | |
| 139 | -# | |
| 140 | -# klass_type= params[:content_type].nil? ? 'TinyMceArticle' : params[:content_type] | |
| 141 | -# return forbidden! unless ARTICLE_TYPES.include?(klass_type) | |
| 142 | -# | |
| 143 | -# article = klass_type.constantize.new(params[:article]) | |
| 144 | -# article.last_changed_by = current_person | |
| 145 | -# article.created_by= current_person | |
| 146 | -# article.profile = enterprise | |
| 147 | -# | |
| 148 | -# if !article.save | |
| 149 | -# render_api_errors!(article.errors.full_messages) | |
| 150 | -# end | |
| 151 | -task = Task.first | |
| 152 | - present task, :with => Entities::Task, :fields => params[:fields] | |
| 48 | + post do | |
| 49 | + profile = environment.send(kind.pluralize).find(params["#{kind}_id"]) | |
| 50 | + post_task(profile, params) | |
| 51 | + end | |
| 153 | 52 | end |
| 154 | - | |
| 155 | 53 | end |
| 156 | 54 | end |
| 157 | - | |
| 158 | 55 | end |
| 159 | - | |
| 160 | - | |
| 161 | 56 | end |
| 162 | 57 | end |
| 163 | 58 | end | ... | ... |
lib/noosfero/version.rb
plugins/gamification
plugins/proposals_discussion
po/fr/noosfero.po
| ... | ... | @@ -6,11 +6,11 @@ msgid "" |
| 6 | 6 | msgstr "" |
| 7 | 7 | "Project-Id-Version: 1.1-2519-g5b6a4ea\n" |
| 8 | 8 | "Report-Msgid-Bugs-To: \n" |
| 9 | -"POT-Creation-Date: 2015-07-07 15:26-0300\n" | |
| 10 | -"PO-Revision-Date: 2015-03-12 16:11+0200\n" | |
| 11 | -"Last-Translator: Tuux <tuxa@galaxie.eu.org>\n" | |
| 12 | -"Language-Team: French <https://hosted.weblate.org/projects/noosfero/noosfero/" | |
| 13 | -"fr/>\n" | |
| 9 | +"POT-Creation-Date: 2015-06-01 17:26-0300\n" | |
| 10 | +"PO-Revision-Date: 2015-07-13 10:39+0200\n" | |
| 11 | +"Last-Translator: Christophe DANIEL <papaeng@gmail.com>\n" | |
| 12 | +"Language-Team: French " | |
| 13 | +"<https://hosted.weblate.org/projects/noosfero/noosfero/fr/>\n" | |
| 14 | 14 | "Language: fr\n" |
| 15 | 15 | "MIME-Version: 1.0\n" |
| 16 | 16 | "Content-Type: text/plain; charset=UTF-8\n" |
| ... | ... | @@ -7744,31 +7744,22 @@ msgstr "Type" |
| 7744 | 7744 | msgid "Last update" |
| 7745 | 7745 | msgstr "Dernière mise à jour" |
| 7746 | 7746 | |
| 7747 | -#: app/views/cms/view.html.erb:48 app/views/cms/view.html.erb:50 | |
| 7748 | -#, fuzzy | |
| 7749 | -msgid "parent folder" | |
| 7750 | -msgstr "Catégorie courante :" | |
| 7747 | +#: app/views/profile_roles/destroy.html.erb:13 | |
| 7748 | +msgid "To which role do you want to change them?" | |
| 7749 | +msgstr "Pour quel rôle voulez-vous les changer ?" | |
| 7751 | 7750 | |
| 7752 | -#: app/views/cms/_media_new_folder.html.erb:1 | |
| 7753 | -#, fuzzy | |
| 7754 | -msgid "Create new folder" | |
| 7755 | -msgstr "Créer un nouveau groupe" | |
| 7751 | +#: app/views/profile_roles/destroy.html.erb:20 | |
| 7752 | +msgid "Delete role" | |
| 7753 | +msgstr "Supprimer le rôle" | |
| 7756 | 7754 | |
| 7757 | 7755 | #: app/views/cms/_media_new_folder.html.erb:3 |
| 7758 | 7756 | #, fuzzy |
| 7759 | 7757 | msgid "Choose parent folder:" |
| 7760 | 7758 | msgstr "Catégorie courante :" |
| 7761 | 7759 | |
| 7762 | -#: app/views/cms/_media_new_folder.html.erb:13 | |
| 7763 | -#: app/views/memberships/new_community.html.erb:52 | |
| 7764 | -#: app/views/profile_themes/new.html.erb:8 | |
| 7765 | -msgid "Create" | |
| 7766 | -msgstr "Créer" | |
| 7767 | - | |
| 7768 | -#: app/views/cms/_link_article.html.erb:3 | |
| 7769 | -#, fuzzy | |
| 7770 | -msgid "Reference" | |
| 7771 | -msgstr "Adresse :" | |
| 7760 | +#: app/views/profile_roles/index.html.erb:5 app/views/role/index.html.erb:5 | |
| 7761 | +msgid "Role" | |
| 7762 | +msgstr "Rôle" | |
| 7772 | 7763 | |
| 7773 | 7764 | #: app/views/cms/upload_files.html.erb:3 |
| 7774 | 7765 | msgid "This file couldn't be saved" |
| ... | ... | @@ -7806,9 +7797,9 @@ msgstr "Catégorie courante :" |
| 7806 | 7797 | msgid "License" |
| 7807 | 7798 | msgstr "" |
| 7808 | 7799 | |
| 7809 | -#: app/views/cms/_blog.html.erb:3 | |
| 7810 | -msgid "My Blog" | |
| 7811 | -msgstr "Mon blog" | |
| 7800 | +#: app/views/comment_notifier/mail_to_followers.html.erb:1 | |
| 7801 | +msgid "Hi!" | |
| 7802 | +msgstr "Bonjour !" | |
| 7812 | 7803 | |
| 7813 | 7804 | #: app/views/cms/_blog.html.erb:42 |
| 7814 | 7805 | #: app/views/profile_editor/_organization.html.erb:48 |
| ... | ... | @@ -7825,10 +7816,10 @@ msgstr "" |
| 7825 | 7816 | "les liens extérieurs menant à la page d'accueil ou le contenu du site lui-" |
| 7826 | 7817 | "même. Voulez-vous vraiment la modifier ?" |
| 7827 | 7818 | |
| 7828 | -#: app/views/cms/_blog.html.erb:59 | |
| 7829 | -#, fuzzy | |
| 7830 | -msgid "Cover image:" | |
| 7831 | -msgstr "image" | |
| 7819 | +#: app/views/comment_notifier/mail_to_followers.html.erb:5 | |
| 7820 | +#: app/views/comment_notifier/notification.text.erb:5 | |
| 7821 | +msgid "Title: %s" | |
| 7822 | +msgstr "Titre : %s" | |
| 7832 | 7823 | |
| 7833 | 7824 | #: app/views/cms/_blog.html.erb:64 |
| 7834 | 7825 | #, fuzzy |
| ... | ... | @@ -7918,18 +7909,17 @@ msgstr "Plus de documents" |
| 7918 | 7909 | msgid "Upload" |
| 7919 | 7910 | msgstr "Téléverser" |
| 7920 | 7911 | |
| 7921 | -#: app/views/cms/_text_fields.html.erb:1 | |
| 7922 | -#, fuzzy | |
| 7923 | -msgid "Publish date" | |
| 7924 | -msgstr "Publier le média" | |
| 7912 | +#: app/views/templates/index.html.erb:31 | |
| 7913 | +msgid "Edit settings" | |
| 7914 | +msgstr "Modifier les paramètres" | |
| 7925 | 7915 | |
| 7926 | 7916 | #: app/views/cms/_enterprise_homepage.html.erb:3 |
| 7927 | 7917 | msgid "Text" |
| 7928 | 7918 | msgstr "Texte" |
| 7929 | 7919 | |
| 7930 | -#: app/views/cms/why_categorize.html.erb:1 app/views/cms/edit.html.erb:31 | |
| 7931 | -msgid "Why categorize?" | |
| 7932 | -msgstr "Pourquoi catégoriser ?" | |
| 7920 | +#: app/views/templates/index.html.erb:35 | |
| 7921 | +msgid "Edit header/footer" | |
| 7922 | +msgstr "Modifier en-tête/pied de page" | |
| 7933 | 7923 | |
| 7934 | 7924 | #: app/views/cms/why_categorize.html.erb:4 |
| 7935 | 7925 | msgid "" |
| ... | ... | @@ -7948,10 +7938,13 @@ msgstr "" |
| 7948 | 7938 | msgid "Start date and time" |
| 7949 | 7939 | msgstr "Date de début" |
| 7950 | 7940 | |
| 7951 | -#: app/views/cms/_event.html.erb:13 | |
| 7952 | -#, fuzzy | |
| 7953 | -msgid "End date and time" | |
| 7954 | -msgstr "Date de fin" | |
| 7941 | +#: app/views/home/terms.html.erb:1 | |
| 7942 | +msgid "Terms of use - %s" | |
| 7943 | +msgstr "Conditions d'utilisation - %s" | |
| 7944 | + | |
| 7945 | +#: app/views/home/welcome.html.erb:4 | |
| 7946 | +msgid "Welcome to %s!" | |
| 7947 | +msgstr "Bienvenue sur %s !" | |
| 7955 | 7948 | |
| 7956 | 7949 | #: app/views/cms/_event.html.erb:15 |
| 7957 | 7950 | msgid "Presenter:" |
| ... | ... | @@ -7961,10 +7954,9 @@ msgstr "" |
| 7961 | 7954 | msgid "Event website:" |
| 7962 | 7955 | msgstr "Site web de l'événement :" |
| 7963 | 7956 | |
| 7964 | -#: app/views/cms/select_article_type.html.erb:3 | |
| 7965 | -#, fuzzy | |
| 7966 | -msgid "Choose the type of content:" | |
| 7967 | -msgstr "Choisissez le type de l'article :" | |
| 7957 | +#: app/views/home/welcome.html.erb:11 | |
| 7958 | +msgid "Confirm your account!" | |
| 7959 | +msgstr "Confirmer votre compte !" | |
| 7968 | 7960 | |
| 7969 | 7961 | #: app/views/cms/_drag_and_drop_note.html.erb:3 |
| 7970 | 7962 | msgid "Drag images to add them to the text." |
| ... | ... | @@ -8038,10 +8030,9 @@ msgid "" |
| 8038 | 8030 | "just search for the community below." |
| 8039 | 8031 | msgstr "" |
| 8040 | 8032 | |
| 8041 | -#: app/views/cms/publish.html.erb:42 | |
| 8042 | -#, fuzzy | |
| 8043 | -msgid "Type in a search for your community" | |
| 8044 | -msgstr "Désactiver la recherche d'entreprises" | |
| 8033 | +#: app/views/home/welcome.html.erb:25 | |
| 8034 | +msgid "Invite and find" | |
| 8035 | +msgstr "Inviter et trouver" | |
| 8045 | 8036 | |
| 8046 | 8037 | #: app/views/cms/publish.html.erb:55 |
| 8047 | 8038 | msgid "" |
| ... | ... | @@ -8053,15 +8044,15 @@ msgstr "" |
| 8053 | 8044 | msgid "Textile markup quick reference" |
| 8054 | 8045 | msgstr "" |
| 8055 | 8046 | |
| 8056 | -#: app/views/cms/_textile_quick_reference.html.erb:4 | |
| 8057 | -#, fuzzy | |
| 8058 | -msgid "(show)" | |
| 8059 | -msgstr "Voir le diaporama" | |
| 8047 | +#: app/views/home/index.html.erb:2 | |
| 8048 | +msgid "News" | |
| 8049 | +msgstr "Nouveautés" | |
| 8060 | 8050 | |
| 8061 | -#: app/views/cms/_textile_quick_reference.html.erb:5 | |
| 8062 | -#, fuzzy | |
| 8063 | -msgid "(hide)" | |
| 8064 | -msgstr "Cacher" | |
| 8051 | +#: app/views/home/index.html.erb:45 | |
| 8052 | +#: app/views/profile/_profile_activities_list.html.erb:14 | |
| 8053 | +#: app/views/profile/_profile_network_activities.html.erb:6 | |
| 8054 | +msgid "View more" | |
| 8055 | +msgstr "Voir plus" | |
| 8065 | 8056 | |
| 8066 | 8057 | #: app/views/cms/_textile_quick_reference.html.erb:8 |
| 8067 | 8058 | #, fuzzy |
| ... | ... | @@ -8072,15 +8063,15 @@ msgstr "Informations fournies" |
| 8072 | 8063 | msgid "italics" |
| 8073 | 8064 | msgstr "" |
| 8074 | 8065 | |
| 8075 | -#: app/views/cms/_textile_quick_reference.html.erb:8 | |
| 8076 | -#, fuzzy | |
| 8077 | -msgid "bold" | |
| 8078 | -msgstr "travail" | |
| 8066 | +#: app/views/features/_manage_enterprise_fields.html.erb:8 | |
| 8067 | +msgid "Display on registration?" | |
| 8068 | +msgstr "Afficher à l'inscription ?" | |
| 8079 | 8069 | |
| 8080 | -#: app/views/cms/_textile_quick_reference.html.erb:8 | |
| 8081 | -#, fuzzy | |
| 8082 | -msgid "striked" | |
| 8083 | -msgstr "Contact" | |
| 8070 | +#: app/views/features/_manage_enterprise_fields.html.erb:13 | |
| 8071 | +#: app/views/features/_manage_community_fields.html.erb:13 | |
| 8072 | +#: app/views/features/_manage_person_fields.html.erb:13 | |
| 8073 | +msgid "Check/Uncheck All" | |
| 8074 | +msgstr "Tout cocher/décocher" | |
| 8084 | 8075 | |
| 8085 | 8076 | #: app/views/cms/_textile_quick_reference.html.erb:9 |
| 8086 | 8077 | #, fuzzy |
| ... | ... | @@ -8125,20 +8116,17 @@ msgstr "" |
| 8125 | 8116 | msgid "Insert media" |
| 8126 | 8117 | msgstr "" |
| 8127 | 8118 | |
| 8128 | -#: app/views/cms/_text_editor_sidebar.html.erb:8 | |
| 8129 | -#, fuzzy | |
| 8130 | -msgid "Show/Hide" | |
| 8131 | -msgstr "Voir le diaporama" | |
| 8119 | +#: app/views/features/index.html.erb:15 | |
| 8120 | +msgid "Feature" | |
| 8121 | +msgstr "Fonctionnalité" | |
| 8132 | 8122 | |
| 8133 | -#: app/views/cms/_text_editor_sidebar.html.erb:21 | |
| 8134 | -#, fuzzy | |
| 8135 | -msgid "New folder" | |
| 8136 | -msgstr "Catégorie courante :" | |
| 8123 | +#: app/views/features/index.html.erb:16 | |
| 8124 | +msgid "Enabled?" | |
| 8125 | +msgstr "Activé ?" | |
| 8137 | 8126 | |
| 8138 | -#: app/views/cms/_text_editor_sidebar.html.erb:26 | |
| 8139 | -#, fuzzy | |
| 8140 | -msgid "Hide all uploads" | |
| 8141 | -msgstr "Voir tous les produits" | |
| 8127 | +#: app/views/features/index.html.erb:27 | |
| 8128 | +msgid "Configure features" | |
| 8129 | +msgstr "Editer les fonctionnalités" | |
| 8142 | 8130 | |
| 8143 | 8131 | #: app/views/cms/_text_editor_sidebar.html.erb:27 |
| 8144 | 8132 | #, fuzzy |
| ... | ... | @@ -8167,14 +8155,9 @@ msgstr "Ma page d'accueil" |
| 8167 | 8155 | msgid "My groups" |
| 8168 | 8156 | msgstr "Mes groupes" |
| 8169 | 8157 | |
| 8170 | -#: app/views/shared/user_menu.html.erb:32 | |
| 8171 | -msgid "Webmail" | |
| 8172 | -msgstr "Webmail" | |
| 8173 | - | |
| 8174 | -#: app/views/shared/_profile_suggestions_list.html.erb:6 | |
| 8175 | -#, fuzzy | |
| 8176 | -msgid "You have no more suggestions :(" | |
| 8177 | -msgstr "Vous avez des requêtes en attente" | |
| 8158 | +#: app/views/chat/start_session_error.html.erb:3 | |
| 8159 | +msgid "Could not connect to chat" | |
| 8160 | +msgstr "Impossible de se connecter au chat" | |
| 8178 | 8161 | |
| 8179 | 8162 | #: app/views/shared/_profile_suggestions_list.html.erb:19 |
| 8180 | 8163 | #: app/views/shared/_profile_suggestions_list.html.erb:26 |
| ... | ... | @@ -8205,46 +8188,65 @@ msgstr "Contenu principal" |
| 8205 | 8188 | msgid "This link might be unavailable if the content is removed" |
| 8206 | 8189 | msgstr "" |
| 8207 | 8190 | |
| 8208 | -#: app/views/shared/reported_versions/profile/_folder.html.erb:1 | |
| 8209 | -#, fuzzy | |
| 8210 | -msgid "Reported folder" | |
| 8211 | -msgstr "Catégorie courante :" | |
| 8191 | +#: app/views/themes/_select_theme.html.erb:5 | |
| 8192 | +msgid "Use the default theme" | |
| 8193 | +msgstr "Utiliser le thème par défaut" | |
| 8212 | 8194 | |
| 8213 | -#: app/views/shared/reported_versions/profile/_comment.html.erb:3 | |
| 8214 | -#, fuzzy | |
| 8215 | -msgid "Comment" | |
| 8216 | -msgstr "Commentaires" | |
| 8195 | +#: app/views/themes/_select_theme.html.erb:5 | |
| 8196 | +msgid "Are you sure you want to use the environment default theme?" | |
| 8197 | +msgstr "Etes-vous sûr que vous voulez utiliser le thème par défaut ?" | |
| 8217 | 8198 | |
| 8218 | -#: app/views/shared/_organization_custom_fields.html.erb:12 | |
| 8219 | -#: app/views/maps/edit_location.html.erb:13 | |
| 8220 | -#: app/views/profile_editor/_person_form.html.erb:25 | |
| 8221 | -msgid "Address (street and number)" | |
| 8222 | -msgstr "Adresse (n° et rue)" | |
| 8199 | +#: app/views/file_presenter/_image.html.erb:7 | |
| 8200 | +#: app/views/file_presenter/_image.html.erb:9 | |
| 8201 | +msgid "« Previous" | |
| 8202 | +msgstr "« Précédent" | |
| 8223 | 8203 | |
| 8224 | -#: app/views/shared/_profile_connections.html.erb:2 | |
| 8225 | -#, fuzzy | |
| 8226 | -msgid "Profiles in common:" | |
| 8227 | -msgstr "Informations fournies" | |
| 8204 | +#: app/views/file_presenter/_image.html.erb:13 | |
| 8205 | +#: app/views/file_presenter/_image.html.erb:15 | |
| 8206 | +msgid "Next »" | |
| 8207 | +msgstr "Suivant »" | |
| 8228 | 8208 | |
| 8229 | 8209 | #: app/views/shared/_profile_connections.html.erb:17 |
| 8230 | 8210 | msgid "Tags in common:" |
| 8231 | 8211 | msgstr "" |
| 8232 | 8212 | |
| 8233 | -#: app/views/shared/logged_in/xmpp_chat.html.erb:10 | |
| 8234 | -msgid "" | |
| 8235 | -"The user is not online now. He/She will receive these messages as soon as he/" | |
| 8236 | -"she gets online." | |
| 8213 | +#: app/views/profile_members/unassociate.html.erb:2 | |
| 8214 | +#: app/views/profile_members/remove_admin.html.erb:2 | |
| 8215 | +#: app/views/profile_members/_members_list.html.erb:2 | |
| 8216 | +#: app/views/profile_members/add_member.html.erb:2 | |
| 8217 | +#: app/views/profile_members/add_admin.html.erb:2 | |
| 8218 | +msgid "Current members" | |
| 8219 | +msgstr "Les membres actuels" | |
| 8220 | + | |
| 8221 | +#: app/views/profile_members/_manage_roles.html.erb:21 | |
| 8222 | +msgid "Type in a search term for users" | |
| 8237 | 8223 | msgstr "" |
| 8238 | 8224 | |
| 8239 | -#: app/views/shared/logged_in/xmpp_chat.html.erb:25 | |
| 8240 | -#, fuzzy | |
| 8241 | -msgid "Offline" | |
| 8242 | -msgstr "Uniquement dans %s" | |
| 8225 | +#: app/views/profile_members/_add_admins.html.erb:1 | |
| 8226 | +msgid "Add admins to %s" | |
| 8227 | +msgstr "Ajouter un admin à %s" | |
| 8243 | 8228 | |
| 8244 | -#: app/views/shared/logged_in/xmpp_chat.html.erb:60 | |
| 8245 | -#, fuzzy | |
| 8246 | -msgid "Join room" | |
| 8247 | -msgstr "Se joindre" | |
| 8229 | +#: app/views/profile_members/affiliate.html.erb:7 | |
| 8230 | +#: app/views/environment_role_manager/affiliate.html.erb:7 | |
| 8231 | +msgid "Affiliate" | |
| 8232 | +msgstr "Affilié" | |
| 8233 | + | |
| 8234 | +#: app/views/profile_members/_index_buttons.html.erb:3 | |
| 8235 | +msgid "Add members" | |
| 8236 | +msgstr "Ajouter des membres" | |
| 8237 | + | |
| 8238 | +#: app/views/profile_members/_index_buttons.html.erb:5 | |
| 8239 | +#: app/views/invite/select_friends.html.erb:6 | |
| 8240 | +#: app/views/invite/invite_friends.html.erb:5 | |
| 8241 | +#: app/views/profile/members.html.erb:21 | |
| 8242 | +msgid "Invite people to join" | |
| 8243 | +msgstr "Invitez les personnes à joindre" | |
| 8244 | + | |
| 8245 | +#: app/views/profile_members/_index_buttons.html.erb:8 | |
| 8246 | +#: app/views/profile/send_mail.html.erb:3 | |
| 8247 | +#: app/views/profile/members.html.erb:24 | |
| 8248 | +msgid "Send e-mail to members" | |
| 8249 | +msgstr "Envoyer un e-mail aux membres" | |
| 8248 | 8250 | |
| 8249 | 8251 | #: app/views/shared/logged_in/xmpp_chat.html.erb:61 |
| 8250 | 8252 | #, fuzzy |
| ... | ... | @@ -8255,26 +8257,22 @@ msgstr "Entrez votre commentaire" |
| 8255 | 8257 | msgid "\"Published at: #{show_date(content.updated_at)}\"" |
| 8256 | 8258 | msgstr "" |
| 8257 | 8259 | |
| 8258 | -#: app/views/shared/_profile_search_form.html.erb:1 | |
| 8259 | -#: app/views/shared/_profile_search_form.html.erb:9 | |
| 8260 | -#, fuzzy | |
| 8261 | -msgid "Find in %s's content" | |
| 8262 | -msgstr "Contenu principal" | |
| 8260 | +#: app/views/profile_members/add_members.html.erb:1 | |
| 8261 | +msgid "Add members to %s" | |
| 8262 | +msgstr "Ajouter des membres à %s" | |
| 8263 | 8263 | |
| 8264 | 8264 | #: app/views/shared/_profile_search_form.html.erb:10 |
| 8265 | 8265 | #, fuzzy |
| 8266 | 8266 | msgid "General" |
| 8267 | 8267 | msgstr "Tâche générique" |
| 8268 | 8268 | |
| 8269 | -#: app/views/shared/_profile_search_form.html.erb:10 | |
| 8270 | -#, fuzzy | |
| 8271 | -msgid "Search all content" | |
| 8272 | -msgstr "Tout le contenu" | |
| 8269 | +#: app/views/profile_members/change_role.html.erb:15 | |
| 8270 | +msgid "Custom Roles:" | |
| 8271 | +msgstr "Rôles personnalisés :" | |
| 8273 | 8272 | |
| 8274 | -#: app/views/shared/_select_subcategories.html.erb:3 | |
| 8275 | -#, fuzzy | |
| 8276 | -msgid "Click to select a category" | |
| 8277 | -msgstr "Choisissez une catégorie :" | |
| 8273 | +#: app/views/maps/edit_location.html.erb:15 | |
| 8274 | +msgid "Locate in the map" | |
| 8275 | +msgstr "Localiser sur la carte" | |
| 8278 | 8276 | |
| 8279 | 8277 | #: app/views/shared/not_found.html.erb:2 |
| 8280 | 8278 | msgid "There is no such page: %s" |
| ... | ... | @@ -8313,10 +8311,9 @@ msgstr "Aller à la page d'accueil du site" |
| 8313 | 8311 | msgid "Open chat" |
| 8314 | 8312 | msgstr "Un contact" |
| 8315 | 8313 | |
| 8316 | -#: app/views/shared/profile_actions/xmpp_chat.html.erb:1 | |
| 8317 | -#, fuzzy | |
| 8318 | -msgid "Join chat room" | |
| 8319 | -msgstr "Se joindre" | |
| 8314 | +#: app/views/maps/_google_map.js.erb:137 | |
| 8315 | +msgid "Request denied" | |
| 8316 | +msgstr "Demande refusée" | |
| 8320 | 8317 | |
| 8321 | 8318 | #: app/views/shared/access_denied.html.erb:3 lib/authenticated_system.rb:83 |
| 8322 | 8319 | msgid "Access denied" |
| ... | ... | @@ -8334,9 +8331,19 @@ msgstr "" |
| 8334 | 8331 | "Si vous êtes supposé(e) avoir accès à cette zone, vous devriez sans doute en " |
| 8335 | 8332 | "référer aux responsable et leur demander de vous y donner accès." |
| 8336 | 8333 | |
| 8337 | -#: app/views/shared/access_denied.html.erb:14 public/500.html.erb:28 | |
| 8338 | -msgid "Go to the site home page" | |
| 8339 | -msgstr "Aller à la page d'accueil du site" | |
| 8334 | +#: app/views/categories/new.html.erb:1 app/views/categories/index.html.erb:7 | |
| 8335 | +#: app/views/categories/index.html.erb:16 | |
| 8336 | +#: app/views/categories/index.html.erb:25 | |
| 8337 | +msgid "New category" | |
| 8338 | +msgstr "Nouvelle catégorie" | |
| 8339 | + | |
| 8340 | +#: app/views/categories/_category.html.erb:10 | |
| 8341 | +msgid "Show" | |
| 8342 | +msgstr "Voir" | |
| 8343 | + | |
| 8344 | +#: app/views/categories/_category.html.erb:12 | |
| 8345 | +msgid "Hide" | |
| 8346 | +msgstr "Cacher" | |
| 8340 | 8347 | |
| 8341 | 8348 | #: app/views/shared/_lead_and_body.html.erb:18 |
| 8342 | 8349 | msgid "Used when a short version of your text is needed." |
| ... | ... | @@ -8354,13 +8361,13 @@ msgstr "" |
| 8354 | 8361 | "Vous pouvez déplacer cette fenêtre pour avoir une meilleure vue sur " |
| 8355 | 8362 | "certaines parties de l'écran." |
| 8356 | 8363 | |
| 8357 | -#: app/views/shared/theme_test_panel.html.erb:9 | |
| 8358 | -msgid "Finished testing" | |
| 8359 | -msgstr "Test terminé" | |
| 8364 | +#: app/views/categories/_form.html.erb:22 | |
| 8365 | +msgid "Display in the menu" | |
| 8366 | +msgstr "Afficher dans le menu" | |
| 8360 | 8367 | |
| 8361 | -#: app/views/shared/theme_test_panel.html.erb:10 | |
| 8362 | -msgid "Edit theme" | |
| 8363 | -msgstr "Éditer le thème" | |
| 8368 | +#: app/views/categories/_form.html.erb:24 | |
| 8369 | +msgid "Pick a color" | |
| 8370 | +msgstr "Choisir la couleur" | |
| 8364 | 8371 | |
| 8365 | 8372 | #: app/views/shared/_list_groups.html.erb:9 |
| 8366 | 8373 | msgid "Role: %s" |
| ... | ... | @@ -8374,14 +8381,13 @@ msgstr "Type : %s" |
| 8374 | 8381 | msgid "Members: %s" |
| 8375 | 8382 | msgstr "Membres : %s" |
| 8376 | 8383 | |
| 8377 | -#: app/views/shared/_list_groups.html.erb:13 | |
| 8378 | -msgid "Created at: %s" | |
| 8379 | -msgstr "Créé le : %s" | |
| 8384 | +#: app/views/memberships/welcome.html.erb:1 | |
| 8385 | +msgid "Community created" | |
| 8386 | +msgstr "Communauté créée" | |
| 8380 | 8387 | |
| 8381 | -#: app/views/shared/_list_groups.html.erb:16 | |
| 8382 | -#, fuzzy | |
| 8383 | -msgid "Control panel of this group" | |
| 8384 | -msgstr "Panneau de contrôle" | |
| 8388 | +#: app/views/memberships/welcome.html.erb:2 | |
| 8389 | +msgid "Your community (%s) was successfully created." | |
| 8390 | +msgstr "Votre communauté (%s) a été créée avec succès." | |
| 8385 | 8391 | |
| 8386 | 8392 | #: app/views/shared/_remove_suggestion.html.erb:4 |
| 8387 | 8393 | #, fuzzy | ... | ... |
public/500.html
| ... | ... | @@ -67,7 +67,7 @@ |
| 67 | 67 | |
| 68 | 68 | |
| 69 | 69 | <div id='fr' style='display: none' class='message'> |
| 70 | - <h1>Problème temporaire du système.</h1> | |
| 70 | + <h1>Problème temporaire du système</h1> | |
| 71 | 71 | <p> |
| 72 | 72 | Notre équipe technique est en train d'y travailler. Merci de réessayer plus tard. Nous sommes désolés de la gêne occasionnée. |
| 73 | 73 | </p> | ... | ... |
public/proposal-app
test/functional/categories_controller_test.rb
| ... | ... | @@ -32,12 +32,10 @@ class CategoriesControllerTest < ActionController::TestCase |
| 32 | 32 | end |
| 33 | 33 | |
| 34 | 34 | def test_edit |
| 35 | - cat = Category.new | |
| 36 | - env.categories.expects(:find).with('1').returns(cat) | |
| 37 | - get :edit, :id => '1' | |
| 35 | + get :edit, :id => cat1 | |
| 38 | 36 | assert_response :success |
| 39 | 37 | assert_template 'edit' |
| 40 | - assert_equal cat, assigns(:category) | |
| 38 | + assert_equal cat1, assigns(:category) | |
| 41 | 39 | end |
| 42 | 40 | |
| 43 | 41 | def test_edit_save | ... | ... |
test/functional/tasks_controller_test.rb
| ... | ... | @@ -145,15 +145,23 @@ class TasksControllerTest < ActionController::TestCase |
| 145 | 145 | end |
| 146 | 146 | |
| 147 | 147 | should 'affiliate roles to user after finish add member task' do |
| 148 | - community = fast_create(Community) | |
| 149 | - community.add_member(person) | |
| 150 | - another_person = fast_create(Person) | |
| 151 | - t = AddMember.create!(:person => another_person, :organization => community) | |
| 152 | - count = community.members.size | |
| 153 | - @controller.stubs(:profile).returns(community) | |
| 148 | + c = fast_create(Community) | |
| 149 | + p = create_user('member').person | |
| 150 | + | |
| 151 | + @controller.stubs(:profile).returns(c) | |
| 152 | + c.affiliate(profile, Profile::Roles.all_roles(profile.environment.id)) | |
| 153 | + | |
| 154 | + t = AddMember.create!(:person => p, :organization => c) | |
| 155 | + | |
| 156 | + count = c.members.size | |
| 157 | + | |
| 154 | 158 | post :close, :tasks => {t.id => {:decision => 'finish', :task => {}}} |
| 155 | - community = Profile.find(community.id) | |
| 156 | - assert_equal count + 1, community.members.size | |
| 159 | + t.reload | |
| 160 | + | |
| 161 | + ok('task should be finished') { t.status == Task::Status::FINISHED } | |
| 162 | + | |
| 163 | + c.reload | |
| 164 | + assert_equal count + 1, c.members.size | |
| 157 | 165 | end |
| 158 | 166 | |
| 159 | 167 | should 'display a create ticket form' do |
| ... | ... | @@ -269,6 +277,7 @@ class TasksControllerTest < ActionController::TestCase |
| 269 | 277 | @controller.stubs(:profile).returns(c) |
| 270 | 278 | c.affiliate(person, Profile::Roles.all_roles(c.environment)) |
| 271 | 279 | person = create_user('test_user').person |
| 280 | + c.add_member(person) | |
| 272 | 281 | p_blog = Blog.create!(:profile => person, :name => 'Blog') |
| 273 | 282 | c_blog1 = Blog.create!(:profile => c, :name => 'Blog') |
| 274 | 283 | c_blog2 = Blog.new(:profile => c); c_blog2.name = 'blog2'; c_blog2.save! | ... | ... |
test/unit/api/articles_test.rb
| ... | ... | @@ -31,7 +31,7 @@ class ArticlesTest < ActiveSupport::TestCase |
| 31 | 31 | end |
| 32 | 32 | |
| 33 | 33 | should 'not return article if user has no permission to view it' do |
| 34 | - person = fast_create(Person) | |
| 34 | + person = fast_create(Person, :environment_id => environment.id) | |
| 35 | 35 | article = fast_create(Article, :profile_id => person.id, :name => "Some thing", :published => false) |
| 36 | 36 | assert !article.published? |
| 37 | 37 | |
| ... | ... | @@ -49,7 +49,7 @@ class ArticlesTest < ActiveSupport::TestCase |
| 49 | 49 | end |
| 50 | 50 | |
| 51 | 51 | should 'not list children of forbidden article' do |
| 52 | - person = fast_create(Person) | |
| 52 | + person = fast_create(Person, :environment_id => environment.id) | |
| 53 | 53 | article = fast_create(Article, :profile_id => person.id, :name => "Some thing", :published => false) |
| 54 | 54 | child1 = fast_create(Article, :parent_id => article.id, :profile_id => person.id, :name => "Some thing") |
| 55 | 55 | child2 = fast_create(Article, :parent_id => article.id, :profile_id => person.id, :name => "Some thing") |
| ... | ... | @@ -58,7 +58,7 @@ class ArticlesTest < ActiveSupport::TestCase |
| 58 | 58 | end |
| 59 | 59 | |
| 60 | 60 | should 'not return child of forbidden article' do |
| 61 | - person = fast_create(Person) | |
| 61 | + person = fast_create(Person, :environment_id => environment.id) | |
| 62 | 62 | article = fast_create(Article, :profile_id => person.id, :name => "Some thing", :published => false) |
| 63 | 63 | child = fast_create(Article, :parent_id => article.id, :profile_id => person.id, :name => "Some thing") |
| 64 | 64 | get "/api/v1/articles/#{article.id}/children/#{child.id}?#{params.to_query}" |
| ... | ... | @@ -66,7 +66,7 @@ class ArticlesTest < ActiveSupport::TestCase |
| 66 | 66 | end |
| 67 | 67 | |
| 68 | 68 | should 'not return private child' do |
| 69 | - person = fast_create(Person) | |
| 69 | + person = fast_create(Person, :environment_id => environment.id) | |
| 70 | 70 | article = fast_create(Article, :profile_id => person.id, :name => "Some thing") |
| 71 | 71 | child = fast_create(Article, :parent_id => article.id, :profile_id => person.id, :name => "Some thing", :published => false) |
| 72 | 72 | get "/api/v1/articles/#{article.id}/children/#{child.id}?#{params.to_query}" |
| ... | ... | @@ -74,7 +74,7 @@ class ArticlesTest < ActiveSupport::TestCase |
| 74 | 74 | end |
| 75 | 75 | |
| 76 | 76 | should 'not list private child' do |
| 77 | - person = fast_create(Person) | |
| 77 | + person = fast_create(Person, :environment_id => environment.id) | |
| 78 | 78 | article = fast_create(Article, :profile_id => person.id, :name => "Some thing") |
| 79 | 79 | child = fast_create(Article, :parent_id => article.id, :profile_id => person.id, :name => "Some thing", :published => false) |
| 80 | 80 | get "/api/v1/articles/#{article.id}/children?#{params.to_query}" |
| ... | ... | @@ -89,7 +89,7 @@ class ArticlesTest < ActiveSupport::TestCase |
| 89 | 89 | profile_kinds = %w(community person enterprise) |
| 90 | 90 | profile_kinds.each do |kind| |
| 91 | 91 | should "return article by #{kind}" do |
| 92 | - profile = fast_create(kind.camelcase.constantize) | |
| 92 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 93 | 93 | article = fast_create(Article, :profile_id => profile.id, :name => "Some thing") |
| 94 | 94 | get "/api/v1/#{kind.pluralize}/#{profile.id}/articles/#{article.id}?#{params.to_query}" |
| 95 | 95 | json = JSON.parse(last_response.body) |
| ... | ... | @@ -97,7 +97,7 @@ class ArticlesTest < ActiveSupport::TestCase |
| 97 | 97 | end |
| 98 | 98 | |
| 99 | 99 | should "not return article by #{kind} if user has no permission to view it" do |
| 100 | - profile = fast_create(kind.camelcase.constantize) | |
| 100 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 101 | 101 | article = fast_create(Article, :profile_id => profile.id, :name => "Some thing", :published => false) |
| 102 | 102 | assert !article.published? |
| 103 | 103 | |
| ... | ... | @@ -106,7 +106,7 @@ class ArticlesTest < ActiveSupport::TestCase |
| 106 | 106 | end |
| 107 | 107 | |
| 108 | 108 | should "not list forbidden article when listing articles by #{kind}" do |
| 109 | - profile = fast_create(kind.camelcase.constantize) | |
| 109 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 110 | 110 | article = fast_create(Article, :profile_id => profile.id, :name => "Some thing", :published => false) |
| 111 | 111 | assert !article.published? |
| 112 | 112 | |
| ... | ... | @@ -123,7 +123,7 @@ class ArticlesTest < ActiveSupport::TestCase |
| 123 | 123 | group_kinds = %w(community enterprise) |
| 124 | 124 | group_kinds.each do |kind| |
| 125 | 125 | should "#{kind}: create article" do |
| 126 | - profile = fast_create(kind.camelcase.constantize) | |
| 126 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 127 | 127 | give_permission(user.person, 'post_content', profile) |
| 128 | 128 | params[:article] = {:name => "Title"} |
| 129 | 129 | post "/api/v1/#{kind.pluralize}/#{profile.id}/articles?#{params.to_query}" |
| ... | ... | @@ -132,16 +132,16 @@ class ArticlesTest < ActiveSupport::TestCase |
| 132 | 132 | end |
| 133 | 133 | |
| 134 | 134 | should "#{kind}: do not create article if user has no permission to post content" do |
| 135 | - profile = fast_create(kind.camelcase.constantize) | |
| 135 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 136 | 136 | give_permission(user.person, 'invite_members', profile) |
| 137 | 137 | params[:article] = {:name => "Title"} |
| 138 | 138 | post "/api/v1/#{kind.pluralize}/#{profile.id}/articles?#{params.to_query}" |
| 139 | 139 | assert_equal 403, last_response.status |
| 140 | 140 | end |
| 141 | 141 | |
| 142 | - should "#{kind}: create article with parent" do | |
| 143 | - profile = fast_create(kind.camelcase.constantize) | |
| 144 | - profile.add_member(user.person) | |
| 142 | + should "#{kind} create article with parent" do | |
| 143 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 144 | + Person.any_instance.stubs(:can_post_content?).with(profile).returns(true) | |
| 145 | 145 | article = fast_create(Article) |
| 146 | 146 | |
| 147 | 147 | params[:article] = {:name => "Title", :parent_id => article.id} |
| ... | ... | @@ -150,9 +150,9 @@ class ArticlesTest < ActiveSupport::TestCase |
| 150 | 150 | assert_equal article.id, json["article"]["parent"]["id"] |
| 151 | 151 | end |
| 152 | 152 | |
| 153 | - should "#{kind}: create article with content type passed as parameter" do | |
| 154 | - profile = fast_create(kind.camelcase.constantize) | |
| 155 | - profile.add_member(user.person) | |
| 153 | + should "#{kind} create article with content type passed as parameter" do | |
| 154 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 155 | + Person.any_instance.stubs(:can_post_content?).with(profile).returns(true) | |
| 156 | 156 | |
| 157 | 157 | Article.delete_all |
| 158 | 158 | params[:article] = {:name => "Title"} |
| ... | ... | @@ -164,8 +164,8 @@ class ArticlesTest < ActiveSupport::TestCase |
| 164 | 164 | end |
| 165 | 165 | |
| 166 | 166 | should "#{kind}: create article of TinyMceArticle type if no content type is passed as parameter" do |
| 167 | - profile = fast_create(kind.camelcase.constantize) | |
| 168 | - profile.add_member(user.person) | |
| 167 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 168 | + Person.any_instance.stubs(:can_post_content?).with(profile).returns(true) | |
| 169 | 169 | |
| 170 | 170 | params[:article] = {:name => "Title"} |
| 171 | 171 | post "/api/v1/#{kind.pluralize}/#{profile.id}/articles?#{params.to_query}" |
| ... | ... | @@ -175,7 +175,7 @@ class ArticlesTest < ActiveSupport::TestCase |
| 175 | 175 | end |
| 176 | 176 | |
| 177 | 177 | should "#{kind}: not create article with invalid article content type" do |
| 178 | - profile = fast_create(kind.camelcase.constantize) | |
| 178 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 179 | 179 | profile.add_member(user.person) |
| 180 | 180 | |
| 181 | 181 | params[:article] = {:name => "Title"} |
| ... | ... | @@ -186,20 +186,20 @@ class ArticlesTest < ActiveSupport::TestCase |
| 186 | 186 | assert_equal 403, last_response.status |
| 187 | 187 | end |
| 188 | 188 | |
| 189 | - should "#{kind}: create article defining the correct profile" do | |
| 190 | - profile = fast_create(kind.camelcase.constantize) | |
| 191 | - profile.add_member(user.person) | |
| 189 | + should "#{kind} create article defining the correct profile" do | |
| 190 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 191 | + Person.any_instance.stubs(:can_post_content?).with(profile).returns(true) | |
| 192 | 192 | |
| 193 | 193 | params[:article] = {:name => "Title"} |
| 194 | 194 | post "/api/v1/#{kind.pluralize}/#{profile.id}/articles?#{params.to_query}" |
| 195 | 195 | json = JSON.parse(last_response.body) |
| 196 | 196 | |
| 197 | - assert_equal profile, Article.last.profile | |
| 197 | + assert_equal profile.id, json['article']['profile']['id'] | |
| 198 | 198 | end |
| 199 | 199 | |
| 200 | 200 | should "#{kind}: create article defining the created_by" do |
| 201 | - profile = fast_create(kind.camelcase.constantize) | |
| 202 | - profile.add_member(user.person) | |
| 201 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 202 | + Person.any_instance.stubs(:can_post_content?).with(profile).returns(true) | |
| 203 | 203 | |
| 204 | 204 | params[:article] = {:name => "Title"} |
| 205 | 205 | post "/api/v1/#{kind.pluralize}/#{profile.id}/articles?#{params.to_query}" |
| ... | ... | @@ -209,8 +209,8 @@ class ArticlesTest < ActiveSupport::TestCase |
| 209 | 209 | end |
| 210 | 210 | |
| 211 | 211 | should "#{kind}: create article defining the last_changed_by" do |
| 212 | - profile = fast_create(kind.camelcase.constantize) | |
| 213 | - profile.add_member(user.person) | |
| 212 | + profile = fast_create(kind.camelcase.constantize, :environment_id => environment.id) | |
| 213 | + Person.any_instance.stubs(:can_post_content?).with(profile).returns(true) | |
| 214 | 214 | |
| 215 | 215 | params[:article] = {:name => "Title"} |
| 216 | 216 | post "/api/v1/#{kind.pluralize}/#{profile.id}/articles?#{params.to_query}" |
| ... | ... | @@ -232,7 +232,7 @@ class ArticlesTest < ActiveSupport::TestCase |
| 232 | 232 | end |
| 233 | 233 | |
| 234 | 234 | should 'person do not create article if user has no permission to post content' do |
| 235 | - person = fast_create(Person) | |
| 235 | + person = fast_create(Person, :environment_id => environment.id) | |
| 236 | 236 | params[:article] = {:name => "Title"} |
| 237 | 237 | post "/api/v1/people/#{person.id}/articles?#{params.to_query}" |
| 238 | 238 | assert_equal 403, last_response.status | ... | ... |
test/unit/api/categories_test.rb
| ... | ... | @@ -7,25 +7,25 @@ class CategoriesTest < ActiveSupport::TestCase |
| 7 | 7 | end |
| 8 | 8 | |
| 9 | 9 | should 'list categories' do |
| 10 | - category = fast_create(Category) | |
| 10 | + category = fast_create(Category, :environment_id => environment.id) | |
| 11 | 11 | get "/api/v1/categories/?#{params.to_query}" |
| 12 | 12 | json = JSON.parse(last_response.body) |
| 13 | 13 | assert_includes json["categories"].map { |c| c["name"] }, category.name |
| 14 | 14 | end |
| 15 | 15 | |
| 16 | 16 | should 'get category by id' do |
| 17 | - category = fast_create(Category) | |
| 17 | + category = fast_create(Category, :environment_id => environment.id) | |
| 18 | 18 | get "/api/v1/categories/#{category.id}/?#{params.to_query}" |
| 19 | 19 | json = JSON.parse(last_response.body) |
| 20 | 20 | assert_equal category.name, json["category"]["name"] |
| 21 | 21 | end |
| 22 | 22 | |
| 23 | 23 | should 'list parent and children when get category by id' do |
| 24 | - parent = fast_create(Category) | |
| 25 | - child_1 = fast_create(Category) | |
| 26 | - child_2 = fast_create(Category) | |
| 24 | + parent = fast_create(Category, :environment_id => environment.id) | |
| 25 | + child_1 = fast_create(Category, :environment_id => environment.id) | |
| 26 | + child_2 = fast_create(Category, :environment_id => environment.id) | |
| 27 | 27 | |
| 28 | - category = fast_create(Category) | |
| 28 | + category = fast_create(Category, :environment_id => environment.id) | |
| 29 | 29 | category.parent = parent |
| 30 | 30 | category.children << child_1 |
| 31 | 31 | category.children << child_2 |
| ... | ... | @@ -38,11 +38,11 @@ class CategoriesTest < ActiveSupport::TestCase |
| 38 | 38 | end |
| 39 | 39 | |
| 40 | 40 | should 'include parent in categories list if params is true' do |
| 41 | - parent_1 = fast_create(Category) # parent_1 has no parent category | |
| 42 | - child_1 = fast_create(Category) | |
| 43 | - child_2 = fast_create(Category) | |
| 41 | + parent_1 = fast_create(Category, :environment_id => environment.id) # parent_1 has no parent category | |
| 42 | + child_1 = fast_create(Category, :environment_id => environment.id) | |
| 43 | + child_2 = fast_create(Category, :environment_id => environment.id) | |
| 44 | 44 | |
| 45 | - parent_2 = fast_create(Category) | |
| 45 | + parent_2 = fast_create(Category, :environment_id => environment.id) | |
| 46 | 46 | parent_2.parent = parent_1 |
| 47 | 47 | parent_2.children << child_1 |
| 48 | 48 | parent_2.children << child_2 |
| ... | ... | @@ -60,10 +60,10 @@ class CategoriesTest < ActiveSupport::TestCase |
| 60 | 60 | end |
| 61 | 61 | |
| 62 | 62 | should 'include children in categories list if params is true' do |
| 63 | - category = fast_create(Category) | |
| 64 | - child_1 = fast_create(Category) | |
| 65 | - child_2 = fast_create(Category) | |
| 66 | - child_3 = fast_create(Category) | |
| 63 | + category = fast_create(Category, :environment_id => environment.id) | |
| 64 | + child_1 = fast_create(Category, :environment_id => environment.id) | |
| 65 | + child_2 = fast_create(Category, :environment_id => environment.id) | |
| 66 | + child_3 = fast_create(Category, :environment_id => environment.id) | |
| 67 | 67 | |
| 68 | 68 | category.children << child_1 |
| 69 | 69 | category.children << child_2 | ... | ... |
test/unit/api/communities_test.rb
| ... | ... | @@ -8,8 +8,8 @@ class CommunitiesTest < ActiveSupport::TestCase |
| 8 | 8 | end |
| 9 | 9 | |
| 10 | 10 | should 'list only communities' do |
| 11 | - community = fast_create(Community) | |
| 12 | - enterprise = fast_create(Enterprise) # should not list this enterprise | |
| 11 | + community = fast_create(Community, :environment_id => environment.id) | |
| 12 | + enterprise = fast_create(Enterprise, :environment_id => environment.id) # should not list this enterprise | |
| 13 | 13 | get "/api/v1/communities?#{params.to_query}" |
| 14 | 14 | json = JSON.parse(last_response.body) |
| 15 | 15 | assert_not_includes json['communities'].map {|c| c['id']}, enterprise.id |
| ... | ... | @@ -17,16 +17,16 @@ class CommunitiesTest < ActiveSupport::TestCase |
| 17 | 17 | end |
| 18 | 18 | |
| 19 | 19 | should 'list all communities' do |
| 20 | - community1 = fast_create(Community, :public_profile => true) | |
| 21 | - community2 = fast_create(Community) | |
| 20 | + community1 = fast_create(Community, :environment_id => environment.id, :public_profile => true) | |
| 21 | + community2 = fast_create(Community, :environment_id => environment.id) | |
| 22 | 22 | get "/api/v1/communities?#{params.to_query}" |
| 23 | 23 | json = JSON.parse(last_response.body) |
| 24 | 24 | assert_equivalent [community1.id, community2.id], json['communities'].map {|c| c['id']} |
| 25 | 25 | end |
| 26 | 26 | |
| 27 | 27 | should 'not list invisible communities' do |
| 28 | - community1 = fast_create(Community) | |
| 29 | - fast_create(Community, :visible => false) | |
| 28 | + community1 = fast_create(Community, :environment_id => environment.id) | |
| 29 | + fast_create(Community, :environment_id => environment.id, :visible => false) | |
| 30 | 30 | |
| 31 | 31 | get "/api/v1/communities?#{params.to_query}" |
| 32 | 32 | json = JSON.parse(last_response.body) |
| ... | ... | @@ -34,8 +34,8 @@ class CommunitiesTest < ActiveSupport::TestCase |
| 34 | 34 | end |
| 35 | 35 | |
| 36 | 36 | should 'not list private communities without permission' do |
| 37 | - community1 = fast_create(Community) | |
| 38 | - fast_create(Community, :public_profile => false) | |
| 37 | + community1 = fast_create(Community, :environment_id => environment.id) | |
| 38 | + fast_create(Community, :environment_id => environment.id, :public_profile => false) | |
| 39 | 39 | |
| 40 | 40 | get "/api/v1/communities?#{params.to_query}" |
| 41 | 41 | json = JSON.parse(last_response.body) |
| ... | ... | @@ -43,8 +43,8 @@ class CommunitiesTest < ActiveSupport::TestCase |
| 43 | 43 | end |
| 44 | 44 | |
| 45 | 45 | should 'list private community for members' do |
| 46 | - c1 = fast_create(Community) | |
| 47 | - c2 = fast_create(Community, :public_profile => false) | |
| 46 | + c1 = fast_create(Community, :environment_id => environment.id) | |
| 47 | + c2 = fast_create(Community, :environment_id => environment.id, :public_profile => false) | |
| 48 | 48 | c2.add_member(person) |
| 49 | 49 | |
| 50 | 50 | get "/api/v1/communities?#{params.to_query}" |
| ... | ... | @@ -66,7 +66,7 @@ class CommunitiesTest < ActiveSupport::TestCase |
| 66 | 66 | end |
| 67 | 67 | |
| 68 | 68 | should 'get community' do |
| 69 | - community = fast_create(Community) | |
| 69 | + community = fast_create(Community, :environment_id => environment.id) | |
| 70 | 70 | |
| 71 | 71 | get "/api/v1/communities/#{community.id}?#{params.to_query}" |
| 72 | 72 | json = JSON.parse(last_response.body) |
| ... | ... | @@ -74,7 +74,7 @@ class CommunitiesTest < ActiveSupport::TestCase |
| 74 | 74 | end |
| 75 | 75 | |
| 76 | 76 | should 'not get invisible community' do |
| 77 | - community = fast_create(Community, :visible => false) | |
| 77 | + community = fast_create(Community, :environment_id => environment.id, :visible => false) | |
| 78 | 78 | |
| 79 | 79 | get "/api/v1/communities/#{community.id}?#{params.to_query}" |
| 80 | 80 | json = JSON.parse(last_response.body) |
| ... | ... | @@ -82,8 +82,8 @@ class CommunitiesTest < ActiveSupport::TestCase |
| 82 | 82 | end |
| 83 | 83 | |
| 84 | 84 | should 'not get private communities without permission' do |
| 85 | - community = fast_create(Community) | |
| 86 | - fast_create(Community, :public_profile => false) | |
| 85 | + community = fast_create(Community, :environment_id => environment.id) | |
| 86 | + fast_create(Community, :environment_id => environment.id, :public_profile => false) | |
| 87 | 87 | |
| 88 | 88 | get "/api/v1/communities/#{community.id}?#{params.to_query}" |
| 89 | 89 | json = JSON.parse(last_response.body) |
| ... | ... | @@ -91,17 +91,18 @@ class CommunitiesTest < ActiveSupport::TestCase |
| 91 | 91 | end |
| 92 | 92 | |
| 93 | 93 | should 'get private community for members' do |
| 94 | - community = fast_create(Community, :public_profile => false) | |
| 94 | + community = fast_create(Community, :environment_id => environment.id, :public_profile => false, :visible => true) | |
| 95 | 95 | community.add_member(person) |
| 96 | 96 | |
| 97 | + | |
| 97 | 98 | get "/api/v1/communities/#{community.id}?#{params.to_query}" |
| 98 | 99 | json = JSON.parse(last_response.body) |
| 99 | 100 | assert_equal community.id, json['community']['id'] |
| 100 | 101 | end |
| 101 | 102 | |
| 102 | 103 | should 'list person communities' do |
| 103 | - community = fast_create(Community) | |
| 104 | - fast_create(Community) | |
| 104 | + community = fast_create(Community, :environment_id => environment.id) | |
| 105 | + fast_create(Community, :environment_id => environment.id) | |
| 105 | 106 | community.add_member(person) |
| 106 | 107 | |
| 107 | 108 | get "/api/v1/people/#{person.id}/communities?#{params.to_query}" |
| ... | ... | @@ -110,8 +111,8 @@ class CommunitiesTest < ActiveSupport::TestCase |
| 110 | 111 | end |
| 111 | 112 | |
| 112 | 113 | should 'not list person communities invisible' do |
| 113 | - c1 = fast_create(Community) | |
| 114 | - c2 = fast_create(Community, :visible => false) | |
| 114 | + c1 = fast_create(Community, :environment_id => environment.id) | |
| 115 | + c2 = fast_create(Community, :environment_id => environment.id, :visible => false) | |
| 115 | 116 | c1.add_member(person) |
| 116 | 117 | c2.add_member(person) |
| 117 | 118 | ... | ... |
test/unit/api/enterprises_test.rb
| ... | ... | @@ -8,8 +8,8 @@ class EnterprisesTest < ActiveSupport::TestCase |
| 8 | 8 | end |
| 9 | 9 | |
| 10 | 10 | should 'list only enterprises' do |
| 11 | - community = fast_create(Community) # should not list this community | |
| 12 | - enterprise = fast_create(Enterprise, :public_profile => true) | |
| 11 | + community = fast_create(Community, :environment_id => environment.id) # should not list this community | |
| 12 | + enterprise = fast_create(Enterprise, :environment_id => environment.id, :public_profile => true) | |
| 13 | 13 | get "/api/v1/enterprises?#{params.to_query}" |
| 14 | 14 | json = JSON.parse(last_response.body) |
| 15 | 15 | assert_includes json['enterprises'].map {|c| c['id']}, enterprise.id |
| ... | ... | @@ -17,15 +17,15 @@ class EnterprisesTest < ActiveSupport::TestCase |
| 17 | 17 | end |
| 18 | 18 | |
| 19 | 19 | should 'list all enterprises' do |
| 20 | - enterprise1 = fast_create(Enterprise, :public_profile => true) | |
| 21 | - enterprise2 = fast_create(Enterprise) | |
| 20 | + enterprise1 = fast_create(Enterprise, :environment_id => environment.id, :public_profile => true) | |
| 21 | + enterprise2 = fast_create(Enterprise, :environment_id => environment.id) | |
| 22 | 22 | get "/api/v1/enterprises?#{params.to_query}" |
| 23 | 23 | json = JSON.parse(last_response.body) |
| 24 | 24 | assert_equivalent [enterprise1.id, enterprise2.id], json['enterprises'].map {|c| c['id']} |
| 25 | 25 | end |
| 26 | 26 | |
| 27 | 27 | should 'not list invisible enterprises' do |
| 28 | - enterprise1 = fast_create(Enterprise) | |
| 28 | + enterprise1 = fast_create(Enterprise, :environment_id => environment.id) | |
| 29 | 29 | fast_create(Enterprise, :visible => false) |
| 30 | 30 | |
| 31 | 31 | get "/api/v1/enterprises?#{params.to_query}" |
| ... | ... | @@ -34,8 +34,8 @@ class EnterprisesTest < ActiveSupport::TestCase |
| 34 | 34 | end |
| 35 | 35 | |
| 36 | 36 | should 'not list private enterprises without permission' do |
| 37 | - enterprise1 = fast_create(Enterprise) | |
| 38 | - fast_create(Enterprise, :public_profile => false) | |
| 37 | + enterprise1 = fast_create(Enterprise, :environment_id => environment.id) | |
| 38 | + fast_create(Enterprise, :environment_id => environment.id, :public_profile => false) | |
| 39 | 39 | |
| 40 | 40 | get "/api/v1/enterprises?#{params.to_query}" |
| 41 | 41 | json = JSON.parse(last_response.body) |
| ... | ... | @@ -43,8 +43,8 @@ class EnterprisesTest < ActiveSupport::TestCase |
| 43 | 43 | end |
| 44 | 44 | |
| 45 | 45 | should 'list private enterprise for members' do |
| 46 | - c1 = fast_create(Enterprise) | |
| 47 | - c2 = fast_create(Enterprise, :public_profile => false) | |
| 46 | + c1 = fast_create(Enterprise, :environment_id => environment.id) | |
| 47 | + c2 = fast_create(Enterprise, :environment_id => environment.id, :public_profile => false) | |
| 48 | 48 | c2.add_member(person) |
| 49 | 49 | |
| 50 | 50 | get "/api/v1/enterprises?#{params.to_query}" |
| ... | ... | @@ -53,7 +53,7 @@ class EnterprisesTest < ActiveSupport::TestCase |
| 53 | 53 | end |
| 54 | 54 | |
| 55 | 55 | should 'get enterprise' do |
| 56 | - enterprise = fast_create(Enterprise) | |
| 56 | + enterprise = fast_create(Enterprise, :environment_id => environment.id) | |
| 57 | 57 | |
| 58 | 58 | get "/api/v1/enterprises/#{enterprise.id}?#{params.to_query}" |
| 59 | 59 | json = JSON.parse(last_response.body) |
| ... | ... | @@ -69,8 +69,8 @@ class EnterprisesTest < ActiveSupport::TestCase |
| 69 | 69 | end |
| 70 | 70 | |
| 71 | 71 | should 'not get private enterprises without permission' do |
| 72 | - enterprise = fast_create(Enterprise) | |
| 73 | - fast_create(Enterprise, :public_profile => false) | |
| 72 | + enterprise = fast_create(Enterprise, :environment_id => environment.id) | |
| 73 | + fast_create(Enterprise, :environment_id => environment.id, :public_profile => false) | |
| 74 | 74 | |
| 75 | 75 | get "/api/v1/enterprises/#{enterprise.id}?#{params.to_query}" |
| 76 | 76 | json = JSON.parse(last_response.body) |
| ... | ... | @@ -87,8 +87,8 @@ class EnterprisesTest < ActiveSupport::TestCase |
| 87 | 87 | end |
| 88 | 88 | |
| 89 | 89 | should 'list person enterprises' do |
| 90 | - enterprise = fast_create(Enterprise) | |
| 91 | - fast_create(Enterprise) | |
| 90 | + enterprise = fast_create(Enterprise, :environment_id => environment.id) | |
| 91 | + fast_create(Enterprise, :environment_id => environment.id) | |
| 92 | 92 | enterprise.add_member(person) |
| 93 | 93 | |
| 94 | 94 | get "/api/v1/people/#{person.id}/enterprises?#{params.to_query}" |
| ... | ... | @@ -97,8 +97,8 @@ class EnterprisesTest < ActiveSupport::TestCase |
| 97 | 97 | end |
| 98 | 98 | |
| 99 | 99 | should 'not list person enterprises invisible' do |
| 100 | - c1 = fast_create(Enterprise) | |
| 101 | - c2 = fast_create(Enterprise, :visible => false) | |
| 100 | + c1 = fast_create(Enterprise, :environment_id => environment.id) | |
| 101 | + c2 = fast_create(Enterprise, :environment_id => environment.id, :visible => false) | |
| 102 | 102 | c1.add_member(person) |
| 103 | 103 | c2.add_member(person) |
| 104 | 104 | ... | ... |
test/unit/api/helpers_test.rb
| ... | ... | @@ -209,7 +209,9 @@ class APIHelpersTest < ActiveSupport::TestCase |
| 209 | 209 | serpro_client_id: '0000000000000000', |
| 210 | 210 | verify_uri: 'http://localhost/api/verify', |
| 211 | 211 | } |
| 212 | - assert_equal test_captcha("127.0.0.1", {}, environment), "Missing captcha data" | |
| 212 | + params = {} | |
| 213 | + params[:txtToken_captcha_serpro_gov_br] = '4324343' | |
| 214 | + assert_equal test_captcha("127.0.0.1", params, environment), _('Captcha text has not been filled') | |
| 213 | 215 | end |
| 214 | 216 | |
| 215 | 217 | should 'render not_found if endpoint is unavailable' do |
| ... | ... | @@ -234,6 +236,23 @@ class APIHelpersTest < ActiveSupport::TestCase |
| 234 | 236 | |
| 235 | 237 | end |
| 236 | 238 | |
| 239 | + should 'captcha serpro say Name or service not known' do | |
| 240 | + environment = Environment.new | |
| 241 | + environment.api_captcha_settings = { | |
| 242 | + enabled: true, | |
| 243 | + provider: 'serpro', | |
| 244 | + serpro_client_id: '0000000000000000', | |
| 245 | + verify_uri: 'http://someserverthatdoesnotexist.mycompanythatdoesnotexist.com/validate', | |
| 246 | + } | |
| 247 | + params = {} | |
| 248 | + params[:txtToken_captcha_serpro_gov_br] = '4324343' | |
| 249 | + params[:captcha_text] = '4324343' | |
| 250 | + logger = Logger.new(File.join(Rails.root, 'log', 'test_api.log')) | |
| 251 | + stubs(:logger).returns(logger) | |
| 252 | + assert_equal test_captcha('127.0.0.1', params, environment), 'Serpro captcha error: getaddrinfo: Name or service not known' | |
| 253 | + end | |
| 254 | + | |
| 255 | + | |
| 237 | 256 | protected |
| 238 | 257 | |
| 239 | 258 | def error!(info, status) | ... | ... |
test/unit/api/task_test.rb
| ... | ... | @@ -12,6 +12,7 @@ class TasksTest < ActiveSupport::TestCase |
| 12 | 12 | attr_accessor :person, :community, :environment |
| 13 | 13 | |
| 14 | 14 | should 'list tasks of environment' do |
| 15 | + environment.add_admin(person) | |
| 15 | 16 | task = create(Task, :requestor => person, :target => environment) |
| 16 | 17 | get "/api/v1/tasks?#{params.to_query}" |
| 17 | 18 | json = JSON.parse(last_response.body) |
| ... | ... | @@ -26,364 +27,147 @@ class TasksTest < ActiveSupport::TestCase |
| 26 | 27 | assert_equal task.id, json["task"]["id"] |
| 27 | 28 | end |
| 28 | 29 | |
| 29 | -# should 'not return environmet task if user has no permission to view it' do | |
| 30 | -# person = fast_create(Person) | |
| 31 | -# task = create(Task, :requestor => person, :target => environment) | |
| 32 | -# | |
| 33 | -# get "/api/v1/tasks/#{task.id}?#{params.to_query}" | |
| 34 | -# assert_equal 403, last_response.status | |
| 35 | -# end | |
| 36 | -# | |
| 37 | -# ############################# | |
| 38 | -# # Community Tasks # | |
| 39 | -# ############################# | |
| 40 | -# | |
| 41 | -# should 'return task by community' do | |
| 42 | -# community = fast_create(Community) | |
| 43 | -# task = create(Task, :requestor => person, :target => community) | |
| 44 | -# get "/api/v1/communities/#{community.id}/tasks/#{task.id}?#{params.to_query}" | |
| 45 | -# json = JSON.parse(last_response.body) | |
| 46 | -# assert_equal task.id, json["task"]["id"] | |
| 47 | -# end | |
| 48 | -# | |
| 49 | -# should 'not return task by community if user has no permission to view it' do | |
| 50 | -# community = fast_create(Community) | |
| 51 | -# task = create(Task, :requestor => person, :target => community) | |
| 52 | -# assert !person.is_member_of?(community) | |
| 53 | -# | |
| 54 | -# get "/api/v1/communities/#{community.id}/tasks/#{task.id}?#{params.to_query}" | |
| 55 | -# assert_equal 403, last_response.status | |
| 56 | -# end | |
| 57 | -# | |
| 58 | -## should 'not list forbidden article when listing articles by community' do | |
| 59 | -## community = fast_create(Community) | |
| 60 | -## article = fast_create(Article, :profile_id => community.id, :name => "Some thing", :published => false) | |
| 61 | -## assert !article.published? | |
| 62 | -## | |
| 63 | -## get "/api/v1/communities/#{community.id}/articles?#{params.to_query}" | |
| 64 | -## json = JSON.parse(last_response.body) | |
| 65 | -## assert_not_includes json['articles'].map {|a| a['id']}, article.id | |
| 66 | -## end | |
| 67 | -# | |
| 68 | -# should 'create task in a community' do | |
| 69 | -# community = fast_create(Community) | |
| 70 | -# give_permission(person, 'post_content', community) | |
| 71 | -# post "/api/v1/communities/#{community.id}/tasks?#{params.to_query}" | |
| 72 | -# json = JSON.parse(last_response.body) | |
| 73 | -# assert_not_nil json["task"]["id"] | |
| 74 | -# end | |
| 75 | -# | |
| 76 | -# should 'do not create article if user has no permission to post content' do | |
| 77 | -#assert false | |
| 78 | -## community = fast_create(Community) | |
| 79 | -## give_permission(user.person, 'invite_members', community) | |
| 80 | -## params[:article] = {:name => "Title"} | |
| 81 | -## post "/api/v1/communities/#{community.id}/articles?#{params.to_query}" | |
| 82 | -## assert_equal 403, last_response.status | |
| 83 | -# end | |
| 84 | -# | |
| 85 | -## should 'create article with parent' do | |
| 86 | -## community = fast_create(Community) | |
| 87 | -## community.add_member(user.person) | |
| 88 | -## article = fast_create(Article) | |
| 89 | -## | |
| 90 | -## params[:article] = {:name => "Title", :parent_id => article.id} | |
| 91 | -## post "/api/v1/communities/#{community.id}/articles?#{params.to_query}" | |
| 92 | -## json = JSON.parse(last_response.body) | |
| 93 | -## assert_equal article.id, json["article"]["parent"]["id"] | |
| 94 | -## end | |
| 95 | -# | |
| 96 | -# should 'create task defining the requestor as current profile logged in' do | |
| 97 | -# community = fast_create(Community) | |
| 98 | -# community.add_member(person) | |
| 99 | -# | |
| 100 | -# post "/api/v1/communities/#{community.id}/tasks?#{params.to_query}" | |
| 101 | -# json = JSON.parse(last_response.body) | |
| 102 | -# | |
| 103 | -# assert_equal person, Task.last.requestor | |
| 104 | -# end | |
| 105 | -# | |
| 106 | -# should 'create task defining the target as the community' do | |
| 107 | -# community = fast_create(Community) | |
| 108 | -# community.add_member(person) | |
| 109 | -# | |
| 110 | -# post "/api/v1/communities/#{community.id}/tasks?#{params.to_query}" | |
| 111 | -# json = JSON.parse(last_response.body) | |
| 112 | -# | |
| 113 | -# assert_equal community, Task.last.target | |
| 114 | -# end | |
| 115 | -# | |
| 116 | -## ############################# | |
| 117 | -## # Person Articles # | |
| 118 | -## ############################# | |
| 119 | -## | |
| 120 | -## should 'return article by person' do | |
| 121 | -## person = fast_create(Person) | |
| 122 | -## article = fast_create(Article, :profile_id => person.id, :name => "Some thing") | |
| 123 | -## get "/api/v1/people/#{person.id}/articles/#{article.id}?#{params.to_query}" | |
| 124 | -## json = JSON.parse(last_response.body) | |
| 125 | -## assert_equal article.id, json["article"]["id"] | |
| 126 | -## end | |
| 127 | -## | |
| 128 | -## should 'not return article by person if user has no permission to view it' do | |
| 129 | -## person = fast_create(Person) | |
| 130 | -## article = fast_create(Article, :profile_id => person.id, :name => "Some thing", :published => false) | |
| 131 | -## assert !article.published? | |
| 132 | -## | |
| 133 | -## get "/api/v1/people/#{person.id}/articles/#{article.id}?#{params.to_query}" | |
| 134 | -## assert_equal 403, last_response.status | |
| 135 | -## end | |
| 136 | -## | |
| 137 | -## should 'not list forbidden article when listing articles by person' do | |
| 138 | -## person = fast_create(Person) | |
| 139 | -## article = fast_create(Article, :profile_id => person.id, :name => "Some thing", :published => false) | |
| 140 | -## assert !article.published? | |
| 141 | -## get "/api/v1/people/#{person.id}/articles?#{params.to_query}" | |
| 142 | -## json = JSON.parse(last_response.body) | |
| 143 | -## assert_not_includes json['articles'].map {|a| a['id']}, article.id | |
| 144 | -## end | |
| 145 | -## | |
| 146 | -## should 'create article in a person' do | |
| 147 | -## params[:article] = {:name => "Title"} | |
| 148 | -## post "/api/v1/people/#{user.person.id}/articles?#{params.to_query}" | |
| 149 | -## json = JSON.parse(last_response.body) | |
| 150 | -## assert_equal "Title", json["article"]["title"] | |
| 151 | -## end | |
| 152 | -## | |
| 153 | -## should 'person do not create article if user has no permission to post content' do | |
| 154 | -## person = fast_create(Person) | |
| 155 | -## params[:article] = {:name => "Title"} | |
| 156 | -## post "/api/v1/people/#{person.id}/articles?#{params.to_query}" | |
| 157 | -## assert_equal 403, last_response.status | |
| 158 | -## end | |
| 159 | -## | |
| 160 | -## should 'person create article with parent' do | |
| 161 | -## article = fast_create(Article) | |
| 162 | -## | |
| 163 | -## params[:article] = {:name => "Title", :parent_id => article.id} | |
| 164 | -## post "/api/v1/people/#{user.person.id}/articles?#{params.to_query}" | |
| 165 | -## json = JSON.parse(last_response.body) | |
| 166 | -## assert_equal article.id, json["article"]["parent"]["id"] | |
| 167 | -## end | |
| 168 | -## | |
| 169 | -## should 'person create article with content type passed as parameter' do | |
| 170 | -## Article.delete_all | |
| 171 | -## params[:article] = {:name => "Title"} | |
| 172 | -## params[:content_type] = 'TextArticle' | |
| 173 | -## post "/api/v1/people/#{user.person.id}/articles?#{params.to_query}" | |
| 174 | -## json = JSON.parse(last_response.body) | |
| 175 | -## | |
| 176 | -## assert_kind_of TextArticle, Article.last | |
| 177 | -## end | |
| 178 | -## | |
| 179 | -## should 'person create article of TinyMceArticle type if no content type is passed as parameter' do | |
| 180 | -## params[:article] = {:name => "Title"} | |
| 181 | -## post "/api/v1/people/#{user.person.id}/articles?#{params.to_query}" | |
| 182 | -## json = JSON.parse(last_response.body) | |
| 183 | -## | |
| 184 | -## assert_kind_of TinyMceArticle, Article.last | |
| 185 | -## end | |
| 186 | -## | |
| 187 | -## should 'person not create article with invalid article content type' do | |
| 188 | -## params[:article] = {:name => "Title"} | |
| 189 | -## params[:content_type] = 'Person' | |
| 190 | -## post "/api/v1/people/#{user.person.id}/articles?#{params.to_query}" | |
| 191 | -## json = JSON.parse(last_response.body) | |
| 192 | -## | |
| 193 | -## assert_equal 403, last_response.status | |
| 194 | -## end | |
| 195 | -## | |
| 196 | -## should 'person create article defining the correct profile' do | |
| 197 | -## params[:article] = {:name => "Title"} | |
| 198 | -## post "/api/v1/people/#{user.person.id}/articles?#{params.to_query}" | |
| 199 | -## json = JSON.parse(last_response.body) | |
| 200 | -## | |
| 201 | -## assert_equal user.person, Article.last.profile | |
| 202 | -## end | |
| 203 | -## | |
| 204 | -## should 'person create article defining the created_by' do | |
| 205 | -## params[:article] = {:name => "Title"} | |
| 206 | -## post "/api/v1/people/#{user.person.id}/articles?#{params.to_query}" | |
| 207 | -## json = JSON.parse(last_response.body) | |
| 208 | -## | |
| 209 | -## assert_equal user.person, Article.last.created_by | |
| 210 | -## end | |
| 211 | -## | |
| 212 | -## should 'person create article defining the last_changed_by' do | |
| 213 | -## params[:article] = {:name => "Title"} | |
| 214 | -## post "/api/v1/people/#{user.person.id}/articles?#{params.to_query}" | |
| 215 | -## json = JSON.parse(last_response.body) | |
| 216 | -## | |
| 217 | -## assert_equal user.person, Article.last.last_changed_by | |
| 218 | -## end | |
| 219 | -## | |
| 220 | -## ############################# | |
| 221 | -## # Enterprise Articles # | |
| 222 | -## ############################# | |
| 223 | -## | |
| 224 | -## should 'return article by enterprise' do | |
| 225 | -## enterprise = fast_create(Enterprise) | |
| 226 | -## article = fast_create(Article, :profile_id => enterprise.id, :name => "Some thing") | |
| 227 | -## get "/api/v1/enterprises/#{enterprise.id}/articles/#{article.id}?#{params.to_query}" | |
| 228 | -## json = JSON.parse(last_response.body) | |
| 229 | -## assert_equal article.id, json["article"]["id"] | |
| 230 | -## end | |
| 231 | -## | |
| 232 | -## should 'not return article by enterprise if user has no permission to view it' do | |
| 233 | -## enterprise = fast_create(Enterprise) | |
| 234 | -## article = fast_create(Article, :profile_id => enterprise.id, :name => "Some thing", :published => false) | |
| 235 | -## assert !article.published? | |
| 236 | -## | |
| 237 | -## get "/api/v1/enterprises/#{enterprise.id}/articles/#{article.id}?#{params.to_query}" | |
| 238 | -## assert_equal 403, last_response.status | |
| 239 | -## end | |
| 240 | -## | |
| 241 | -## should 'not list forbidden article when listing articles by enterprise' do | |
| 242 | -## enterprise = fast_create(Enterprise) | |
| 243 | -## article = fast_create(Article, :profile_id => enterprise.id, :name => "Some thing", :published => false) | |
| 244 | -## assert !article.published? | |
| 245 | -## | |
| 246 | -## get "/api/v1/enterprises/#{enterprise.id}/articles?#{params.to_query}" | |
| 247 | -## json = JSON.parse(last_response.body) | |
| 248 | -## assert_not_includes json['articles'].map {|a| a['id']}, article.id | |
| 249 | -## end | |
| 250 | -## | |
| 251 | -## should 'create article in a enterprise' do | |
| 252 | -## enterprise = fast_create(Enterprise) | |
| 253 | -## give_permission(user.person, 'post_content', enterprise) | |
| 254 | -## params[:article] = {:name => "Title"} | |
| 255 | -## post "/api/v1/enterprises/#{enterprise.id}/articles?#{params.to_query}" | |
| 256 | -## json = JSON.parse(last_response.body) | |
| 257 | -## assert_equal "Title", json["article"]["title"] | |
| 258 | -## end | |
| 259 | -## | |
| 260 | -## should 'enterprise: do not create article if user has no permission to post content' do | |
| 261 | -## enterprise = fast_create(Enterprise) | |
| 262 | -## give_permission(user.person, 'invite_members', enterprise) | |
| 263 | -## params[:article] = {:name => "Title"} | |
| 264 | -## post "/api/v1/enterprises/#{enterprise.id}/articles?#{params.to_query}" | |
| 265 | -## assert_equal 403, last_response.status | |
| 266 | -## end | |
| 267 | -## | |
| 268 | -## should 'enterprise: create article with parent' do | |
| 269 | -## enterprise = fast_create(Enterprise) | |
| 270 | -## enterprise.add_member(user.person) | |
| 271 | -## article = fast_create(Article) | |
| 272 | -## | |
| 273 | -## params[:article] = {:name => "Title", :parent_id => article.id} | |
| 274 | -## post "/api/v1/enterprises/#{enterprise.id}/articles?#{params.to_query}" | |
| 275 | -## json = JSON.parse(last_response.body) | |
| 276 | -## assert_equal article.id, json["article"]["parent"]["id"] | |
| 277 | -## end | |
| 278 | -## | |
| 279 | -## should 'enterprise: create article with content type passed as parameter' do | |
| 280 | -## enterprise = fast_create(Enterprise) | |
| 281 | -## enterprise.add_member(user.person) | |
| 282 | -## | |
| 283 | -## Article.delete_all | |
| 284 | -## params[:article] = {:name => "Title"} | |
| 285 | -## params[:content_type] = 'TextArticle' | |
| 286 | -## post "/api/v1/enterprises/#{enterprise.id}/articles?#{params.to_query}" | |
| 287 | -## json = JSON.parse(last_response.body) | |
| 288 | -## | |
| 289 | -## assert_kind_of TextArticle, Article.last | |
| 290 | -## end | |
| 291 | -## | |
| 292 | -## should 'enterprise: create article of TinyMceArticle type if no content type is passed as parameter' do | |
| 293 | -## enterprise = fast_create(Enterprise) | |
| 294 | -## enterprise.add_member(user.person) | |
| 295 | -## | |
| 296 | -## params[:article] = {:name => "Title"} | |
| 297 | -## post "/api/v1/enterprises/#{enterprise.id}/articles?#{params.to_query}" | |
| 298 | -## json = JSON.parse(last_response.body) | |
| 299 | -## | |
| 300 | -## assert_kind_of TinyMceArticle, Article.last | |
| 301 | -## end | |
| 302 | -## | |
| 303 | -## should 'enterprise: not create article with invalid article content type' do | |
| 304 | -## enterprise = fast_create(Enterprise) | |
| 305 | -## enterprise.add_member(user.person) | |
| 306 | -## | |
| 307 | -## params[:article] = {:name => "Title"} | |
| 308 | -## params[:content_type] = 'Person' | |
| 309 | -## post "/api/v1/enterprises/#{enterprise.id}/articles?#{params.to_query}" | |
| 310 | -## json = JSON.parse(last_response.body) | |
| 311 | -## | |
| 312 | -## assert_equal 403, last_response.status | |
| 313 | -## end | |
| 314 | -## | |
| 315 | -## should 'enterprise: create article defining the correct profile' do | |
| 316 | -## enterprise = fast_create(Enterprise) | |
| 317 | -## enterprise.add_member(user.person) | |
| 318 | -## | |
| 319 | -## params[:article] = {:name => "Title"} | |
| 320 | -## post "/api/v1/enterprises/#{enterprise.id}/articles?#{params.to_query}" | |
| 321 | -## json = JSON.parse(last_response.body) | |
| 322 | -## | |
| 323 | -## assert_equal enterprise, Article.last.profile | |
| 324 | -## end | |
| 325 | -## | |
| 326 | -## should 'enterprise: create article defining the created_by' do | |
| 327 | -## enterprise = fast_create(Enterprise) | |
| 328 | -## enterprise.add_member(user.person) | |
| 329 | -## | |
| 330 | -## params[:article] = {:name => "Title"} | |
| 331 | -## post "/api/v1/enterprises/#{enterprise.id}/articles?#{params.to_query}" | |
| 332 | -## json = JSON.parse(last_response.body) | |
| 333 | -## | |
| 334 | -## assert_equal user.person, Article.last.created_by | |
| 335 | -## end | |
| 336 | -## | |
| 337 | -## should 'enterprise: create article defining the last_changed_by' do | |
| 338 | -## enterprise = fast_create(Enterprise) | |
| 339 | -## enterprise.add_member(user.person) | |
| 340 | -## | |
| 341 | -## params[:article] = {:name => "Title"} | |
| 342 | -## post "/api/v1/enterprises/#{enterprise.id}/articles?#{params.to_query}" | |
| 343 | -## json = JSON.parse(last_response.body) | |
| 344 | -## | |
| 345 | -## assert_equal user.person, Article.last.last_changed_by | |
| 346 | -## end | |
| 347 | -## | |
| 348 | -## should 'list article children with partial fields' do | |
| 349 | -## article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") | |
| 350 | -## child1 = fast_create(Article, :parent_id => article.id, :profile_id => user.person.id, :name => "Some thing") | |
| 351 | -## params[:fields] = [:title] | |
| 352 | -## get "/api/v1/articles/#{article.id}/children?#{params.to_query}" | |
| 353 | -## json = JSON.parse(last_response.body) | |
| 354 | -## assert_equal ['title'], json['articles'].first.keys | |
| 355 | -## end | |
| 356 | -## | |
| 357 | -## should 'suggest article children' do | |
| 358 | -## article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") | |
| 359 | -## params[:target_id] = user.person.id | |
| 360 | -## params[:article] = {:name => "Article name", :body => "Article body"} | |
| 361 | -## assert_difference "SuggestArticle.count" do | |
| 362 | -## post "/api/v1/articles/#{article.id}/children/suggest?#{params.to_query}" | |
| 363 | -## end | |
| 364 | -## json = JSON.parse(last_response.body) | |
| 365 | -## assert_equal 'SuggestArticle', json['type'] | |
| 366 | -## end | |
| 367 | -## | |
| 368 | -## should 'suggest event children' do | |
| 369 | -## article = fast_create(Article, :profile_id => user.person.id, :name => "Some thing") | |
| 370 | -## params[:target_id] = user.person.id | |
| 371 | -## params[:article] = {:name => "Article name", :body => "Article body", :type => "Event"} | |
| 372 | -## assert_difference "SuggestArticle.count" do | |
| 373 | -## post "/api/v1/articles/#{article.id}/children/suggest?#{params.to_query}" | |
| 374 | -## end | |
| 375 | -## json = JSON.parse(last_response.body) | |
| 376 | -## assert_equal 'SuggestArticle', json['type'] | |
| 377 | -## end | |
| 378 | -## | |
| 379 | -## should 'update hit attribute of article children' do | |
| 380 | -## a1 = fast_create(Article, :profile_id => user.person.id) | |
| 381 | -## a2 = fast_create(Article, :parent_id => a1.id, :profile_id => user.person.id) | |
| 382 | -## a3 = fast_create(Article, :parent_id => a1.id, :profile_id => user.person.id) | |
| 383 | -## get "/api/v1/articles/#{a1.id}/children?#{params.to_query}" | |
| 384 | -## json = JSON.parse(last_response.body) | |
| 385 | -## assert_equal [1, 1], json['articles'].map { |a| a['hits']} | |
| 386 | -## assert_equal [0, 1, 1], [a1.reload.hits, a2.reload.hits, a3.reload.hits] | |
| 387 | -## end | |
| 388 | -## | |
| 30 | + should 'not return environmet task if user has no permission to view it' do | |
| 31 | + person = fast_create(Person) | |
| 32 | + task = create(Task, :requestor => person, :target => environment) | |
| 33 | + | |
| 34 | + get "/api/v1/tasks/#{task.id}?#{params.to_query}" | |
| 35 | + assert_equal 403, last_response.status | |
| 36 | + end | |
| 37 | + | |
| 38 | + ############################# | |
| 39 | + # Community Tasks # | |
| 40 | + ############################# | |
| 41 | + | |
| 42 | + should 'return task by community' do | |
| 43 | + community = fast_create(Community) | |
| 44 | + community.add_admin(person) | |
| 45 | + | |
| 46 | + task = create(Task, :requestor => person, :target => community) | |
| 47 | + assert person.is_member_of?(community) | |
| 48 | + | |
| 49 | + get "/api/v1/communities/#{community.id}/tasks/#{task.id}?#{params.to_query}" | |
| 50 | + json = JSON.parse(last_response.body) | |
| 51 | + assert_equal task.id, json["task"]["id"] | |
| 52 | + end | |
| 53 | + | |
| 54 | + should 'not return task by community if user has no permission to view it' do | |
| 55 | + community = fast_create(Community) | |
| 56 | + task = create(Task, :requestor => person, :target => community) | |
| 57 | + assert !person.is_member_of?(community) | |
| 58 | + | |
| 59 | + get "/api/v1/communities/#{community.id}/tasks/#{task.id}?#{params.to_query}" | |
| 60 | + assert_equal 403, last_response.status | |
| 61 | + end | |
| 62 | + | |
| 63 | + should 'create task in a community' do | |
| 64 | + community = fast_create(Community) | |
| 65 | + give_permission(person, 'perform_task', community) | |
| 66 | + post "/api/v1/communities/#{community.id}/tasks?#{params.to_query}" | |
| 67 | + json = JSON.parse(last_response.body) | |
| 68 | + assert_not_nil json["task"]["id"] | |
| 69 | + end | |
| 70 | + | |
| 71 | + should 'create task defining the requestor as current profile logged in' do | |
| 72 | + community = fast_create(Community) | |
| 73 | + community.add_member(person) | |
| 74 | + | |
| 75 | + post "/api/v1/communities/#{community.id}/tasks?#{params.to_query}" | |
| 76 | + json = JSON.parse(last_response.body) | |
| 77 | + | |
| 78 | + assert_equal person, Task.last.requestor | |
| 79 | + end | |
| 80 | + | |
| 81 | + should 'create task defining the target as the community' do | |
| 82 | + community = fast_create(Community) | |
| 83 | + community.add_member(person) | |
| 84 | + | |
| 85 | + post "/api/v1/communities/#{community.id}/tasks?#{params.to_query}" | |
| 86 | + json = JSON.parse(last_response.body) | |
| 87 | + | |
| 88 | + assert_equal community, Task.last.target | |
| 89 | + end | |
| 90 | + | |
| 91 | + ############################# | |
| 92 | + # Person Tasks # | |
| 93 | + ############################# | |
| 94 | + | |
| 95 | + should 'return task by person' do | |
| 96 | + task = create(Task, :requestor => person, :target => person) | |
| 97 | + get "/api/v1/people/#{person.id}/tasks/#{task.id}?#{params.to_query}" | |
| 98 | + json = JSON.parse(last_response.body) | |
| 99 | + assert_equal task.id, json["task"]["id"] | |
| 100 | + end | |
| 101 | + | |
| 102 | + should 'not return task by person if user has no permission to view it' do | |
| 103 | + some_person = fast_create(Person) | |
| 104 | + task = create(Task, :requestor => person, :target => some_person) | |
| 105 | + | |
| 106 | + get "/api/v1/people/#{some_person.id}/tasks/#{task.id}?#{params.to_query}" | |
| 107 | + assert_equal 403, last_response.status | |
| 108 | + end | |
| 109 | + | |
| 110 | + should 'create task for person' do | |
| 111 | + post "/api/v1/people/#{person.id}/tasks?#{params.to_query}" | |
| 112 | + json = JSON.parse(last_response.body) | |
| 113 | + assert_not_nil json["task"]["id"] | |
| 114 | + end | |
| 115 | + | |
| 116 | + should 'create task for another person' do | |
| 117 | + some_person = fast_create(Person) | |
| 118 | + post "/api/v1/people/#{some_person.id}/tasks?#{params.to_query}" | |
| 119 | + json = JSON.parse(last_response.body) | |
| 120 | + | |
| 121 | + assert_equal some_person, Task.last.target | |
| 122 | + end | |
| 123 | + | |
| 124 | + should 'create task defining the target as a person' do | |
| 125 | + post "/api/v1/people/#{person.id}/tasks?#{params.to_query}" | |
| 126 | + json = JSON.parse(last_response.body) | |
| 127 | + | |
| 128 | + assert_equal person, Task.last.target | |
| 129 | + end | |
| 130 | + | |
| 131 | + ############################# | |
| 132 | + # Enterprise Tasks # | |
| 133 | + ############################# | |
| 134 | + | |
| 135 | + should 'return task by enterprise' do | |
| 136 | + enterprise = fast_create(Enterprise) | |
| 137 | + enterprise.add_admin(person) | |
| 138 | + | |
| 139 | + task = create(Task, :requestor => person, :target => enterprise) | |
| 140 | + assert person.is_member_of?(enterprise) | |
| 141 | + | |
| 142 | + get "/api/v1/enterprises/#{enterprise.id}/tasks/#{task.id}?#{params.to_query}" | |
| 143 | + json = JSON.parse(last_response.body) | |
| 144 | + assert_equal task.id, json["task"]["id"] | |
| 145 | + end | |
| 146 | + | |
| 147 | + should 'not return task by enterprise if user has no permission to view it' do | |
| 148 | + enterprise = fast_create(Enterprise) | |
| 149 | + task = create(Task, :requestor => person, :target => enterprise) | |
| 150 | + assert !person.is_member_of?(enterprise) | |
| 151 | + | |
| 152 | + get "/api/v1/enterprises/#{enterprise.id}/tasks/#{task.id}?#{params.to_query}" | |
| 153 | + assert_equal 403, last_response.status | |
| 154 | + end | |
| 155 | + | |
| 156 | + should 'create task in a enterprise' do | |
| 157 | + enterprise = fast_create(Enterprise) | |
| 158 | + give_permission(person, 'perform_task', enterprise) | |
| 159 | + post "/api/v1/enterprises/#{enterprise.id}/tasks?#{params.to_query}" | |
| 160 | + json = JSON.parse(last_response.body) | |
| 161 | + assert_not_nil json["task"]["id"] | |
| 162 | + end | |
| 163 | + | |
| 164 | + should 'create task defining the target as the enterprise' do | |
| 165 | + enterprise = fast_create(Enterprise) | |
| 166 | + enterprise.add_member(person) | |
| 167 | + | |
| 168 | + post "/api/v1/enterprises/#{enterprise.id}/tasks?#{params.to_query}" | |
| 169 | + json = JSON.parse(last_response.body) | |
| 170 | + | |
| 171 | + assert_equal enterprise, Task.last.target | |
| 172 | + end | |
| 389 | 173 | end | ... | ... |
test/unit/api/test_helper.rb
| ... | ... | @@ -9,7 +9,8 @@ class ActiveSupport::TestCase |
| 9 | 9 | end |
| 10 | 10 | |
| 11 | 11 | def login_api |
| 12 | - @user = User.create!(:login => 'testapi', :password => 'testapi', :password_confirmation => 'testapi', :email => 'test@test.org', :environment => Environment.default) | |
| 12 | + @environment = Environment.default | |
| 13 | + @user = User.create!(:login => 'testapi', :password => 'testapi', :password_confirmation => 'testapi', :email => 'test@test.org', :environment => @environment) | |
| 13 | 14 | @user.activate |
| 14 | 15 | @person = @user.person |
| 15 | 16 | |
| ... | ... | @@ -18,7 +19,7 @@ class ActiveSupport::TestCase |
| 18 | 19 | @private_token = json["private_token"] |
| 19 | 20 | @params = {:private_token => @private_token} |
| 20 | 21 | end |
| 21 | - attr_accessor :private_token, :user, :person, :params | |
| 22 | + attr_accessor :private_token, :user, :person, :params, :environment | |
| 22 | 23 | |
| 23 | 24 | private |
| 24 | 25 | ... | ... |
test/unit/approve_article_test.rb
| ... | ... | @@ -9,6 +9,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
| 9 | 9 | @profile = create_user('test_user').person |
| 10 | 10 | @article = fast_create(TextileArticle, :profile_id => @profile.id, :name => 'test name', :abstract => 'Lead of article', :body => 'This is my article') |
| 11 | 11 | @community = fast_create(Community) |
| 12 | + @community.add_member(@profile) | |
| 12 | 13 | end |
| 13 | 14 | attr_reader :profile, :article, :community |
| 14 | 15 | |
| ... | ... | @@ -251,6 +252,8 @@ class ApproveArticleTest < ActiveSupport::TestCase |
| 251 | 252 | end |
| 252 | 253 | |
| 253 | 254 | should 'not group trackers activity of article\'s creation' do |
| 255 | + other_community = fast_create(Community) | |
| 256 | + other_community.add_member(profile) | |
| 254 | 257 | ActionTracker::Record.delete_all |
| 255 | 258 | |
| 256 | 259 | article = fast_create(TextileArticle) |
| ... | ... | @@ -262,20 +265,20 @@ class ApproveArticleTest < ActiveSupport::TestCase |
| 262 | 265 | a.finish |
| 263 | 266 | |
| 264 | 267 | article = fast_create(TextileArticle) |
| 265 | - other_community = fast_create(Community) | |
| 266 | 268 | a = create(ApproveArticle, :name => 'another bar', :article => article, :target => other_community, :requestor => profile) |
| 267 | 269 | a.finish |
| 268 | 270 | assert_equal 3, ActionTracker::Record.count |
| 269 | 271 | end |
| 270 | 272 | |
| 271 | 273 | should 'not create trackers activity when updating articles' do |
| 274 | + other_community = fast_create(Community) | |
| 275 | + other_community.add_member(profile) | |
| 272 | 276 | ActionTracker::Record.delete_all |
| 273 | 277 | article1 = fast_create(TextileArticle) |
| 274 | 278 | a = create(ApproveArticle, :name => 'bar', :article => article1, :target => community, :requestor => profile) |
| 275 | 279 | a.finish |
| 276 | 280 | |
| 277 | 281 | article2 = fast_create(TinyMceArticle) |
| 278 | - other_community = fast_create(Community) | |
| 279 | 282 | a = create(ApproveArticle, :name => 'another bar', :article => article2, :target => other_community, :requestor => profile) |
| 280 | 283 | a.finish |
| 281 | 284 | assert_equal 2, ActionTracker::Record.count |
| ... | ... | @@ -283,7 +286,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
| 283 | 286 | assert_no_difference 'ActionTracker::Record.count' do |
| 284 | 287 | published = article1.class.last |
| 285 | 288 | published.name = 'foo';published.save! |
| 286 | - | |
| 289 | + | |
| 287 | 290 | published = article2.class.last |
| 288 | 291 | published.name = 'another foo';published.save! |
| 289 | 292 | end |
| ... | ... | @@ -307,7 +310,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
| 307 | 310 | person = fast_create(Person) |
| 308 | 311 | person.stubs(:notification_emails).returns(['target@example.org']) |
| 309 | 312 | |
| 310 | - a = create(ApproveArticle, :article => article, :target => person, :requestor => profile) | |
| 313 | + a = create(ApproveArticle, :article => article, :target => person, :requestor => person) | |
| 311 | 314 | a.finish |
| 312 | 315 | |
| 313 | 316 | approved_article = person.articles.find_by_name(article.name) |
| ... | ... | @@ -427,7 +430,7 @@ class ApproveArticleTest < ActiveSupport::TestCase |
| 427 | 430 | article = fast_create(Article) |
| 428 | 431 | profile.domains << create(Domain, :name => 'example.org') |
| 429 | 432 | assert_nothing_raised do |
| 430 | - create(ApproveArticle, :article => article, :target => profile, :requestor => community) | |
| 433 | + create(ApproveArticle, :article => article, :target => profile, :requestor => profile) | |
| 431 | 434 | end |
| 432 | 435 | end |
| 433 | 436 | |
| ... | ... | @@ -440,4 +443,47 @@ class ApproveArticleTest < ActiveSupport::TestCase |
| 440 | 443 | assert_equal article, LinkArticle.last.reference_article |
| 441 | 444 | end |
| 442 | 445 | |
| 446 | + should 'not allow non-person requestor' do | |
| 447 | + task = ApproveArticle.new(:requestor => Community.new) | |
| 448 | + task.valid? | |
| 449 | + assert task.invalid?(:requestor) | |
| 450 | + end | |
| 451 | + | |
| 452 | + should 'allow only self requestors when the target is a person' do | |
| 453 | + person = fast_create(Person) | |
| 454 | + another_person = fast_create(Person) | |
| 455 | + | |
| 456 | + t1 = ApproveArticle.new(:requestor => person, :target => person) | |
| 457 | + t2 = ApproveArticle.new(:requestor => another_person, :target => person) | |
| 458 | + | |
| 459 | + assert t1.valid? | |
| 460 | + assert !t2.valid? | |
| 461 | + assert t2.invalid?(:requestor) | |
| 462 | + end | |
| 463 | + | |
| 464 | + should 'allow only members to be requestors when target is a community' do | |
| 465 | + community = fast_create(Community) | |
| 466 | + member = fast_create(Person) | |
| 467 | + community.add_member(member) | |
| 468 | + non_member = fast_create(Person) | |
| 469 | + | |
| 470 | + t1 = ApproveArticle.new(:requestor => member, :target => community) | |
| 471 | + t2 = ApproveArticle.new(:requestor => non_member, :target => community) | |
| 472 | + | |
| 473 | + assert t1.valid? | |
| 474 | + assert !t2.valid? | |
| 475 | + assert t2.invalid?(:requestor) | |
| 476 | + end | |
| 477 | + | |
| 478 | + should 'allow any user to be requestor whe the target is the portal community' do | |
| 479 | + community = fast_create(Community) | |
| 480 | + environment = community.environment | |
| 481 | + environment.portal_community = community | |
| 482 | + environment.save! | |
| 483 | + person = fast_create(Person) | |
| 484 | + | |
| 485 | + task = ApproveArticle.new(:requestor => person, :target => community) | |
| 486 | + | |
| 487 | + assert task.valid? | |
| 488 | + end | |
| 443 | 489 | end | ... | ... |
test/unit/article_test.rb
| ... | ... | @@ -913,6 +913,7 @@ class ArticleTest < ActiveSupport::TestCase |
| 913 | 913 | should 'not doubly escape quotes in the name' do |
| 914 | 914 | person = fast_create(Person) |
| 915 | 915 | community = fast_create(Community) |
| 916 | + community.add_member(profile) | |
| 916 | 917 | article = fast_create(Article, :name => 'article name', :profile_id => person.id) |
| 917 | 918 | a = create(ApproveArticle, :article => article, :target => community, :requestor => profile) |
| 918 | 919 | a.finish | ... | ... |
test/unit/environment_test.rb
| ... | ... | @@ -759,13 +759,10 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 759 | 759 | |
| 760 | 760 | should 'set custom_person_fields with its dependecies' do |
| 761 | 761 | env = Environment.new |
| 762 | - env.custom_person_fields = {'cell_phone' => {'required' => 'true', 'active' => '', 'signup' => ''}, 'comercial_phone'=> {'required' => '', 'active' => 'true', 'signup' => '' }, 'description' => {'required' => '', 'active' => '', 'signup' => 'true'}} | |
| 762 | + data = {'cell_phone' => {'required' => 'true', 'active' => '', 'signup' => ''}, 'comercial_phone'=> {'required' => '', 'active' => 'true', 'signup' => '' }, 'description' => {'required' => '', 'active' => '', 'signup' => 'true'}} | |
| 763 | + env.custom_person_fields = data | |
| 763 | 764 | |
| 764 | - assert_equal({'cell_phone' => {'required' => 'true', 'active' => 'true', 'signup' => 'true'}, 'comercial_phone'=> {'required' => '', 'active' => 'true', 'signup' => '' }, 'description' => {'required' => '', 'active' => 'true', 'signup' => 'true'}}, env.custom_person_fields) | |
| 765 | - end | |
| 766 | - | |
| 767 | - should 'have no custom_person_fields by default' do | |
| 768 | - assert_equal({}, Environment.new.custom_person_fields) | |
| 765 | + assert(env.custom_person_fields.merge(data) == env.custom_person_fields) | |
| 769 | 766 | end |
| 770 | 767 | |
| 771 | 768 | should 'not set in custom_person_fields if not in person.fields' do |
| ... | ... | @@ -773,7 +770,8 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 773 | 770 | Person.stubs(:fields).returns(['cell_phone', 'comercial_phone']) |
| 774 | 771 | |
| 775 | 772 | env.custom_person_fields = { 'birth_date' => {'required' => 'true', 'active' => 'true'}, 'cell_phone' => {'required' => 'true', 'active' => 'true'}} |
| 776 | - assert_equal({'cell_phone' => {'required' => 'true','signup' => 'true', 'active' => 'true'}}, env.custom_person_fields) | |
| 773 | + expected_hash = {'cell_phone' => {'required' => 'true', 'active' => 'true', 'signup' => 'true'}} | |
| 774 | + assert(env.custom_person_fields.merge(expected_hash) == env.custom_person_fields) | |
| 777 | 775 | assert ! env.custom_person_fields.keys.include?('birth_date') |
| 778 | 776 | end |
| 779 | 777 | |
| ... | ... | @@ -782,7 +780,8 @@ class EnvironmentTest < ActiveSupport::TestCase |
| 782 | 780 | Person.stubs(:fields).returns(['cell_phone', 'schooling']) |
| 783 | 781 | |
| 784 | 782 | env.custom_person_fields = { 'schooling' => {'required' => 'true', 'active' => 'true'}} |
| 785 | - assert_equal({'schooling' => {'required' => 'true', 'signup' => 'true', 'active' => 'true'}, 'schooling_status' => {'required' => 'true', 'signup' => 'true', 'active' => 'true'}}, env.custom_person_fields) | |
| 783 | + expected_hash = {'schooling' => {'required' => 'true', 'active' => 'true', 'signup' => 'true'}, 'schooling_status' => {'required' => 'true', 'signup' => 'true', 'active' => 'true'}} | |
| 784 | + assert(env.custom_person_fields.merge(expected_hash) == env.custom_person_fields) | |
| 786 | 785 | assert ! env.custom_person_fields.keys.include?('birth_date') |
| 787 | 786 | end |
| 788 | 787 | ... | ... |
test/unit/folder_test.rb
| ... | ... | @@ -93,6 +93,7 @@ class FolderTest < ActiveSupport::TestCase |
| 93 | 93 | image = UploadedFile.create!(:profile => person, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
| 94 | 94 | |
| 95 | 95 | community = fast_create(Community) |
| 96 | + community.add_member(person) | |
| 96 | 97 | folder = fast_create(Folder, :profile_id => community.id) |
| 97 | 98 | a = create(ApproveArticle, :article => image, :target => community, :requestor => person, :article_parent => folder) |
| 98 | 99 | a.finish | ... | ... |
test/unit/gallery_test.rb
| ... | ... | @@ -101,6 +101,7 @@ class GalleryTest < ActiveSupport::TestCase |
| 101 | 101 | i = UploadedFile.create!(:profile => p, :uploaded_data => fixture_file_upload('/files/rails.png', 'image/png')) |
| 102 | 102 | |
| 103 | 103 | c = fast_create(Community) |
| 104 | + c.add_member(p) | |
| 104 | 105 | gallery = fast_create(Gallery, :profile_id => c.id) |
| 105 | 106 | |
| 106 | 107 | a = create(ApproveArticle, :article => i, :target => c, :requestor => p, :article_parent => gallery) | ... | ... |
test/unit/scrap_test.rb
| ... | ... | @@ -218,7 +218,7 @@ class ScrapTest < ActiveSupport::TestCase |
| 218 | 218 | should "update the scrap on reply creation" do |
| 219 | 219 | person = create_user.person |
| 220 | 220 | s = fast_create(Scrap, :updated_at => DateTime.parse('2010-01-01')) |
| 221 | - assert_equal DateTime.parse('2010-01-01'), s.updated_at.strftime('%Y-%m-%d') | |
| 221 | + assert_equal DateTime.parse('2010-01-01'), s.updated_at | |
| 222 | 222 | DateTime.stubs(:now).returns(DateTime.parse('2010-09-07')) |
| 223 | 223 | s1 = create(Scrap, :content => 'some content', :sender => person, :receiver => person, :scrap_id => s.id) |
| 224 | 224 | s.reload | ... | ... |
util/debian-install/README.md
| 1 | 1 | This directory contains the basic structure to test the installation of |
| 2 | 2 | Noosfero debian packages, using a fresh Vagrant VM and packages built in |
| 3 | 3 | ${NOOSFEROROOT}/pkg/. |
| 4 | + | |
| 5 | +To perform a test, do | |
| 6 | + | |
| 7 | +``` | |
| 8 | +$ cd /path/to/noosfero | |
| 9 | +$ rake noosfero:deb | |
| 10 | +$ cd util/debian-install/ | |
| 11 | +$ vagrant up | |
| 12 | +``` | |
| 13 | + | |
| 14 | +To reset the environment in preparation for a new test, destroy the VM and | |
| 15 | +remove any local `*.deb` files : | |
| 16 | + | |
| 17 | +``` | |
| 18 | +$ cd util/debian-install/ | |
| 19 | +$ vagrant halt | |
| 20 | +$ vagrant destroy | |
| 21 | +$ rm -f *.deb | |
| 22 | +``` | ... | ... |
util/debian-install/Vagrantfile
| ... | ... | @@ -5,7 +5,7 @@ |
| 5 | 5 | VAGRANTFILE_API_VERSION = "2" |
| 6 | 6 | |
| 7 | 7 | require 'fileutils' |
| 8 | -debs = `find ../../pkg/ -name '*.deb' | sort -t _ -V | tail -2`.split | |
| 8 | +debs = `find ../../pkg/ -name '*.deb' | sort -t _ -V`.split | |
| 9 | 9 | if debs.empty? |
| 10 | 10 | puts "W: no debs built in ../../pkg/; will either install existing local" |
| 11 | 11 | puts " ones, or the ones from the remote repository" |
| ... | ... | @@ -16,7 +16,7 @@ else |
| 16 | 16 | |
| 17 | 17 | local_debs.delete(fn) |
| 18 | 18 | |
| 19 | - if File.stat(f) != File.stat(fn) | |
| 19 | + if !File.exist?(fn) || File.stat(f) != File.stat(fn) | |
| 20 | 20 | FileUtils::Verbose.rm_f(fn) |
| 21 | 21 | FileUtils::Verbose.ln f, '.' |
| 22 | 22 | end | ... | ... |