From d4fc661200af73fd446b570ffd48436c992b4fec Mon Sep 17 00:00:00 2001 From: João M. M. da Silva Date: Mon, 14 Jan 2013 13:44:38 -0200 Subject: [PATCH] [Mezuro] added project link on edit and new repository pages --- plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb | 18 ++++++++++++------ plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb | 9 +++++++-- plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb | 4 ++-- plugins/mezuro/views/mezuro_plugin_repository/new.html.erb | 4 ++-- 4 files changed, 23 insertions(+), 12 deletions(-) diff --git a/plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb b/plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb index 92c457d..cf24413 100644 --- a/plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb +++ b/plugins/mezuro/controllers/profile/mezuro_plugin_repository_controller.rb @@ -3,8 +3,11 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController append_view_path File.join(File.dirname(__FILE__) + '/../../views') def new - @project_content = profile.articles.find(params[:id]) - + project_content = profile.articles.find(params[:id]) + @project_name = project_content.name + @data_profile = project_content.profile.identifier + @project_content_id = project_content.id + @repository_types = Kalibro::Repository.repository_types configurations = Kalibro::Configuration.all @@ -16,7 +19,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController def create project_content = profile.articles.find(params[:id]) - + repository = Kalibro::Repository.new( params[:repository] ) repository.save(project_content.project_id) @@ -29,8 +32,11 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController end def edit - @project_content = profile.articles.find(params[:id]) - + project_content = profile.articles.find(params[:id]) + @project_name = project_content.name + @data_profile = project_content.profile.identifier + @project_content_id = project_content.id + @repository_types = Kalibro::Repository.repository_types configurations = Kalibro::Configuration.all @@ -39,7 +45,7 @@ class MezuroPluginRepositoryController < MezuroPluginProfileController [configuration.name,configuration.id] end - @repository = @project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first + @repository = project_content.repositories.select{ |repository| repository.id.to_s == params[:repository_id] }.first end def update diff --git a/plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb b/plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb index 587f3a5..dee5d4d 100644 --- a/plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb +++ b/plugins/mezuro/test/functional/profile/mezuro_plugin_repository_controller_test.rb @@ -31,8 +31,10 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase get :new, :profile => @profile.identifier, :id => @content.id - assert_equal @content, assigns(:project_content) + assert_equal @content.id, assigns(:project_content_id) + assert_equal @content.name, assigns(:project_name) assert_equal @repository_types, assigns(:repository_types) + assert_equal @content.profile.identifier, assigns(:data_profile) assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last end @@ -63,8 +65,10 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase get :edit, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id - assert_equal @content, assigns(:project_content) + assert_equal @content.id, assigns(:project_content_id) + assert_equal @content.name, assigns(:project_name) assert_equal @repository_types, assigns(:repository_types) + assert_equal @content.profile.identifier, assigns(:data_profile) assert_equal @all_configurations.first.name, assigns(:configuration_select).first.first assert_equal @all_configurations.first.id, assigns(:configuration_select).first.last assert_equal @repository, assigns(:repository) @@ -92,6 +96,7 @@ class MezuroPluginRepositoryControllerTest < ActionController::TestCase Kalibro::Configuration.expects(:configuration_of).with(@repository.id).returns(@configuration) get :show, :profile => @profile.identifier, :id => @content.id, :repository_id => @repository.id + assert_equal @content.name, assigns(:project_name) assert_equal @repository, assigns(:repository) assert_equal @configuration.name, assigns(:configuration_name) diff --git a/plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb b/plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb index e7246e4..78d8831 100644 --- a/plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb +++ b/plugins/mezuro/views/mezuro_plugin_repository/edit.html.erb @@ -1,7 +1,7 @@ -

<%= @project_content.name %> Project

+

<%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %>

<% form_for :repository, :url => {:action =>"update", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> - <%= hidden_field_tag :id, @project_content.id %> + <%= hidden_field_tag :id, @project_content_id %> <%= f.hidden_field :id%> <%= required labelled_form_field _('Name:'), f.text_field(:name) %> diff --git a/plugins/mezuro/views/mezuro_plugin_repository/new.html.erb b/plugins/mezuro/views/mezuro_plugin_repository/new.html.erb index c81d0fe..35217e8 100644 --- a/plugins/mezuro/views/mezuro_plugin_repository/new.html.erb +++ b/plugins/mezuro/views/mezuro_plugin_repository/new.html.erb @@ -1,7 +1,7 @@ -

<%= @project_content.name %> Project

+

<%= link_to( @project_name, homepage_url(@data_profile, @project_name.downcase.gsub(/[^0-9A-Za-z]/, '')) ) %>

<% form_for :repository, :url => {:action =>"create", :controller => "mezuro_plugin_repository"}, :method => :get do |f| %> - <%= hidden_field_tag :id, @project_content.id %> + <%= hidden_field_tag :id, @project_content_id %> <%= required labelled_form_field _('Name:'), f.text_field(:name) %> -- libgit2 0.21.2