Commit 998035d2e57181f68672ed40998beb5bc4b8c5f7
Exists in
master
and in
29 other branches
Merge branch 'refactoring_repository' of gitorious.org:+mezuro/noosfero/mezuro i…
…nto refactoring_repository
Showing
2 changed files
with
24 additions
and
7 deletions
Show diff stats
plugins/mezuro/lib/kalibro/configuration.rb
... | ... | @@ -9,7 +9,7 @@ class Kalibro::Configuration < Kalibro::Model |
9 | 9 | def self.all |
10 | 10 | response = request(:all_configurations)[:configuration] |
11 | 11 | response = [] if response.nil? |
12 | - response = [response] if response.is_a? (Hash) | |
12 | + response = [response] if response.is_a?(Hash) | |
13 | 13 | response.map {|configuration| new configuration} |
14 | 14 | end |
15 | 15 | ... | ... |
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
... | ... | @@ -15,18 +15,35 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase |
15 | 15 | @profile = fast_create(Community) |
16 | 16 | |
17 | 17 | @repository = RepositoryFixtures.repository |
18 | + @repository_hash = RepositoryFixtures.hash | |
18 | 19 | @content = MezuroPlugin::ProjectContent.new(:profile => @profile, :name => name) |
19 | 20 | @content.expects(:send_project_to_service).returns(nil) |
20 | 21 | @content.stubs(:solr_save) |
21 | 22 | @content.save |
22 | 23 | end |
23 | 24 | |
24 | - should 'test stuff' do | |
25 | - Kalibro::Repository.expects(:repository_types).returns(RepositoryFixtures.types) | |
26 | - #Kalibro::Configuration.any_instance.expects(:all).returns(ConfigurationFixtures.all) | |
25 | + should 'provide the correct variables to the "new" view' do | |
26 | + repository_types = RepositoryFixtures.types | |
27 | + all_configurations = ConfigurationFixtures.all | |
28 | + Kalibro::Repository.expects(:repository_types).returns(repository_types) | |
29 | + Kalibro::Configuration.expects(:all).returns(all_configurations) | |
27 | 30 | |
28 | - get :new_repository, :profile => @profile.identifier, :id => @content.id | |
31 | + get :new, :profile => @profile.identifier, :id => @content.id | |
29 | 32 | |
30 | - #assert_equal RepositoryFixtures.types, assigns(:repository_types) | |
33 | + #assert_equal @content, assigns(:project_content) | |
34 | + assert_equal repository_types, assigns(:repository_types) | |
35 | + assert_equal all_configurations.first.name, assigns(:configuration_select).first.first | |
36 | + assert_equal all_configurations.first.id, assigns(:configuration_select).first.last | |
31 | 37 | end |
32 | -end | |
33 | 38 | \ No newline at end of file |
39 | + | |
40 | + should 'create a repository and redirect correctly' do | |
41 | + Kalibro::Repository.expects(:new).returns(@repository) | |
42 | + @repository.expects(:save).with(@content.project_id).returns(true) | |
43 | + get :create, :profile => @profile.identifier, :id => @content.id, :repository => @repository_hash | |
44 | + assert @repository.errors.empty? | |
45 | + assert_response :redirect | |
46 | + assert_select('h5', 'Repositories') | |
47 | + end | |
48 | + | |
49 | + | |
50 | +end | ... | ... |