Commit 9461b05ba9b4eaf199ae01a36ae15d7fee3a23f2

Authored by Weblate
2 parents c02f6e44 3ec38214

Merge remote-tracking branch 'origin/master'

app/controllers/my_profile/profile_editor_controller.rb
... ... @@ -16,14 +16,16 @@ class ProfileEditorController < MyProfileController
16 16 if request.post?
17 17 params[:profile_data][:fields_privacy] ||= {} if profile.person? && params[:profile_data].is_a?(Hash)
18 18 Profile.transaction do
19   - Image.transaction do
20   - if @profile_data.update_attributes(params[:profile_data])
21   - redirect_to :action => 'index', :profile => profile.identifier
22   - else
23   - profile.identifier = params[:profile] if profile.identifier.blank?
  19 + Image.transaction do
  20 + begin
  21 + @plugins.dispatch(:profile_editor_transaction_extras)
  22 + @profile_data.update_attributes!(params[:profile_data])
  23 + redirect_to :action => 'index', :profile => profile.identifier
  24 + rescue Exception => ex
  25 + profile.identifier = params[:profile] if profile.identifier.blank?
  26 + end
24 27 end
25 28 end
26   - end
27 29 end
28 30 end
29 31  
... ...
app/views/profile_editor/_person_form.html.erb
... ... @@ -27,6 +27,10 @@
27 27 <%= optional_field(@person, 'district', labelled_form_field(_('District'), text_field(:profile_data, :district, :rel => _('District')))) %>
28 28 <%= optional_field(@person, 'image', labelled_form_field(_('Image'), file_field(:file, :image, :rel => _('Image')))) %>
29 29  
  30 +<% @plugins.dispatch(:extra_optional_fields).each do |field| %>
  31 + <%= optional_field(@person, field[:name], labelled_form_field(field[:label], text_field(field[:object_name], field[:method], :rel => field[:label], :value => field[:value]))) %>
  32 +<% end %>
  33 +
30 34 <% optional_field(@person, 'schooling') do %>
31 35 <div class="formfieldline">
32 36 <label class='formlabel' for='profile_data_schooling'><%= _('Schooling') %></label>
... ...
features/step_definitions/noosfero_steps.rb
... ... @@ -762,3 +762,11 @@ When /^I confirm the &quot;(.*)&quot; dialog$/ do |confirmation|
762 762 assert_equal confirmation, a.text
763 763 a.accept
764 764 end
  765 +
  766 +Given /^the field (.*) is public for all users$/ do |field|
  767 + Person.all.each do |person|
  768 + person.fields_privacy = Hash.new if person.fields_privacy.nil?
  769 + person.fields_privacy[field] = "public"
  770 + person.save!
  771 + end
  772 +end
765 773 \ No newline at end of file
... ...
lib/noosfero/plugin.rb
... ... @@ -531,6 +531,18 @@ class Noosfero::Plugin
531 531 nil
532 532 end
533 533  
  534 + # -> Perform extra transactions related to profile in profile editor
  535 + # returns = true in success or raise and exception if it could not update the data
  536 + def profile_editor_transaction_extras
  537 + nil
  538 + end
  539 +
  540 + # -> Return a list of hashs with the needed information to create optional fields
  541 + # returns = a list of hashs as {:name => "string", :label => "string", :object_name => :key, :method => :key}
  542 + def extra_optional_fields
  543 + []
  544 + end
  545 +
534 546 # -> Adds additional blocks to profiles and environments.
535 547 # Your plugin must implements a class method called 'extra_blocks'
536 548 # that returns a hash with the following syntax.
... ...
plugins/lattes_curriculum/README.md 0 → 100644
... ... @@ -0,0 +1,45 @@
  1 +README - Lattes Curriculum (LattesCurriculum Plugin)
  2 +================================
  3 +
  4 +Lattes Curriculum is a plugin that allow users to show their academic informations in the wall, extracted from CNPQ's lattes plataform
  5 +
  6 +INSTALL
  7 +=======
  8 +
  9 +Enable Plugin
  10 +-------------
  11 +
  12 +Also, you need to enable LattesCurriculum Plugin on your Noosfero:
  13 +
  14 +cd <your_noosfero_dir>
  15 +./script/noosfero-plugins enable lattes_curriculum
  16 +
  17 +Active Plugin
  18 +-------------
  19 +
  20 +As a Noosfero administrator user, go to administrator panel:
  21 +
  22 +- Click on "Enable/disable plugins" option
  23 +- Click on "LattesCurriculumPlugin" check-box
  24 +
  25 +Running LattesCurriculum tests
  26 +--------------------
  27 +
  28 +$ rake test:noosfero_plugins:lattes_curriculum
  29 +
  30 +LICENSE
  31 +=======
  32 +
  33 +Copyright (c) The Author developers.
  34 +
  35 +See Noosfero license.
  36 +
  37 +
  38 +AUTHORS
  39 +=======
  40 +
  41 +Jose Pedro (1jpsneto at gmail.com)
  42 +Thiago Kairala (thiagor.kairala at gmail.com)
  43 +Ana Paula Vargas (anapaulavnoronha at gmail.com)
  44 +Leandro Veloso (leandrovelosorodrigues at gmail.com)
  45 +Arthur Del Esposte (arthurmde at gmail.com)
0 46 \ No newline at end of file
... ...
plugins/lattes_curriculum/db/migrate/20140814210103_create_academic_infos.rb 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +class CreateAcademicInfos < ActiveRecord::Migration
  2 + def self.up
  3 + create_table :academic_infos do |t|
  4 + t.references :person
  5 + t.column :lattes_url, :string
  6 + end
  7 + end
  8 +
  9 + def self.down
  10 + drop_table :academic_infos
  11 + end
  12 +end
... ...
plugins/lattes_curriculum/features/lattes_curriculum.feature 0 → 100644
... ... @@ -0,0 +1,49 @@
  1 +Feature: import lattes information
  2 + As an user
  3 + I want to inform my lattes url address
  4 + So that I can import my academic informations automatically
  5 +
  6 + Background:
  7 + Given "LattesCurriculumPlugin" plugin is enabled
  8 + And I am logged in as admin
  9 + And I go to /admin/plugins
  10 + And I check "Lattes Curriculum Plugin"
  11 + And I press "Save changes"
  12 + And I go to /admin/features/manage_fields
  13 + Given I follow "Person's fields"
  14 + And I check "person_fields_lattes_url_active"
  15 + And I check "person_fields_lattes_url_signup"
  16 + And I press "save_person_fields"
  17 +
  18 + Scenario: Don't accept edit the profile with invalid lattes url
  19 + Given I am on admin_user's control panel
  20 + When I follow "Edit Profile"
  21 + And I fill in "Lattes URL" with "http://youtube.com.br/"
  22 + And I press "Save"
  23 + Then I should see "Academic info lattes url is invalid"
  24 +
  25 + Scenario: Import lattes informations
  26 + Given I am on admin_user's control panel
  27 + And the field lattes_url is public for all users
  28 + When I follow "Edit Profile"
  29 + And I fill in "Lattes URL" with "http://lattes.cnpq.br/2864976228727880"
  30 + And I press "Save"
  31 + And I go to /profile/admin_user#lattes_tab
  32 + Then I should see "Endereço para acessar este CV: http://lattes.cnpq.br/2864976228727880"
  33 +
  34 + Scenario: Don't show lattes informations for blank lattes urls
  35 + Given I am on admin_user's control panel
  36 + And the field lattes_url is public for all users
  37 + When I follow "Edit Profile"
  38 + And I press "Save"
  39 + And I go to /profile/admin_user
  40 + Then I should not see "Lattes"
  41 +
  42 + Scenario: Inform problem if the informed lattes doesn't exist
  43 + Given I am on admin_user's control panel
  44 + And the field lattes_url is public for all users
  45 + When I follow "Edit Profile"
  46 + And I fill in "Lattes URL" with "http://lattes.cnpq.br/123456"
  47 + And I press "Save"
  48 + And I go to /profile/admin_user#lattes_tab
  49 + Then I should see "Lattes not found. Please, make sure the informed URL is correct."
0 50 \ No newline at end of file
... ...
plugins/lattes_curriculum/lib/academic_info.rb 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +class AcademicInfo < ActiveRecord::Base
  2 +
  3 + belongs_to :person
  4 +
  5 + attr_accessible :lattes_url
  6 + validate :lattes_url_validate?
  7 +
  8 + def lattes_url_validate?
  9 + unless AcademicInfo.matches?(self.lattes_url)
  10 + self.errors.add(:lattes_url, _(" is invalid."))
  11 + end
  12 + end
  13 +
  14 + def self.matches?(info)
  15 + lattes = nil
  16 + if info.class == String
  17 + lattes = info
  18 + elsif info.class == Hash
  19 + lattes = info[:lattes_url]
  20 + end
  21 + return lattes.blank? || lattes =~ /^http:\/\/lattes.cnpq.br\/\d+$/
  22 + end
  23 +end
... ...
plugins/lattes_curriculum/lib/ext/person.rb 0 → 100755
... ... @@ -0,0 +1,32 @@
  1 +require_dependency 'person'
  2 +
  3 +class Person
  4 +
  5 + attr_accessible :lattes_url, :academic_info_attributes
  6 +
  7 + has_one :academic_info
  8 +
  9 + after_destroy do |person|
  10 + if !person.environment.nil? &&
  11 +person.environment.plugin_enabled?(LattesCurriculumPlugin) &&
  12 +!person.academic_info.nil?
  13 + person.academic_info.destroy
  14 + end
  15 + end
  16 +
  17 + accepts_nested_attributes_for :academic_info
  18 +
  19 + def lattes_url
  20 + if self.environment && self.environment.plugin_enabled?(LattesCurriculumPlugin)
  21 + self.academic_info.nil? ? nil : self.academic_info.lattes_url
  22 + end
  23 + end
  24 +
  25 + def lattes_url= value
  26 + if self.environment && self.environment.plugin_enabled?(LattesCurriculumPlugin)
  27 + self.academic_info.lattes_url = value unless self.academic_info.nil?
  28 + end
  29 + end
  30 +
  31 + FIELDS << "lattes_url"
  32 +end
... ...
plugins/lattes_curriculum/lib/html_parser.rb 0 → 100755
... ... @@ -0,0 +1,64 @@
  1 +require 'rubygems'
  2 +require 'nokogiri'
  3 +require 'open-uri'
  4 +
  5 +Encoding.default_external = Encoding::UTF_8
  6 +Encoding.default_internal = Encoding::UTF_8
  7 +
  8 +class Html_parser
  9 + def get_html(lattes_link = "")
  10 + begin
  11 + page = Nokogiri::HTML(open(lattes_link), nil, "UTF-8")
  12 + page = page.css(".main-content").to_s()
  13 + page = remove_class_tooltip(page)
  14 + page = remove_img(page)
  15 + page = remove_select(page)
  16 + page = remove_footer(page)
  17 + page = remove_further_informations(page)
  18 + rescue OpenURI::HTTPError => e
  19 + page = _("Lattes not found. Please, make sure the informed URL is correct.")
  20 + rescue Timeout::Error => e
  21 + page = _("Lattes Platform is unreachable. Please, try it later.")
  22 + end
  23 + end
  24 +
  25 + def remove_class_tooltip(page = "")
  26 + while page.include? 'class="tooltip"' do
  27 + page['class="tooltip"'] = 'class="link_not_to_mark"'
  28 + end
  29 +
  30 + return page
  31 + end
  32 +
  33 + def remove_img(page = "")
  34 + fist_part_to_keep, *rest = page.split('<img')
  35 + second_part = rest.join(" ")
  36 + part_to_throw_away, *after_img = second_part.split('>',2)
  37 + page = fist_part_to_keep + after_img.join(" ")
  38 + end
  39 +
  40 + def remove_select(page = "")
  41 + while page.include? '<label' do
  42 + first_part_to_keep, *rest = page.split('<label')
  43 + second_part = rest.join(" ")
  44 + part_to_throw_away, *after_img = second_part.split('</select>')
  45 + page = first_part_to_keep + after_img.join(" ")
  46 + end
  47 +
  48 + return page
  49 + end
  50 +
  51 + def remove_footer(page = "")
  52 + first_part_to_keep, *rest = page.split('<div class="rodape-cv">')
  53 + second_part = rest.join(" ")
  54 + part_to_throw_away, *after_img = second_part.split('Imprimir Curr&iacute;culo</a>')
  55 + page = first_part_to_keep + after_img.join(" ")
  56 + end
  57 +
  58 + def remove_further_informations(page = "")
  59 + first_part_to_keep, *rest = page.split('<a name="OutrasI')
  60 + second_part = rest.join(" ")
  61 + part_to_throw_away, *after_img = second_part.split('</div>',2)
  62 + page = first_part_to_keep + after_img.join(" ")
  63 + end
  64 +end
... ...
plugins/lattes_curriculum/lib/lattes_curriculum_plugin.rb 0 → 100755
... ... @@ -0,0 +1,139 @@
  1 +class LattesCurriculumPlugin < Noosfero::Plugin
  2 +
  3 + def self.plugin_name
  4 + "Lattes Curriculum Plugin"
  5 + end
  6 +
  7 + def self.plugin_description
  8 + _("A plugin that imports the lattes curriculum into the users profiles")
  9 + end
  10 +
  11 + def js_files
  12 + ["singup_complement.js"]
  13 + end
  14 +
  15 + def stylesheet?
  16 + true
  17 + end
  18 +
  19 + def extra_optional_fields
  20 + fields = []
  21 +
  22 + lattes_url = {
  23 + :name => 'lattes_url',
  24 + :label => 'Lattes URL',
  25 + :object_name => :academic_infos,
  26 + :method => :lattes_url,
  27 + :value => context.profile.nil? ? "" : context.profile.academic_info.lattes_url
  28 + }
  29 +
  30 + fields << lattes_url
  31 +
  32 + return fields
  33 + end
  34 +
  35 + def profile_tabs
  36 + if show_lattes_tab?
  37 + href = context.profile.academic_info.lattes_url
  38 + html_parser = Html_parser.new
  39 + {
  40 + :title => _("Lattes"),
  41 + :id => 'lattes_tab',
  42 + :content => lambda{html_parser.get_html(href)},
  43 + :start => false
  44 + }
  45 + end
  46 + end
  47 +
  48 + def profile_editor_transaction_extras
  49 + if context.profile.person?
  50 + if context.params.has_key?(:academic_infos)
  51 + academic_info_transaction
  52 + end
  53 + end
  54 + end
  55 +
  56 + def profile_editor_controller_filters
  57 + validate_lattes_url_block = proc do
  58 + if request.post?
  59 + if !params[:academic_infos].blank?
  60 + @profile_data = profile
  61 +
  62 + academic_infos = {"academic_info_attributes" => params[:academic_infos]}
  63 +
  64 + params_profile_data = params[:profile_data]
  65 + params_profile_data = params_profile_data.merge(academic_infos)
  66 +
  67 + @profile_data.attributes = params_profile_data
  68 + @profile_data.valid?
  69 +
  70 + @possible_domains = profile.possible_domains
  71 +
  72 + unless AcademicInfo.matches?(params[:academic_infos])
  73 + @profile_data.errors.add(:lattes_url, _(' Invalid lattes url'))
  74 + render :action => :edit, :profile => profile.identifier
  75 + end
  76 + end
  77 + end
  78 + end
  79 +
  80 + create_academic_info_block = proc do
  81 + if profile && profile.person? && profile.academic_info.nil?
  82 + profile.academic_info = AcademicInfo.new
  83 + end
  84 + end
  85 +
  86 + [{:type => 'before_filter',
  87 + :method_name => 'validate_lattes_url',
  88 + :options => {:only => 'edit'},
  89 + :block => validate_lattes_url_block },
  90 + {:type => 'before_filter',
  91 + :method_name => 'create_academic_info',
  92 + :options => {:only => 'edit'},
  93 + :block => create_academic_info_block }]
  94 + end
  95 +
  96 + def account_controller_filters
  97 + validate_lattes_url_block = proc do
  98 + if request.post?
  99 + params[:profile_data] ||= {}
  100 + params[:profile_data][:academic_info_attributes] = params[:academic_infos]
  101 +
  102 + if !params[:academic_infos].blank? && !AcademicInfo.matches?(params[:academic_infos])
  103 + @person = Person.new(params[:profile_data])
  104 + @person.environment = environment
  105 + @user = User.new(params[:user])
  106 + @person.errors.add(:lattes_url, _(' Invalid lattes url'))
  107 + render :action => :signup
  108 + end
  109 + end
  110 + end
  111 +
  112 + create_academic_info_block = proc do
  113 + if profile && profile.person? && profile.academic_info.nil?
  114 + profile.academic_info = AcademicInfo.new
  115 + end
  116 + end
  117 +
  118 + [{:type => 'before_filter',
  119 + :method_name => 'validate_lattes_url',
  120 + :options => {:only => 'signup'},
  121 + :block => validate_lattes_url_block },
  122 + {:type => 'before_filter',
  123 + :method_name => 'create_academic_info',
  124 + :options => {:only => 'edit'},
  125 + :block => create_academic_info_block }]
  126 + end
  127 +
  128 + protected
  129 +
  130 + def academic_info_transaction
  131 + AcademicInfo.transaction do
  132 + context.profile.academic_info.update_attributes!(context.params[:academic_infos])
  133 + end
  134 + end
  135 +
  136 + def show_lattes_tab?
  137 + return context.profile.person? && !context.profile.academic_info.nil? && !context.profile.academic_info.lattes_url.blank? && context.profile.public_fields.include?("lattes_url")
  138 + end
  139 +end
... ...
plugins/lattes_curriculum/public/images/grey-bg.png 0 → 100644
... ... @@ -0,0 +1,12 @@
  1 +8950 4e47 0d0a 1a0a 0000 000d 4948 4452
  2 +0000 0009 0000 0027 0806 0000 00dd 3762
  3 +5600 0000 0173 5247 4200 aece 1ce9 0000
  4 +0006 624b 4744 00ff 00ff 00ff a0bd a793
  5 +0000 0009 7048 5973 0000 0dd7 0000 0dd7
  6 +0142 289b 7800 0000 0774 494d 4507 dc05
  7 +040f 1a01 22dc e3a3 0000 003b 4944 4154
  8 +38cb 635c 30bd f53f 0301 c0c4 4004 188c
  9 +8a58 18fe 13a3 8808 552c ff87 6810 101b
  10 +4eff 87af efa8 1704 c33e 1550 29b7 0c4a
  11 +dffd 1fa2 b905 009c 4210 1067 9fec 9d00
  12 +0000 0049 454e 44ae 4260 82
0 13 \ No newline at end of file
... ...
plugins/lattes_curriculum/public/singup_complement.js 0 → 100644
... ... @@ -0,0 +1,15 @@
  1 +jQuery(function($){
  2 + $(document).ready(function(){
  3 + $('#lattes_id_field').blur(function(){
  4 + var value = this.value
  5 + })
  6 +
  7 + $('#lattes_id_field').focus(function(){
  8 + $('#lattes-id-balloon').fadeIn('slow')
  9 + })
  10 +
  11 + $('#lattes_id_field').blur(function(){
  12 + $('#lattes-id-balloon').fadeOut('slow')
  13 + })
  14 + })
  15 +})
0 16 \ No newline at end of file
... ...
plugins/lattes_curriculum/public/style.css 0 → 100644
... ... @@ -0,0 +1,37 @@
  1 +#signup-form label[for="lattes_id_field"],
  2 +{
  3 + display: block;
  4 +}
  5 +
  6 +#signup-form small#lattes-id-balloon
  7 +{
  8 + display: none;
  9 + width: 142px;
  10 + height: 69px;
  11 + color: #FFFFFF;
  12 + font-weight: bold;
  13 + font-size: 11px;
  14 + padding: 5px 10px 45px 10px;
  15 + margin: 0;
  16 + line-height: 1.5em;
  17 + background: transparent url(/images/gray-balloon.png) bottom center no-repeat;
  18 + position: absolute;
  19 + z-index: 2;
  20 + right: -150px;
  21 + top: -75px;
  22 +}
  23 +
  24 +#signup-form .formfield.checking {
  25 + border-color: transparent;
  26 + background-image: none;
  27 +}
  28 +
  29 +#signup-form small#lattes-id-balloon
  30 +{
  31 + top: -80px;
  32 +}
  33 +
  34 +#signup-form #signup-lattes-id
  35 +{
  36 + position: relative;
  37 +}
... ...
plugins/lattes_curriculum/test/unit/academic_info_test.rb 0 → 100644
... ... @@ -0,0 +1,23 @@
  1 +require "test_helper"
  2 +
  3 +class AcademicInfoTest < ActiveSupport::TestCase
  4 +
  5 + def setup
  6 + @academic_info = AcademicInfo.new
  7 + end
  8 +
  9 + should 'not ve invalid lattes url' do
  10 + @academic_info.lattes_url = "http://softwarelivre.org/"
  11 + assert !@academic_info.save
  12 + end
  13 +
  14 + should 'accept blank lattes url' do
  15 + @academic_info.lattes_url = ""
  16 + assert @academic_info.save
  17 + end
  18 +
  19 + should 'save with correct lattes url' do
  20 + @academic_info.lattes_url = "http://lattes.cnpq.br/2193972715230641"
  21 + assert @academic_info.save
  22 + end
  23 +end
... ...
plugins/lattes_curriculum/test/unit/html_parser_test.rb 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +#!/bin/env ruby
  2 +# encoding: utf-8
  3 +
  4 +require "test_helper"
  5 +
  6 +class HtmlParserTest < ActiveSupport::TestCase
  7 +
  8 + def setup
  9 + @parser = Html_parser.new
  10 + end
  11 +
  12 + should 'be not nil the instance' do
  13 + assert_not_nil @parser
  14 + end
  15 +
  16 + should 'be not nil the return get_html' do
  17 + result = @parser.get_html("http://lattes.cnpq.br/2193972715230641")
  18 + assert result.include?("Endereço para acessar este CV")
  19 + end
  20 +
  21 + should 'inform that lattes was not found' do
  22 + assert_equal "Lattes not found. Please, make sure the informed URL is correct.", @parser.get_html("http://lattes.cnpq.br/123")
  23 + end
  24 +end
... ...
plugins/lattes_curriculum/test/unit/lattes_curriculum_test.rb 0 → 100644
... ... @@ -0,0 +1,24 @@
  1 +require "test_helper"
  2 +
  3 +class LattesCurriculumPluginTest < ActiveSupport::TestCase
  4 +
  5 + def setup
  6 + @plugin = LattesCurriculumPlugin.new
  7 + end
  8 +
  9 + should 'be a noosfero plugin' do
  10 + assert_kind_of Noosfero::Plugin, @plugin
  11 + end
  12 +
  13 + should 'have name' do
  14 + assert_equal 'Lattes Curriculum Plugin', LattesCurriculumPlugin.plugin_name
  15 + end
  16 +
  17 + should 'have description' do
  18 + assert_equal _('A plugin that imports the lattes curriculum into the users profiles'), LattesCurriculumPlugin.plugin_description
  19 + end
  20 +
  21 + should 'have stylesheet' do
  22 + assert @plugin.stylesheet?
  23 + end
  24 +end
... ...
plugins/lattes_curriculum/test/unit/person_test.rb 0 → 100644
... ... @@ -0,0 +1,26 @@
  1 +require "test_helper"
  2 +
  3 +class PersonTest < ActiveSupport::TestCase
  4 +
  5 + def setup
  6 + @environment = Environment.default
  7 + @environment.enable_plugin(LattesCurriculumPlugin)
  8 + end
  9 +
  10 + attr_reader :environment
  11 +
  12 + should 'destroy academic info if person is removed' do
  13 + person = fast_create(Person)
  14 + academic_info = fast_create(AcademicInfo, :person_id => person.id,
  15 +:lattes_url => 'http://lattes.cnpq.br/2193972715230')
  16 +
  17 + assert_difference 'AcademicInfo.count', -1 do
  18 + person.destroy
  19 + end
  20 + end
  21 +
  22 + should 'add lattes_url field to Person' do
  23 + assert_includes Person.fields, 'lattes_url'
  24 + end
  25 +
  26 +end
... ...
test/functional/profile_editor_controller_test.rb
... ... @@ -230,16 +230,20 @@ class ProfileEditorControllerTest &lt; ActionController::TestCase
230 230  
231 231 should 'back when update community info fail' do
232 232 org = fast_create(Community)
233   - Community.any_instance.stubs(:update_attributes).returns(false)
  233 + Community.any_instance.expects(:update_attributes!).raises(ActiveRecord::RecordInvalid)
234 234 post :edit, :profile => org.identifier
  235 +
235 236 assert_template 'edit'
  237 + assert_response :success
236 238 end
237 239  
238 240 should 'back when update enterprise info fail' do
239 241 org = fast_create(Enterprise)
240   - Enterprise.any_instance.stubs(:update_attributes).returns(false)
  242 +
  243 + Enterprise.any_instance.expects(:update_attributes!).raises(ActiveRecord::RecordInvalid)
241 244 post :edit, :profile => org.identifier
242 245 assert_template 'edit'
  246 + assert_response :success
243 247 end
244 248  
245 249 should 'show edit profile button' do
... ...