diff --git a/models/site.rb b/models/site.rb index 3d737643..34106f57 100644 --- a/models/site.rb +++ b/models/site.rb @@ -210,7 +210,7 @@ class Site < Sequel::Model def password=(plaintext) @password_length = plaintext.nil? ? 0 : plaintext.length @password_plaintext = plaintext - values[:password] = BCrypt::Password.create plaintext, cost: (self.class.bcrypt_cost || BCrypt::Engine::DEFAULT_COST) + super BCrypt::Password.create plaintext, cost: (self.class.bcrypt_cost || BCrypt::Engine::DEFAULT_COST) end def new_tags_string=(tags_string) diff --git a/tests/acceptance/settings_tests.rb b/tests/acceptance/settings_tests.rb index 2e2bcf27..06ff3d0a 100644 --- a/tests/acceptance/settings_tests.rb +++ b/tests/acceptance/settings_tests.rb @@ -87,7 +87,6 @@ describe 'site/settings' do @domain = SecureRandom.uuid.gsub('-', '')+'.com' @site = Fabricate :site, domain: @domain page.set_rack_session id: @site.id - end it 'fails without domain set' do @@ -216,4 +215,27 @@ describe 'site/settings' do Site[username: ''].must_equal nil end end + + describe 'change password' do + include Capybara::DSL + + before do + @site = Fabricate :site, password: 'derpie' + page.set_rack_session id: @site.id + end + + it 'should change correctly' do + visit '/settings' + + fill_in 'current_password', with: 'derpie' + fill_in 'new_password', with: 'derpie2' + fill_in 'new_password_confirm', with: 'derpie2' + click_button 'Change Password' + + page.must_have_content /successfully changed password/i + @site.reload + @site.valid_password?('derpie').must_equal false + @site.valid_password?('derpie2').must_equal true + end + end end \ No newline at end of file