Skip to content

Commit

Permalink
Removed distinction between free and paid users.
Browse files Browse the repository at this point in the history
FeedBunch users have never had to pay anything and the boolean attribute
that marks some users as "free" is not used.
  • Loading branch information
amatriain committed Jan 22, 2021
1 parent a8e35b0 commit 4fa350b
Show file tree
Hide file tree
Showing 9 changed files with 27 additions and 36 deletions.
2 changes: 1 addition & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0

## [Unreleased]
### Changed
Nothing yet
- Removed distinction between "free" and "paid" users. Users have never had to pay.

## [1.3.18] - 2021-01-22
### Changed
Expand Down
1 change: 0 additions & 1 deletion app/admin/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,6 @@
f.input :email
f.input :name
f.input :admin
f.input :free
end
f.actions
end
Expand Down
10 changes: 0 additions & 10 deletions app/models/user.rb
Original file line number Diff line number Diff line change
Expand Up @@ -47,9 +47,6 @@
#
# - admin: Boolean that indicates whether the user is an administrator. This attribute is used to restrict access to certain
# functionality, like ActiveAdmin and Sidekiq administration.
# - free: Boolean that indicates if the user has been granted free access to the app (if true) or if he's a paying user (if false).
# Note that regular users have this attribute set to false, even during any unpaid trial period. Only users who are never
# required to pay anything have this attribute set to true.
# - name: text with the username, to be displayed in the app. Usernames are unique. Defaults to the value of the "email" attribute.
# - locale: locale (en, es etc) in which the user wants to see the application. By default "en".
# - timezone: name of the timezone (Europe/Madrid, UTC etc) to which the user wants to see times localized. By default "UTC".
Expand Down Expand Up @@ -136,7 +133,6 @@ class User < ApplicationRecord
has_many :subscribe_job_states, dependent: :destroy

validates :admin, inclusion: {in: [true, false]}
validates :free, inclusion: {in: [true, false]}
validates :name, presence: true, uniqueness: {case_sensitive: true}
validates :locale, presence: true
validates :timezone, presence: true
Expand Down Expand Up @@ -443,7 +439,6 @@ def after_save_user
# - locale: 'en'
# - timezone: 'UTC'
# - admin: false
# - free: false
# - quick_reading: false
# - open_all_entries: false
# - show_main_tour, show_mobile_tour, show_feed_tour: show_entry_tour, show_kb_shortcuts_tour: true
Expand Down Expand Up @@ -473,11 +468,6 @@ def default_values
self.admin = false
end

if self.free == nil
Rails.logger.info "User #{self.email} has unsupported free #{self.free}. Defaulting to free 'false' instead"
self.free = false
end

if self.quick_reading == nil
Rails.logger.info "User #{self.email} has unsupported quick_reading #{self.quick_reading}. Defaulting to quick_reading 'false' instead"
self.quick_reading = false
Expand Down
4 changes: 1 addition & 3 deletions app/workers/reset_demo_user_worker.rb
Original file line number Diff line number Diff line change
Expand Up @@ -73,8 +73,7 @@ def create_demo_user
else
demo_user = User.new email: @demo_email,
password: @demo_password,
confirmed_at: Time.zone.now,
free: true
confirmed_at: Time.zone.now
Rails.logger.debug 'Demo user does not exist, creating it'
demo_user.save!
end
Expand All @@ -98,7 +97,6 @@ def reset_demo_config(demo_user)
demo_user.show_feed_tour = true
demo_user.show_entry_tour = true
demo_user.show_kb_shortcuts_tour = true
demo_user.free = true
demo_user.save!
end

Expand Down
9 changes: 9 additions & 0 deletions db/migrate/20210122225804_remove_free_from_users.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
class RemoveFreeFromUsers < ActiveRecord::Migration[6.0]
def up
remove_column :users, :free
end

def down
add_column :users, :free, :boolean, null: false, default: false
end
end
18 changes: 16 additions & 2 deletions db/schema.rb
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
#
# It's strongly recommended that you check this file into your version control system.

ActiveRecord::Schema.define(version: 2020_01_06_204929) do
ActiveRecord::Schema.define(version: 2021_01_22_225804) do

create_table "active_admin_comments", force: :cascade do |t|
t.string "namespace"
Expand Down Expand Up @@ -197,7 +197,6 @@
t.datetime "refresh_feed_jobs_updated_at"
t.datetime "config_updated_at"
t.datetime "user_data_updated_at"
t.boolean "free", default: false, null: false
t.boolean "first_confirmation_reminder_sent", default: false, null: false
t.boolean "second_confirmation_reminder_sent", default: false, null: false
t.boolean "kb_shortcuts_enabled", default: true, null: false
Expand All @@ -212,4 +211,19 @@
t.index ["unlock_token"], name: "index_users_on_unlock_token", unique: true
end

add_foreign_key "deleted_entries", "feeds", on_delete: :cascade
add_foreign_key "entries", "feeds", on_delete: :cascade
add_foreign_key "entry_states", "entries", on_delete: :cascade
add_foreign_key "entry_states", "users", on_delete: :cascade
add_foreign_key "feed_subscriptions", "feeds", on_delete: :cascade
add_foreign_key "feed_subscriptions", "users", on_delete: :cascade
add_foreign_key "feeds_folders", "feeds", on_delete: :cascade
add_foreign_key "feeds_folders", "folders", on_delete: :cascade
add_foreign_key "folders", "users", on_delete: :cascade
add_foreign_key "opml_export_job_states", "users", on_delete: :cascade
add_foreign_key "opml_import_failures", "opml_import_job_states", on_delete: :cascade
add_foreign_key "opml_import_job_states", "users", on_delete: :cascade
add_foreign_key "refresh_feed_job_states", "feeds", on_delete: :cascade
add_foreign_key "refresh_feed_job_states", "users", on_delete: :cascade
add_foreign_key "subscribe_job_states", "users", on_delete: :cascade
end
1 change: 0 additions & 1 deletion spec/factories/users.rb
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@
remember_me {true}
confirmed_at {Time.zone.now}
admin {false}
free {false}
locale {'en'}
timezone {'UTC'}
quick_reading {false}
Expand Down
10 changes: 0 additions & 10 deletions spec/unit_tests/models/user/user_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -276,16 +276,6 @@
end
end

context 'free users' do

it 'gives a default value of false' do
user = FactoryBot.build :user, free: nil
user.save!
expect(user.reload.free).not_to be_nil
expect(user.free).to be false
end
end

context 'quick reading' do

it 'gives a default value of false' do
Expand Down
8 changes: 0 additions & 8 deletions spec/unit_tests/workers/reset_demo_user_worker_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -145,14 +145,6 @@
expect(@demo_user.show_kb_shortcuts_tour).to be true
end

it 'resets free to true' do
@demo_user.update free: false

expect(@demo_user.free).not_to be true
ResetDemoUserWorker.new.perform
expect(@demo_user.reload.free).to be true
end

it 'resets OPML import state to NONE' do
opml_import = FactoryBot.build :opml_import_job_state,
user_id: @demo_user.id,
Expand Down

0 comments on commit 4fa350b

Please sign in to comment.