Commit d4fc661200af73fd446b570ffd48436c992b4fec

Authored by João M. M. da Silva
1 parent 1c08281c

[Mezuro] added project link on edit and new repository pages

plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb
@@ -3,8 +3,11 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController @@ -3,8 +3,11 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
3 append_view_path File.join(File.dirname(__FILE__) + '/../../views') 3 append_view_path File.join(File.dirname(__FILE__) + '/../../views')
4 4
5 def new 5 def new
6 - @project_content = profile.articles.find(params[:id])  
7 - 6 + project_content = profile.articles.find(params[:id])
  7 + @project_name = project_content.name
  8 + @data_profile = project_content.profile.identifier
  9 + @project_content_id = project_content.id
  10 +
8 @repository_types = Kalibro::Repository.repository_types 11 @repository_types = Kalibro::Repository.repository_types
9 12
10 configurations = Kalibro::Configuration.all 13 configurations = Kalibro::Configuration.all
@@ -16,7 +19,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController @@ -16,7 +19,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
16 19
17 def create 20 def create
18 project_content = profile.articles.find(params[:id]) 21 project_content = profile.articles.find(params[:id])
19 - 22 +
20 repository = Kalibro::Repository.new( params[:repository] ) 23 repository = Kalibro::Repository.new( params[:repository] )
21 repository.save(project_content.project_id) 24 repository.save(project_content.project_id)
22 25
@@ -29,8 +32,11 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController @@ -29,8 +32,11 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
29 end 32 end
30 33
31 def edit 34 def edit
32 - @project_content = profile.articles.find(params[:id])  
33 - 35 + project_content = profile.articles.find(params[:id])
  36 + @project_name = project_content.name
  37 + @data_profile = project_content.profile.identifier
  38 + @project_content_id = project_content.id
  39 +
34 @repository_types = Kalibro::Repository.repository_types 40 @repository_types = Kalibro::Repository.repository_types
35 41
36 configurations = Kalibro::Configuration.all 42 configurations = Kalibro::Configuration.all
@@ -39,7 +45,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController @@ -39,7 +45,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController
39 [configuration.name,configuration.id] 45 [configuration.name,configuration.id]
40 end 46 end
41 47
42 - @repository = @project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first 48 + @repository = project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first
43 end 49 end
44 50
45 def update 51 def update
plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb
@@ -31,8 +31,10 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase @@ -31,8 +31,10 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase
31 31
32 get :new, :profile => @profile.identifier, :id => @content.id 32 get :new, :profile => @profile.identifier, :id => @content.id
33 33
34 - assert_equal @content, assigns(:project_content) 34 + assert_equal @content.id, assigns(:project_content_id)
  35 + assert_equal @content.name, assigns(:project_name)
35 assert_equal @repository_types, assigns(:repository_types) 36 assert_equal @repository_types, assigns(:repository_types)
  37 + assert_equal @content.profile.identifier, assigns(:data_profile)
36 assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first 38 assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first
37 assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last 39 assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last
38 end 40 end
@@ -63,8 +65,10 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase @@ -63,8 +65,10 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase
63 65
64 get :edit, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id 66 get :edit, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id
65 67
66 - assert_equal @content, assigns(:project_content) 68 + assert_equal @content.id, assigns(:project_content_id)
  69 + assert_equal @content.name, assigns(:project_name)
67 assert_equal @repository_types, assigns(:repository_types) 70 assert_equal @repository_types, assigns(:repository_types)
  71 + assert_equal @content.profile.identifier, assigns(:data_profile)
68 assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first 72 assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first
69 assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last 73 assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last
70 assert_equal @repository, assigns(:repository) 74 assert_equal @repository, assigns(:repository)
@@ -92,6 +96,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase @@ -92,6 +96,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase
92 Kalibro::Configuration.expects(:configuration_of).with(@repository.id).returns(@configuration) 96 Kalibro::Configuration.expects(:configuration_of).with(@repository.id).returns(@configuration)
93 97
94 get :show, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id 98 get :show, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id
  99 +
95 assert_equal @content.name, assigns(:project_name) 100 assert_equal @content.name, assigns(:project_name)
96 assert_equal @repository, assigns(:repository) 101 assert_equal @repository, assigns(:repository)
97 assert_equal @configuration.name, assigns(:configuration_name) 102 assert_equal @configuration.name, assigns(:configuration_name)
plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb
1 -<h2><%= @project_content.name %> Project</h2> 1 +<h3> <%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %></h3>
2 2
3 <% form_for :repository, :url => {:action =>"update", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> 3 <% form_for :repository, :url => {:action =>"update", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %>
4 - <%= hidden_field_tag :id, @project_content.id %> 4 + <%= hidden_field_tag :id, @project_content_id %>
5 5
6 <%= f.hidden_field :id%> 6 <%= f.hidden_field :id%>
7 <%= required labelled_form_field _('Name:'), f.text_field(:name) %> 7 <%= required labelled_form_field _('Name:'), f.text_field(:name) %>
plugins/mezuro/views/mezuro_plugin_repository/new.html.erb
1 -<h2><%= @project_content.name %> Project</h2> 1 +<h3> <%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %></h3>
2 2
3 <% form_for :repository, :url => {:action =>"create", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> 3 <% form_for :repository, :url => {:action =>"create", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %>
4 - <%= hidden_field_tag :id, @project_content.id %> 4 + <%= hidden_field_tag :id, @project_content_id %>
5 5
6 <%= required labelled_form_field _('Name:'), f.text_field(:name) %> 6 <%= required labelled_form_field _('Name:'), f.text_field(:name) %>
7 7