move versions left and right

pull/6827/head
Jens Ulferts 13 years ago
parent 4264668e6b
commit 1c81177c65
  1. 2
      app/models/version_setting.rb
  2. 11
      features/version_settings.feature
  3. 13
      lib/backlogs/patches/version_controller_patch.rb
  4. 1
      lib/backlogs/patches/version_patch.rb

@ -4,6 +4,8 @@ class VersionSetting < ActiveRecord::Base
attr_accessible :display, :project attr_accessible :display, :project
validates_presence_of :project
DISPLAY_NONE = 1 DISPLAY_NONE = 1
DISPLAY_LEFT = 2 DISPLAY_LEFT = 2
DISPLAY_RIGHT = 3 DISPLAY_RIGHT = 3

@ -60,6 +60,17 @@ Feature: Version Settings
And I press "Save" And I press "Save"
Then I should be on the settings/versions page of the project called "ecookbook" Then I should be on the settings/versions page of the project called "ecookbook"
Scenario: Switch from right to left
When I go to the edit page of the version called "Sprint 001"
And I select "right" from "version[version_settings_attributes][][display]"
And I press "Save"
And I go to the edit page of the version called "Sprint 001"
Then the "version[version_settings_attributes][][display]" field within "#content form" should contain "3"
When I select "left" from "version[version_settings_attributes][][display]"
And I press "Save"
And I go to the edit page of the version called "Sprint 001"
Then the "version[version_settings_attributes][][display]" field within "#content form" should contain "2"
Scenario: There should be a version start date field Scenario: There should be a version start date field
When I go to the edit page of the version called "Sprint 001" When I go to the edit page of the version called "Sprint 001"
Then there should be a "version_start_date" field within "#content form" Then there should be a "version_start_date" field within "#content form"

@ -12,16 +12,11 @@ module Backlogs::Patches::VersionsControllerPatch
filter_chain.detect { |m| m.method == :find_project_from_association }.options[:except] << "update" filter_chain.detect { |m| m.method == :find_project_from_association }.options[:except] << "update"
filter_chain.detect { |m| m.method == :find_project }.options[:only] << "update" filter_chain.detect { |m| m.method == :find_project }.options[:only] << "update"
before_filter :assign_project_to_version_settings, :only => [:create, :update] before_filter :add_project_to_version_settings_attributes, :only => [:update, :create]
protected def add_project_to_version_settings_attributes
params["version"]["version_settings_attributes"].each do |h|
def assign_project_to_version_settings h["project"] = @project
if params[:version] && params[:version][:version_settings_attributes]
params[:version][:version_settings_attributes].each do |attributes|
attributes[:project] = @project
attributes.delete(:project_id)
end
end end
end end
end end

@ -7,6 +7,7 @@ module Backlogs::Patches::VersionPatch
has_many :version_settings, :dependent => :destroy has_many :version_settings, :dependent => :destroy
accepts_nested_attributes_for :version_settings accepts_nested_attributes_for :version_settings
safe_attributes 'version_settings_attributes'
include InstanceMethods include InstanceMethods
end end

Loading…
Cancel
Save