freeze + spec
This commit is contained in:
parent
a655d0eb6b
commit
3b51d53225
|
@ -1,6 +1,8 @@
|
|||
class PlatformsController < ApplicationController
|
||||
before_filter :authenticate_user!
|
||||
|
||||
before_filter :find_platform, :only => [:freeze, :unfreeze]
|
||||
|
||||
def index
|
||||
@platforms = Platform.all
|
||||
end
|
||||
|
@ -26,10 +28,35 @@ class PlatformsController < ApplicationController
|
|||
end
|
||||
end
|
||||
|
||||
def freeze
|
||||
@platform.released = true
|
||||
if @platform.save
|
||||
flash[:notice] = I18n.t("flash.platform.freezed")
|
||||
else
|
||||
flash[:notice] = I18n.t("flash.platform.freeze_error")
|
||||
end
|
||||
|
||||
redirect_to @platform
|
||||
end
|
||||
|
||||
def unfreeze
|
||||
@platform.released = false
|
||||
if @platform.save
|
||||
flash[:notice] = I18n.t("flash.platform.unfreezed")
|
||||
else
|
||||
flash[:notice] = I18n.t("flash.platform.unfreeze_error")
|
||||
end
|
||||
|
||||
redirect_to @platform
|
||||
end
|
||||
|
||||
def destroy
|
||||
Platform.destroy params[:id]
|
||||
redirect_to root_path
|
||||
end
|
||||
|
||||
protected
|
||||
def find_platform
|
||||
@platform = Platform.find params[:id]
|
||||
end
|
||||
end
|
||||
|
|
|
@ -21,6 +21,10 @@ class Platform < ActiveRecord::Base
|
|||
return p
|
||||
end
|
||||
|
||||
def name
|
||||
released? ? "#{self[:name]} #{I18n.t("layout.platforms.released_suffix")}" : self[:name]
|
||||
end
|
||||
|
||||
protected
|
||||
|
||||
def build_path(dir)
|
||||
|
|
|
@ -2,6 +2,13 @@
|
|||
= t('layout.platforms.show')
|
||||
= @platform.name
|
||||
= link_to t('layout.platforms.back_to_the_list'), platforms_path
|
||||
|
||||
.freeze
|
||||
- if @platform.released?
|
||||
= link_to I18n.t("layout.platforms.unfreeze"), unfreeze_platform_path(@platform), :confirm => I18n.t("layout.platforms.confirm_unfreeze")
|
||||
- else
|
||||
= link_to I18n.t("layout.platforms.freeze"), freeze_platform_path(@platform), :confirm => I18n.t("layout.platforms.confirm_freeze")
|
||||
|
||||
.location
|
||||
= t('layout.platforms.location')
|
||||
= @platform.path
|
||||
|
|
|
@ -19,6 +19,11 @@ ru:
|
|||
location: Расположение
|
||||
repositories: Репозитории
|
||||
back_to_the_list: ⇐ К списку платформ
|
||||
freeze: Заморозить
|
||||
unfreeze: Разморозить
|
||||
confirm_freeze: Вы уверены, что хотите заморозить эту платформу?
|
||||
confirm_unfreeze: Вы уверены, что хотите разморозить эту платформу?
|
||||
released_suffix: (выпущена)
|
||||
repositories:
|
||||
new: Новый репозиторий
|
||||
show: Репозиторий
|
||||
|
@ -51,6 +56,10 @@ ru:
|
|||
platform:
|
||||
saved: Платформа успешно добавлена
|
||||
saved_error: Не удалось создать платформу
|
||||
freezed: Платформа успешно заморожена
|
||||
freeze_error: Не удалось заморозить платформу, попробуйте еще раз
|
||||
unfreezed: Платформа успешно разморожена
|
||||
unfreeze_error: Не удалось разморозить платформу, попробуйте еще раз
|
||||
|
||||
attributes:
|
||||
password: Пароль
|
||||
|
|
|
@ -2,6 +2,11 @@ Rosa::Application.routes.draw do
|
|||
devise_for :users
|
||||
|
||||
resources :platforms do
|
||||
member do
|
||||
get 'freeze'
|
||||
get 'unfreeze'
|
||||
end
|
||||
|
||||
resources :repositories do
|
||||
resources :projects do
|
||||
resource :repo, :controller => "git/repositories", :only => [:show]
|
||||
|
|
|
@ -0,0 +1,9 @@
|
|||
class AddReleasedToPlatforms < ActiveRecord::Migration
|
||||
def self.up
|
||||
add_column :platforms, :released, :boolean, :default => false
|
||||
end
|
||||
|
||||
def self.down
|
||||
remove_column :platforms, :released
|
||||
end
|
||||
end
|
|
@ -10,7 +10,7 @@
|
|||
#
|
||||
# It's strongly recommended to check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(:version => 20110312133948) do
|
||||
ActiveRecord::Schema.define(:version => 20110317130503) do
|
||||
|
||||
create_table "arches", :force => true do |t|
|
||||
t.string "name", :null => false
|
||||
|
@ -34,6 +34,7 @@ ActiveRecord::Schema.define(:version => 20110312133948) do
|
|||
t.integer "parent_platform_id"
|
||||
t.datetime "created_at"
|
||||
t.datetime "updated_at"
|
||||
t.boolean "released", :default => false
|
||||
end
|
||||
|
||||
create_table "projects", :force => true do |t|
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe GitController do
|
||||
|
||||
end
|
||||
#describe GitController do
|
||||
#
|
||||
#end
|
||||
|
|
|
@ -0,0 +1,4 @@
|
|||
Factory.define(:platform) do |p|
|
||||
p.name { Factory.next(:string) }
|
||||
p.unixname { Factory.next(:string) }
|
||||
end
|
|
@ -10,6 +10,6 @@ require 'spec_helper'
|
|||
# end
|
||||
# end
|
||||
# end
|
||||
describe GitHelper do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
#describe GitHelper do
|
||||
# pending "add some examples to (or delete) #{__FILE__}"
|
||||
#end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Arch do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
#describe Arch do
|
||||
# pending "add some examples to (or delete) #{__FILE__}"
|
||||
#end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Containter do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
#describe Containter do
|
||||
# pending "add some examples to (or delete) #{__FILE__}"
|
||||
#end
|
||||
|
|
|
@ -1,5 +1,25 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Platform do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
before(:each) do
|
||||
Platform.delete_all
|
||||
FileUtils.rm_rf(APP_CONFIG['root_path'])
|
||||
end
|
||||
|
||||
context 'released' do
|
||||
it 'should add suffix to name when released' do
|
||||
@platform = Factory(:platform)
|
||||
old_name = @platform.name
|
||||
|
||||
@platform.released = true
|
||||
@platform.save
|
||||
|
||||
@platform.name.should == "#{old_name} #{I18n.t("layout.platforms.released_suffix")}"
|
||||
end
|
||||
|
||||
it 'should not add suffix to name when not released' do
|
||||
@platform = Factory(:platform, :name => 'name')
|
||||
@platform.name.should == 'name'
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Project do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
#describe Project do
|
||||
# pending "add some examples to (or delete) #{__FILE__}"
|
||||
#end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe Rpm do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
#describe Rpm do
|
||||
# pending "add some examples to (or delete) #{__FILE__}"
|
||||
#end
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
require 'spec_helper'
|
||||
|
||||
describe User do
|
||||
pending "add some examples to (or delete) #{__FILE__}"
|
||||
end
|
||||
#describe User do
|
||||
# pending "add some examples to (or delete) #{__FILE__}"
|
||||
#end
|
||||
|
|
Loading…
Reference in New Issue