Permalink
Browse files

remove last_update_by_ip from items

  • Loading branch information...
blahed committed Nov 15, 2012
1 parent a6e2d1b commit 0beaceb95a66d4fd9bd111352e10e1a4590b3e2a
@@ -77,7 +77,6 @@ def account_params
:comments,
:group_ids
).merge(
- :last_updated_by_ip => request.remote_ip,
:current_user => current_user
)
end
@@ -78,7 +78,6 @@ def account_params
:comments,
:group_ids
).merge(
- :last_updated_by_ip => request.remote_ip,
:current_user => current_user
)
end
@@ -75,7 +75,6 @@ def note_params
:body,
:group_ids
).merge(
- :last_updated_by_ip => request.remote_ip,
:current_user => current_user
)
end
@@ -77,7 +77,6 @@ def software_license_params
:comments,
:group_ids
).merge(
- :last_updated_by_ip => request.remote_ip,
:current_user => current_user
)
end
View
@@ -6,15 +6,10 @@ class BaseItem
attr_accessor :current_user
field :title, :type => String
- field :last_updated_by, :type => String
- field :last_updated_by_ip, :type => String
has_and_belongs_to_many :groups, :inverse_of => nil
- before_validation :set_updated_by
-
- validates_presence_of :title, :last_updated_by, :last_updated_by_ip
- validates_format_of :last_updated_by_ip, :with => /\A\d{0,3}\.\d{0,3}\.\d{0,3}\.\d{0,3}\z/
+ validates_presence_of :title
validate :groups_are_allowed
@@ -36,8 +31,4 @@ def groups_are_allowed
errors.add(:base, "The following groups are invalid `#{invalid_groups.join(', ')}'") unless invalid_groups.empty?
end
-
- def set_updated_by
- self.last_updated_by = current_user.id if current_user
- end
end
@@ -6,36 +6,31 @@
factory :base_item do
title
current_user { create(:user) }
- last_updated_by_ip '127.0.0.1'
end
factory :generic_account do
title
username 'foo'
password 'sssh'
current_user { create(:user) }
- last_updated_by_ip '127.0.0.1'
end
factory :web_account do
title
username 'foo'
password 'sssh'
current_user { create(:user) }
- last_updated_by_ip '127.0.0.1'
end
factory :note do
title
body 'foo'
current_user { create(:user) }
- last_updated_by_ip '127.0.0.1'
end
factory :software_license do
title
license_key 'foo'
current_user { create(:user) }
- last_updated_by_ip '127.0.0.1'
end
end
@@ -16,24 +16,6 @@
item.errors.has_key?(:title).must_equal true
end
- it "wont be valid without last_updated_by" do
- item = FactoryGirl.build(:base_item, :current_user => nil)
- item.wont_be :valid?
- item.errors.has_key?(:last_updated_by).must_equal true
- end
-
- it "wont be valid without a proper last_updated_by_ip" do
- item = FactoryGirl.build(:base_item, :last_updated_by_ip => nil)
- item.wont_be :valid?
- item.errors.has_key?(:last_updated_by_ip).must_equal true
-
- %w[blah 123.123.123 3333.234.234.234 34s.23b.33d.234].each do |ip|
- item = FactoryGirl.build(:base_item, :last_updated_by_ip => ip)
- item.wont_be :valid?
- item.errors.has_key?(:last_updated_by_ip).must_equal true
- end
- end
-
it "wont be valid unless the user is a member of the requested groups" do
@item.groups << FactoryGirl.create_list(:group, 3)
@item.wont_be :valid?

0 comments on commit 0beaceb

Please sign in to comment.