diff options
-rw-r--r-- | app/models/profile_photo.rb | 3 | ||||
-rw-r--r-- | app/models/user.rb | 1 | ||||
-rw-r--r-- | db/migrate/084_alter_profile_photo.rb | 9 | ||||
-rw-r--r-- | db/schema.rb | 5 | ||||
-rw-r--r-- | spec/models/profile_photo_spec.rb | 4 |
5 files changed, 14 insertions, 8 deletions
diff --git a/app/models/profile_photo.rb b/app/models/profile_photo.rb index 4cf32ef4b..0811978fe 100644 --- a/app/models/profile_photo.rb +++ b/app/models/profile_photo.rb @@ -23,8 +23,7 @@ class ProfilePhoto < ActiveRecord::Base WIDTH = 96 HEIGHT = 96 - has_one :user - validates_presence_of :user + # has_one :user # deliberately don't strip_attributes, so keeps raw photo properly diff --git a/app/models/user.rb b/app/models/user.rb index 4cd3394b4..00fd332ad 100644 --- a/app/models/user.rb +++ b/app/models/user.rb @@ -283,7 +283,6 @@ class User < ActiveRecord::Base old_profile_photo = self.profile_photo self.profile_photo = nil end - new_profile_photo.user = self self.profile_photo = new_profile_photo end if !old_profile_photo.nil? diff --git a/db/migrate/084_alter_profile_photo.rb b/db/migrate/084_alter_profile_photo.rb new file mode 100644 index 000000000..52e798b23 --- /dev/null +++ b/db/migrate/084_alter_profile_photo.rb @@ -0,0 +1,9 @@ +class AlterProfilePhoto < ActiveRecord::Migration + def self.up + remove_column :profile_photos, :user_id + end + + def self.down + raise "Reverse migrations not supported" + end +end diff --git a/db/schema.rb b/db/schema.rb index 2e6406ad7..d1b682d48 100644 --- a/db/schema.rb +++ b/db/schema.rb @@ -9,7 +9,7 @@ # # It's strongly recommended to check this file into your version control system. -ActiveRecord::Schema.define(:version => 83) do +ActiveRecord::Schema.define(:version => 84) do create_table "acts_as_xapian_jobs", :force => true do |t| t.string "model", :null => false @@ -144,8 +144,7 @@ ActiveRecord::Schema.define(:version => 83) do add_index "post_redirects", ["updated_at"], :name => "index_post_redirects_on_updated_at" create_table "profile_photos", :force => true do |t| - t.binary "data", :null => false - t.integer "user_id", :null => false + t.binary "data", :null => false end create_table "public_bodies", :force => true do |t| diff --git a/spec/models/profile_photo_spec.rb b/spec/models/profile_photo_spec.rb index af58d0274..b7d45b8ae 100644 --- a/spec/models/profile_photo_spec.rb +++ b/spec/models/profile_photo_spec.rb @@ -17,7 +17,7 @@ describe ProfilePhoto, "when constructing a new photo" do it 'should accept and convert a PNG to right size' do data = load_file_fixture("parrot.png") - profile_photo = ProfilePhoto.new(:data => data, :user => mock_model(User, :valid? => true)) + profile_photo = ProfilePhoto.new(:data => data) profile_photo.valid?.should == true profile_photo.image.format.should == 'PNG' profile_photo.image.columns.should == 96 @@ -26,7 +26,7 @@ describe ProfilePhoto, "when constructing a new photo" do it 'should accept and convert a JPEG to right format and size' do data = load_file_fixture("parrot.jpg") - profile_photo = ProfilePhoto.new(:data => data, :user => mock_model(User, :valid? => true)) + profile_photo = ProfilePhoto.new(:data => data) profile_photo.valid?.should == true profile_photo.image.format.should == 'PNG' profile_photo.image.columns.should == 96 |