repo
stringlengths
5
92
file_url
stringlengths
80
287
file_path
stringlengths
5
197
content
stringlengths
0
32.8k
language
stringclasses
1 value
license
stringclasses
7 values
commit_sha
stringlengths
40
40
retrieved_at
stringdate
2026-01-04 15:37:27
2026-01-04 17:58:21
truncated
bool
2 classes
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/controllers/api/photos_test.rb
test/controllers/api/photos_test.rb
require "spec_helper" require "active_support/core_ext" describe Api::V3::PhotosController do let(:json) { JSON.parse(response.body) } describe "POST /api/v3/photos.json" do include ActionDispatch::TestProcess it "without login should response 401" do post "/api/v3/photos.json" assert_equal 4...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/controllers/api/users_test.rb
test/controllers/api/users_test.rb
require "spec_helper" describe Api::V3::UsersController do describe "GET /api/v3/users.json" do before do @users = create_list(:user, 10) @users.each do |user| user.yearly_replies_count.to_i user.monthly_replies_count.to_i end end it "should work" do get "/api/v3...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/controllers/api/nodes_test.rb
test/controllers/api/nodes_test.rb
require "spec_helper" require "active_support/core_ext" describe Api::V3::NodesController do describe "GET /api/nodes.json" do before do %w[fun ruby nodes].each_with_index { |n, i| create(:node, name: n, id: i + 1, sort: (3 - i)) } end it "should return the list of nodes" do get "/api/v3/nod...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/controllers/api/notifications_test.rb
test/controllers/api/notifications_test.rb
require "spec_helper" describe Api::V3::NotificationsController do describe "GET /api/notifications.json" do it "must require token" do get "/api/v3/notifications.json" assert_equal 401, response.status end it "should be ok" do login_user! get "/api/v3/notifications.json" a...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/controllers/api/replies_test.rb
test/controllers/api/replies_test.rb
require "spec_helper" describe Api::V3::RepliesController do let(:reply) { create(:reply, user: current_user) } describe "GET /api/v3/replies/:id.json" do it "should be ok" do get "/api/v3/replies/#{reply.id}.json" assert_equal 200, response.status assert_has_keys json["reply"], "id", "topic...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/controllers/oauth/applications_controller_test.rb
test/controllers/oauth/applications_controller_test.rb
require "spec_helper" describe Oauth::ApplicationsController do let(:application) { create(:application, owner: user) } describe "GET /oauth/applications" do let(:user) { create :user } it "should show register link if user not signed in" do get oauth_applications_path assert_not_equal 200, r...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/controllers/users/sessions_controller_test.rb
test/controllers/users/sessions_controller_test.rb
require "test_helper" class Users::SessionsControllerTest < ActionDispatch::IntegrationTest setup do @user = create(:user, login: "huacnlee", email: "huacnlee@gmail.com", password: "123456", password_confirmation: "123456") end test "GET /account/sign_in" do get new_user_session_path assert_equal 20...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/controllers/users/registrations_controller_test.rb
test/controllers/users/registrations_controller_test.rb
require "test_helper" class Users::RegistrationsControllerTest < ActionDispatch::IntegrationTest test "normal user sign up" do get new_user_registration_path assert_equal 200, response.status assert_select ".btn-primary", value: "Sign Up" assert_select "input[name='_rucaptcha']" assert_select "....
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/controllers/users/passwords_controller_test.rb
test/controllers/users/passwords_controller_test.rb
require "spec_helper" describe Users::PasswordsController, type: :controller do describe "GET /account/password/new" do it "should render new tempalte" do get "/account/password/new" assert_equal 200, response.status assert_select ".rucaptcha-image", 1 end it "should not has captcha" d...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/components/topic_component_test.rb
test/components/topic_component_test.rb
require "test_helper" class TopicComponentTest < ViewComponent::TestCase test "nil" do component = TopicComponent.new(topic: nil) assert_equal "", render_inline(component).inner_html end test "normal" do topic = create(:topic) component = TopicComponent.new(topic: topic) doc = render_inline(...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/components/reply_component_test.rb
test/components/reply_component_test.rb
require "test_helper" class ReplyComponentTest < ViewComponent::TestCase test "normal" do topic = create(:topic) reply = create(:reply, topic: topic) component = ReplyComponent.new(reply: reply, topic: topic) doc = render_inline(component) assert_equal 1, doc.css("#reply-#{reply.id}").length en...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/components/profile_card_component_test.rb
test/components/profile_card_component_test.rb
require "test_helper" class ProfileCardComponentTest < ViewComponent::TestCase def test_component_renders_something_useful user = create(:user) component = ProfileCardComponent.new(user: user) component.stub(:owner?, true) do doc = render_inline(component) assert_equal user.name, doc.css(".us...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/components/reply_to_component_test.rb
test/components/reply_to_component_test.rb
require "test_helper" class ReplyToComponentTest < ViewComponent::TestCase setup do @topic = create(:topic) @reply_to = create(:reply, topic: @topic) @reply = create(:reply, reply_to: @reply_to, topic: @topic) end test "normal" do component = ReplyToComponent.new(reply: @reply, topic: @topic) ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/components/alert_component_test.rb
test/components/alert_component_test.rb
require "test_helper" class AlertComponentTest < ViewComponent::TestCase def test_component component = AlertComponent.new doc = render_inline(component) assert_nil doc.css(".alert").first vc_test_controller.flash[:notice] = "hello" doc = render_inline(component) assert_equal "hello", doc.cs...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/user_test.rb
test/models/user_test.rb
require "test_helper" require "digest/md5" class UserTest < ActiveSupport::TestCase setup do User.any_instance.stubs(:update_index).returns(true) @user = nil end def user @user ||= create(:user) end test "user_type" do assert_equal :user, user.user_type end def assert_valid_login(valid...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/cache_version_test.rb
test/models/cache_version_test.rb
require "test_helper" class CacheVersionTest < ActiveSupport::TestCase test "set / get" do t = Time.now.to_f.to_s CacheVersion.topic_last_suggested_at = t assert_equal t, CacheVersion.topic_last_suggested_at t1 = Time.now.to_f.to_s CacheVersion.topic_last_suggested_at = t1 assert_equal t1, Ca...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/photo_test.rb
test/models/photo_test.rb
require "test_helper" class PhotoTest < ActiveSupport::TestCase include ActiveJob::TestHelper setup do @user = create(:user) @file = fixture_file_upload("test.png") end test "upload and delete" do photo = Photo.new(image: @file, user: @user) photo.save! assert_match Regexp.new("/uploads/p...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/setting_test.rb
test/models/setting_test.rb
require "test_helper" class SettingTest < ActiveSupport::TestCase test "navbar_brand_html" do assert_equal %(<a href="/" class="navbar-brand"><b>#{Setting.app_name}</b></a>), Setting.navbar_brand_html end test "reject_newbie_reply_in_the_evening" do assert_equal false, Setting.reject_newbie_reply_in_the...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/comment_test.rb
test/models/comment_test.rb
require "test_helper" class CommentTest < ActiveSupport::TestCase setup do @monkey = Monkey.create(name: "Foo") @user = create(:user) end test "base" do comment = Comment.new assert_equal true, comment.respond_to?(:mentioned_user_ids) assert_equal true, comment.respond_to?(:extract_mentioned...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/topic_test.rb
test/models/topic_test.rb
require "test_helper" class TopicTest < ActiveSupport::TestCase attr_accessor :topic, :user setup do @topic = create(:topic) @user = create(:user) end test "should no save invalid node_id" do assert_not_equal true, build(:topic, node_id: nil).valid? end test "should set last_active_mark on c...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/ability_test.rb
test/models/ability_test.rb
require "test_helper" class AbilityTest < ActiveSupport::TestCase test "Admin manage all" do admin = create :admin ability = Ability.new(admin) assert ability.can?(:manage, Topic) assert ability.can?(:manage, Reply) assert ability.can?(:manage, Node) assert ability.can?(:manage, Photo) a...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/counter_test.rb
test/models/counter_test.rb
require "test_helper" class CounterTest < ActiveSupport::TestCase test "base" do counter = create :counter assert_equal 0, counter.value assert_equal 0, counter.to_i counter.incr assert_equal 1, counter.value counter.incr assert_equal 2, counter.value counter.incr(3) assert_equ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/team_user_test.rb
test/models/team_user_test.rb
require "test_helper" class TeamUserTest < ActiveSupport::TestCase test "Create via login" do user = create(:user) team_user = build(:team_user, login: user.login) assert_equal true, team_user.save assert_equal user.id, team_user.user_id # should add error when user not exists team_user = b...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/notification_test.rb
test/models/notification_test.rb
require "test_helper" class NotificationTest < ActiveSupport::TestCase test ".realtime_push_to_client" do note = create(:notification_topic_reply) hash = {} hash[:count] = note.user.notifications.unread.count args = ["notifications_count/#{note.user_id}", hash] ActionCable.server.expects(:broadc...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/search_document_test.rb
test/models/search_document_test.rb
require "test_helper" class SearchDocumentTest < ActiveSupport::TestCase end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/team_test.rb
test/models/team_test.rb
require "test_helper" class TeamTest < ActiveSupport::TestCase test "base" do team = create(:team) assert_equal "Team", team.class.name assert_equal "Team", team[:type] assert_equal :team, team.user_type end test "Create" do team = build :team, password: nil, password_confirmation: nil ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/location_test.rb
test/models/location_test.rb
require "test_helper" class LocationTest < ActiveSupport::TestCase setup do @location = create(:location, name: "foo") end test "should validates_uniqueness_of :name ignore case" do record = Location.create(name: "FoO") assert_equal 1, record.errors[:name].size end test "should find_by_name str...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/profile_test.rb
test/models/profile_test.rb
require "test_helper" class ProfileTest < ActiveSupport::TestCase setup do @user = create(:user) end attr_accessor :user test "contacts" do @user.create_profile(contacts: { weibo: "huacnlee", twitter: "huacnlee" }) assert_equal({ weibo: "huacnlee", twitter: "huacnlee" }.as_json, @user.contacts) ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/device_test.rb
test/models/device_test.rb
require "test_helper" class DeviceTest < ActiveSupport::TestCase test ".alive?" do device = build :device, last_actived_at: 3.weeks.ago assert_equal false, device.alive? # last_actived_at nil device = build :device, last_actived_at: nil assert_equal true, device.alive? # last_actived_at les...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/node_test.rb
test/models/node_test.rb
require "test_helper" class NodeTest < ActiveSupport::TestCase attr_accessor :node setup do @node = create(:node) end test "should valid with only name present" do node = Node.new node.name = "Cersei" assert_equal true, node.valid? end test ".summary_html should return html" do node.s...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/reply_test.rb
test/models/reply_test.rb
require "test_helper" class ReplyTest < ActiveSupport::TestCase include ActiveJob::TestHelper attr_accessor :user setup do @user = create(:user) end test "should not valid when Topic was closed" do t = create :topic, closed_at: Time.now r = build(:reply) assert_equal true, r.valid? r.t...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/concerns/mentionable_test.rb
test/models/concerns/mentionable_test.rb
require "test_helper" class MentionableTest < ActiveSupport::TestCase class TestDocument < ApplicationRecord include Mentionable belongs_to :user, optional: true belongs_to :reply_to, class_name: "TestDocument", optional: true delegate :login, to: :user, prefix: true, allow_nil: true end test "...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/concerns/topic_reference_test.rb
test/models/concerns/topic_reference_test.rb
require "test_helper" class TopicReferenceTest < ActiveSupport::TestCase include ActiveJob::TestHelper test "topic" do perform_enqueued_jobs do t1 = create(:topic) t1_updated_at = t1.updated_at t2 = create(:topic) t2_udpated_at = t2.updated_at t3 = create(:topic) sleep 0.0...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/concerns/markdown_body_test.rb
test/models/concerns/markdown_body_test.rb
require "test_helper" class MarkdownBodyTest < ActiveSupport::TestCase include ActiveJob::TestHelper test "body_html" do topic = Topic.new(body: "各类系统总会或多或少的需要一些**赞、收藏、关注/订阅**等功能。\n\n每次我们都要重新开发么?不!那不是 DRY 的风格。采用 Active Record 多态关联(Polymorphic Association)的方式存储各种类型的动作数据,例如:赞、喜欢、收藏、关注、订阅、屏蔽(靠你的想象,还可以干更多的事情)等等。"...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/concerns/counterable_test.rb
test/models/concerns/counterable_test.rb
require "test_helper" class CounterableTest < ActiveSupport::TestCase test "Topic hits" do Homeland.redis.del("topic:123:hits") t = Topic.new(id: 123) # Ensure Redis DB is 0 assert_equal 0, t.hits.redis._client.db assert_equal false, t.hits.nil? assert_equal 0, t.hits.to_i assert_equal "...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/concerns/base_model_test.rb
test/models/concerns/base_model_test.rb
require "test_helper" class ApplicationRecordTest < ActiveSupport::TestCase test "should have recent scope method" do monkey = Monkey.create(name: "Caesar", id: 1) ghost = Monkey.create(name: "Wukong", id: 2) assert_equal [ghost, monkey], Monkey.recent.to_a end test "should have exclude_ids scope m...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/concerns/mention_topic_test.rb
test/models/concerns/mention_topic_test.rb
require "test_helper" class MentionTopicTest < ActiveSupport::TestCase include ActiveJob::TestHelper attr_accessor :user, :topics setup do @user = create(:user) @topics = create_list(:topic, 3) end test "mentioned_topic_ids" do # should extract mentioned user ids topic = Topic.new body: ":...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/concerns/soft_delete_test.rb
test/models/concerns/soft_delete_test.rb
require "spec_helper" class SoftDeleteTest < ActiveSupport::TestCase class WalkingDead < ApplicationRecord include SoftDelete after_destroy do self.tag = "after_destroy #{name}" end before_validation :check_name_not_exist def check_name_not_exist if WalkingDead.unscoped.where(name: ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/user/reward_fields_test.rb
test/models/user/reward_fields_test.rb
require "test_helper" class User::RewardFieldsTest < ActiveSupport::TestCase setup do @user = create(:user) end attr_accessor :user test "RewardFields" do params = { alipay: "alipay111", wechat: "wechat111" } assert_equal false, user.reward_enabled? user.update_reward_fields(p...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/user/profile_fields_test.rb
test/models/user/profile_fields_test.rb
require "test_helper" class User::ProfileFiledsTest < ActiveSupport::TestCase setup do @user = create(:user) end attr_accessor :user test "profile_field" do params = { weibo: "weibo1", douban: "douban1", dribbble: "dribbble1" } user.update_profile_fields(params) assert_e...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/user/online_trackable_test.rb
test/models/user/online_trackable_test.rb
require "test_helper" class User::OnlineTrackableTest < ActiveSupport::TestCase def setup Homeland.redis.del(User::REDIS_ONLINE_KEY) end test "online query methods should work" do assert_equal 0, User.count user = create(:user) assert_equal false, user.online? assert_nil user.last_online_at ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/user/avatar_test.rb
test/models/user/avatar_test.rb
require "test_helper" class User::AvatarTest < ActiveSupport::TestCase include ActiveJob::TestHelper test "letter_avatar_char" do u = User.new(login: "hello") assert_equal "h", u.letter_avatar_char u = User.new(login: "apple") assert_equal "a", u.letter_avatar_char u = User.new(login: "Apple")...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/user/soft_delete_test.rb
test/models/user/soft_delete_test.rb
require "test_helper" class User::SoftDeleteTest < ActiveSupport::TestCase test "soft_delete" do user = create(:user) user.soft_delete user.reload assert_equal "deleted", user.state assert_equal true, user.deleted? end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/user/deviseable_test.rb
test/models/user/deviseable_test.rb
require "test_helper" class User::DeviseableTest < ActiveSupport::TestCase include ActiveJob::TestHelper class Monkey < ApplicationRecord include User::Deviseable end setup do @data = { "email" => "email@example.com", "nickname" => "_why", "name" => "why" } @uid = "42" end attr_accessor :dat...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/models/setting/legecy_test.rb
test/models/setting/legecy_test.rb
require "test_helper" class Setting::LegecyTest < ActiveSupport::TestCase test "legecy_envs" do assert_equal [], Setting.legecy_envs ENV["github_token"] = "foo" assert_equal [:github_token], Setting.legecy_envs end test "legecy_env_instead" do assert_equal "github_api_key", Setting.legecy_env_in...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/plugins/setting_test.rb
test/plugins/setting_test.rb
require "test_helper" class SettingPluginTest < ActiveSupport::TestCase test "editable_keys" do assert_kind_of Array, Setting.editable_keys end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/plugins/plugin_test.rb
test/plugins/plugin_test.rb
require "test_helper" class Homeland::PluginTest < ActiveSupport::TestCase setup do @plugin = Homeland.register_plugin do |plugin| plugin.name = "foo" plugin.version = "0.1.0" plugin.display_name = "Foo bar" plugin.root_path = "/foo" plugin.admin_path = "/admin/foo" plugin.des...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/plugins/plugin_load_test.rb
test/plugins/plugin_load_test.rb
require "test_helper" class PluginLoadTest < ActiveSupport::TestCase test "base load" do assert_includes Homeland.plugins.collect(&:name), "test" plugin = Homeland.plugins.find { |p| p.name == "test" } assert_kind_of Homeland::Plugin, plugin assert_equal "Test plugin", plugin.display_name assert_...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/lib/image_thumb_test.rb
test/lib/image_thumb_test.rb
require "test_helper" require "fileutils" class Homeland::ImageThumbTest < ActiveSupport::TestCase test "pragma: false" do image_thumb = Homeland::ImageThumb.new("test", "xs") assert_equal false, image_thumb.exists? end test "pragma: true" do FileUtils.mkdir_p(Rails.root.join("public", "uploads")) ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/lib/search_test.rb
test/lib/search_test.rb
require "test_helper" class Homeland::SearchText < ActiveSupport::TestCase test "initialize" do @search = Homeland::Search.new("(Ruby)语言!") assert_equal ["Ruby", "语言"], @search.terms assert_equal "Ruby 语言", @search.term assert_equal "TO_TSQUERY('simple', 'Ruby:* & 语言:*')", @search.ts_query end t...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/lib/utils_test.rb
test/lib/utils_test.rb
require "test_helper" class Homeland::UtilsTest < ActiveSupport::TestCase test "omniauth_name" do assert_equal "GitHub", Homeland::Utils.omniauth_name(:github) assert_equal "Twitter", Homeland::Utils.omniauth_name(:twitter) assert_equal "微信", Homeland::Utils.omniauth_name(:wechat) end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/lib/html_test.rb
test/lib/html_test.rb
require "test_helper" class Homeland::HtmlTest < ActiveSupport::TestCase test "plain" do html = read_file("plain.html") expected = read_file("plain.txt") assert_equal expected, Homeland::Html.plain(html) end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/lib/sanitize_test.rb
test/lib/sanitize_test.rb
require "test_helper" class Homeland::SanitizeTest < ActiveSupport::TestCase include ActionView::Helpers::SanitizeHelper def assert_sanitize_html(expected, raw) assert_equal expected, sanitize(raw, scrubber: Homeland::Sanitize::TOPIC_SCRUBBER) end test "work relative link" do html = '<a href="/foo">f...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/lib/homeland_test.rb
test/lib/homeland_test.rb
require "test_helper" class HomelandTest < ActiveSupport::TestCase test "boot_at" do assert_kind_of Time, Homeland.boot_at end test "find_plugin" do plugin = Homeland.find_plugin("test") assert_kind_of Homeland::Plugin, plugin assert_equal "test", plugin.name end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/test/lib/markdown_test.rb
test/lib/markdown_test.rb
require "test_helper" def assert_render_with_cases(cases) cases.each_key do |key| assert_markdown_render cases[key], key end end def assert_markdown_render(html, raw = nil) raw = yield if block_given? assert_html_equal html, Homeland::Markdown.call(raw) end def parse_markdown_doc(raw) Nokogiri::HTML.fr...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/plugins/test/boot.rb
plugins/test/boot.rb
Homeland.register_plugin do |s| s.name = "test" s.display_name = "Test plugin" s.description = "Plugin for Homeland development test." s.url = "https://github.com/ruby-china/homeland/tree/master/plugins/test" end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland.rb
lib/homeland.rb
require "homeland/version" require "homeland/plugin" unless ENV["RAILS_PRECOMPILE"] # Preload Jieba require "homeland/search" end module Homeland cattr_reader :boot_at class << self # Follow Redis offical guides make redis thread safety # https://github.com/redis/redis-rb#connection-pooling-and-threa...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/single_sign_on.rb
lib/single_sign_on.rb
# From: https://github.com/discourse/discourse/blob/master/lib/single_sign_on.rb class SingleSignOn ACCESSORS = %i[nonce name username email avatar_url bio external_id return_sso_url admin] FIXNUMS = [] BOOLS = [:admin] NONCE_EXPIRY_TIME = 10.minutes attr_accessor(*ACCESSORS) attr_writer :sso_secret, :sso_...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/rails/generators/erb/scaffold/scaffold_generator.rb
lib/rails/generators/erb/scaffold/scaffold_generator.rb
require "rails/generators/erb" require "rails/generators/resource_helpers" module Erb module Generators class ScaffoldGenerator < Base include Rails::Generators::ResourceHelpers argument :attributes, type: :array, default: [], banner: "field:type field:type" def create_root_folder emp...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/user_notification_helper.rb
lib/homeland/user_notification_helper.rb
module Homeland module UserNotificationHelper extend ActiveSupport::Concern included do helper_method :unread_notify_count end def unread_notify_count return 0 if current_user.blank? @unread_notify_count ||= Notification.unread_count(current_user) end end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/pipeline.rb
lib/homeland/pipeline.rb
module Homeland class Pipeline end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/version.rb
lib/homeland/version.rb
module Homeland class << self def version "3.11.0" end end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/utils.rb
lib/homeland/utils.rb
module Homeland class Utils class << self # Get name for OmniAuth provider # Other -> OmniAuth::Utils.camelize def omniauth_name(provider) provider = provider.to_s case provider when "wechat" "微信" else OmniAuth::Utils.camelize(provider) ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/plugin.rb
lib/homeland/plugin.rb
module Homeland class Plugin # name of plugin, use var name style. attr_accessor :name # Plugin version attr_accessor :version # Description of plugin attr_accessor :description # Display name of plugin attr_accessor :display_name # Project url attr_accessor :url # set...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/search.rb
lib/homeland/search.rb
module Homeland class Search attr_accessor :term, :terms INVALID_CHARS = /[:()&!'"]/ JIEBA = JiebaRb::Segment.new def initialize(term) term = term.to_s.squish.gsub(INVALID_CHARS, "") @terms = Search.jieba.cut(term) @term = @terms.join(" ") @results = [] end def quer...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/markdown.rb
lib/homeland/markdown.rb
require "html/pipeline" context = { gfm: true, video_width: 700, video_height: 387 } filters = [ Homeland::Pipeline::NormalizeMentionFilter, Homeland::Pipeline::EmbedVideoFilter, Homeland::Pipeline::MarkdownFilter, Homeland::Pipeline::MentionFilter, Homeland::Pipeline::FloorFilter, HTML::Pipeline::A...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/sanitize.rb
lib/homeland/sanitize.rb
module Homeland # Sanitize # Test case in: test/helpers/application_helper_spec.rb module Sanitize TOPIC_SCRUBBER = TopicScrubber.new end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/sso.rb
lib/homeland/sso.rb
module Homeland class SSO < SingleSignOn def self.sso_url Setting.sso[:url] end def self.sso_secret Setting.sso[:secret] end def self.generate_sso(return_path = "/") sso = new sso.nonce = SecureRandom.hex sso.register_nonce(return_path) sso.return_sso_url = Se...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/image_thumb.rb
lib/homeland/image_thumb.rb
module Homeland # Generate Upload Image thumbs for development environment. class ImageThumb require "mini_magick" require "fileutils" attr_reader :outpath attr_reader :filename attr_reader :version def initialize(filename, version, pragma: false) @filename = filename @version ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/username.rb
lib/homeland/username.rb
module Homeland class Username def self.sanitize(username) username.gsub(/[^\w.-]/, "_") end end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/html.rb
lib/homeland/html.rb
module Homeland class Html def self.plain(html) doc = Nokogiri::HTML.parse(html) doc.text.gsub(/\s+/, " ").strip end end end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/sanitize/topic_scrubber.rb
lib/homeland/sanitize/topic_scrubber.rb
module Homeland module Sanitize class TopicScrubber < Rails::Html::PermitScrubber def initialize super self.tags = %w[ p br img h1 h2 h3 h4 h5 h6 blockquote pre code b i del strong em table tr td tbody th strike del u a ul ol li span hr sub sup ] ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/pipeline/twemoji_filter.rb
lib/homeland/pipeline/twemoji_filter.rb
module Homeland class Pipeline class TwemojiFilter < HTML::Pipeline::Filter def call doc.xpath(".//text()").each do |node| content = node.to_html next unless content.include?(":") next if has_ancestor?(node, %w[pre code]) html = Twemoji.parse(content) ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/pipeline/markdown_filter.rb
lib/homeland/pipeline/markdown_filter.rb
require "redcarpet" require "rouge/plugins/redcarpet" require "nokogiri" module Homeland class Pipeline class MarkdownFilter < HTML::Pipeline::TextFilter class Render < Redcarpet::Render::HTML include Rouge::Plugins::Redcarpet def domain Setting.domain end def bl...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/pipeline/floor_filter.rb
lib/homeland/pipeline/floor_filter.rb
module Homeland class Pipeline class FloorFilter < HTML::Pipeline::Filter FLOOR_REGEXP = /#(\d+)([楼樓Ff])/ def call doc.search(".//text()").each do |node| content = node.to_html next unless content.include?("#") next if has_ancestor?(node, %w[pre code]) ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/pipeline/normalize_mention_filter.rb
lib/homeland/pipeline/normalize_mention_filter.rb
module Homeland class Pipeline class NormalizeMentionFilter < HTML::Pipeline::TextFilter PREFIX_REGEXP = %r{(^|[^#{User::LOGIN_FORMAT}!#/$%&*@@])} USER_REGEXP = /#{PREFIX_REGEXP}@([#{User::LOGIN_FORMAT}]{1,20})/io def call users = [] # Makesure clone a new value, not change orig...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/pipeline/mention_filter.rb
lib/homeland/pipeline/mention_filter.rb
module Homeland class Pipeline class MentionFilter < HTML::Pipeline::Filter MENTION_REGEXP = /#{NormalizeMentionFilter::PREFIX_REGEXP}@(user[0-9]{1,6})/io MENTION_REGEXP_IN_CODE = /#{NormalizeMentionFilter::PREFIX_REGEXP}@\z/i def call users = result[:normalize_mentions] link_me...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/pipeline/embed_video_filter.rb
lib/homeland/pipeline/embed_video_filter.rb
module Homeland class Pipeline class EmbedVideoFilter < HTML::Pipeline::TextFilter YOUTUBE_URL_REGEXP = %r{(\s|^|<div>|<br>)(https?://)(www.)?(youtube\.com/watch\?v=|youtu\.be/|youtube\.com/watch\?feature=player_embedded&v=)([A-Za-z0-9_-]*)(&\S+)?(\?\S+)?} YOUKU_URL_REGEXP = %r{(\s|^|<div>|<br>)(https...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/homeland/pipeline/imageproxy_filter.rb
lib/homeland/pipeline/imageproxy_filter.rb
module Homeland class Pipeline class ImageproxyFilter < HTML::Pipeline::Filter def call return doc if Setting.imageproxy_url.blank? doc.search("img").each do |node| src = node.attr("src") img_uri = parse_uri(src) next if img_uri.blank? next if Settin...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/lib/templates/rails/scaffold_controller/controller.rb
lib/templates/rails/scaffold_controller/controller.rb
class <%= controller_class_name %>Controller < <%= controller_class_name.include?('::') == true ? "#{controller_class_name.split('::').first}::" : '' %>ApplicationController before_action :set_<%= file_name %>, only: [:show, :edit, :update, :destroy] def index @<%= plural_file_name %> = <%= file_name.camelize...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/application.rb
config/application.rb
require_relative "boot" require "rails/all" # Require the gems listed in Gemfile, including any gems # you've limited to :test, :development, or :production. Bundler.require(*Rails.groups) Dotenv::Rails.load module Homeland class Application < Rails::Application # Initialize configuration defaults for origina...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/puma-backup.rb
config/puma-backup.rb
environment ENV.fetch("RAILS_ENV", "production") port 7001 threads 3, 3 preload_app! on_worker_boot do ActiveSupport.on_load(:active_record) do ActiveRecord::Base.establish_connection end end # Run the Solid Queue supervisor inside of Puma for single-server deployments plugin :solid_queue if ENV["SOLID_QUEUE_...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/environment.rb
config/environment.rb
# Load the Rails application. require_relative "application" # Initialize the Rails application. Rails.application.initialize!
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/puma.rb
config/puma.rb
# This configuration file will be evaluated by Puma. The top-level methods that # are invoked here are part of Puma's configuration DSL. For more information # about methods provided by the DSL, see https://puma.io/puma/Puma/DSL.html. # # Puma starts a configurable number of processes (workers) and each process # serve...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/routes.rb
config/routes.rb
require "sidekiq/web" require "sidekiq/cron/web" Rails.application.routes.draw do use_doorkeeper do controllers applications: "oauth/applications", authorized_applications: "oauth/authorized_applications" end resources :comments resources :devices resources :teams root to: "topics#index" matc...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/puma-master.rb
config/puma-master.rb
port 7000 environment ENV.fetch("RAILS_ENV", "production") workers(ENV["workers"] || 4) threads 3, 3 preload_app! on_worker_boot do ActiveSupport.on_load(:active_record) do ActiveRecord::Base.establish_connection end end # Run the Solid Queue supervisor inside of Puma for single-server deployments plugin :sol...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/spring.rb
config/spring.rb
Spring.watch( ".ruby-version", ".rbenv-vars", "tmp/restart.txt", "tmp/caching-dev.txt" )
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/boot.rb
config/boot.rb
ENV["BUNDLE_GEMFILE"] ||= File.expand_path("../Gemfile", __dir__) require "bundler/setup" # Set up gems listed in the Gemfile. require "bootsnap/setup" # Speed up boot time by caching expensive operations.
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/content_security_policy.rb
config/initializers/content_security_policy.rb
# Be sure to restart your server when you modify this file. # Define an application-wide content security policy. # See the Securing Rails Applications Guide for more information: # https://guides.rubyonrails.org/security.html#content-security-policy-header # Rails.application.configure do # config.content_security...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/filter_parameter_logging.rb
config/initializers/filter_parameter_logging.rb
# Be sure to restart your server when you modify this file. # Configure sensitive parameters which will be filtered from the log file. Rails.application.config.filter_parameters += [ :passw, :email, :secret, :token, :_key, :crypt, :salt, :certificate, :otp, :ssn, :cvv, :cvc, :auth, :certificate, :access, :private,...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/application_controller_renderer.rb
config/initializers/application_controller_renderer.rb
# Be sure to restart your server when you modify this file. # ActiveSupport::Reloader.to_prepare do # ApplicationController.renderer.defaults.merge!( # http_host: 'example.org', # https: false # ) # end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/redis.rb
config/initializers/redis.rb
return if ENV["RAILS_PRECOMPILE"] redis_config = Rails.application.config_for(:redis) sidekiq_url = redis_config["url"] Sidekiq.configure_server do |config| config.redis = { url: sidekiq_url, db: 1 } end Sidekiq.configure_client do |config| config.redis = { url: sidekiq_url, db: 1 } end if Sidekiq.server? sche...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/bootstrap_form.rb
config/initializers/bootstrap_form.rb
def add_class(old_class, class_name) classes = [] classes << class_name if old_class.present? classes << old_class.strip end classes.uniq.join(" ") end module BoostrapLabel # :nodoc: def initialize(*) super @options[:class] = add_class(@options[:class], "form-label") end end module Boostrap...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/session_store.rb
config/initializers/session_store.rb
# Be sure to restart your server when you modify this file. Rails.application.config.session_store :cookie_store, key: "_homeland_session", expire_after: 86_400 * 90
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/devise.rb
config/initializers/devise.rb
TWITTER_OMNIAUTH_SETUP = lambda do |env| env["omniauth.strategy"].options[:consumer_key] = Setting.twitter_api_key env["omniauth.strategy"].options[:consumer_secret] = Setting.twitter_api_secret end WECHAT_OMNIAUTH_SETUP = lambda do |env| env["omniauth.strategy"].options[:client_id] = Setting.wechat_api_key en...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/doorkeeper.rb
config/initializers/doorkeeper.rb
Doorkeeper.configure do # Change the ORM that doorkeeper will use. # Currently supported options are :active_record, :mongoid2, :mongoid3, # :mongoid4, :mongo_mapper orm :active_record # This block will be called to check whether the resource owner is authenticated or not. resource_owner_authenticator do ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/social-share-button.rb
config/initializers/social-share-button.rb
SocialShareButton.configure do |config| config.allow_sites = %w[twitter wechat facebook weibo] end
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/feature_policy.rb
config/initializers/feature_policy.rb
# Define an application-wide HTTP feature policy. For further # information see https://developers.google.com/web/updates/2018/06/feature-policy # # Rails.application.config.feature_policy do |f| # f.camera :none # f.gyroscope :none # f.microphone :none # f.usb :none # f.fullscreen :self # ...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/rack-attack.rb
config/initializers/rack-attack.rb
Rails.application.config.to_prepare do limit_value = Setting.rack_attack[:limit].to_s.to_i period_value = Setting.rack_attack[:period].to_s.to_i || 5.minutes block_message = ["你请求过快,超过了频率限制,暂时屏蔽一段时间。"] Rack::Attack.cache.store = Rails.cache if limit_value > 0 ### Throttle Spammy Clients ### Rack::Att...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false
ruby-china/homeland
https://github.com/ruby-china/homeland/blob/9f5dbde5b7ce92b72bfdfb14622a784a2805e412/config/initializers/wrap_parameters.rb
config/initializers/wrap_parameters.rb
# Be sure to restart your server when you modify this file. # This file contains settings for ActionController::ParamsWrapper which # is enabled by default. # Enable parameter wrapping for JSON. You can disable this by setting :format to an empty array. ActiveSupport.on_load(:action_controller) do wrap_parameters f...
ruby
MIT
9f5dbde5b7ce92b72bfdfb14622a784a2805e412
2026-01-04T15:48:23.006961Z
false