Commit 8187e5191f699e5663f7c78f6580a0b14da14eef
1 parent
d15030b9
Exists in
master
and in
5 other branches
Add instituition tests
Signed-off-by: Parley Martins <parley@outlook.com> Signed-off-by: Gustavo Jaruga <darksshades@gmail.com>
Showing
2 changed files
with
18 additions
and
2 deletions
Show diff stats
controllers/mpog_software_plugin_controller.rb
| ... | ... | @@ -73,7 +73,7 @@ class MpogSoftwarePluginController < ApplicationController |
| 73 | 73 | end |
| 74 | 74 | |
| 75 | 75 | institution = private_create_institution() |
| 76 | - if environment.admins.include?(current_user.person) | |
| 76 | + if environment.admins.include?(current_user.person) and params[:edit_institution_page] == false | |
| 77 | 77 | environment.admins.each do |adm| |
| 78 | 78 | institution.community.add_admin(adm) |
| 79 | 79 | end | ... | ... |
test/functional/mpog_software_plugin_controller_test.rb
| ... | ... | @@ -9,6 +9,7 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase |
| 9 | 9 | def setup |
| 10 | 10 | @admin = create_user("adminuser").person |
| 11 | 11 | @admin.stubs(:has_permission?).returns("true") |
| 12 | + @controller.stubs(:current_user).returns(@admin.user) | |
| 12 | 13 | |
| 13 | 14 | @environment = Environment.default |
| 14 | 15 | @environment.enabled_plugins = ['MpogSoftwarePlugin'] |
| ... | ... | @@ -173,4 +174,19 @@ class MpogSoftwarePluginControllerTest < ActionController::TestCase |
| 173 | 174 | assert json_response["success"] |
| 174 | 175 | end |
| 175 | 176 | |
| 176 | -end | |
| 177 | + should "add environment admins to institution when created via admin panel" do | |
| 178 | + @controller.stubs(:verify_recaptcha).returns(true) | |
| 179 | + admin2 = create_user("another_admin").person | |
| 180 | + admin2.stubs(:has_permission?).returns("true") | |
| 181 | + @environment.add_admin(admin2) | |
| 182 | + @environment.save | |
| 183 | + | |
| 184 | + fields = InstitutionTestHelper.generate_form_fields "Private Institution", "BR", "DF", "Brasilia", "12.323.557/8900-10", "PrivateInstitution" | |
| 185 | + fields[:institutions][:acronym] = "PI" | |
| 186 | + fields[:edit_institution_page] = false | |
| 187 | + post :new_institution, fields | |
| 188 | + | |
| 189 | + assert(Institution.last.community.admins.include?(admin2) ) | |
| 190 | + end | |
| 191 | + | |
| 192 | +end | |
| 177 | 193 | \ No newline at end of file | ... | ... |