This repository has been archived by the owner on Apr 19, 2022. It is now read-only.
forked from mmcc/forem
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Namespaced models can now be used with Forem#user_class.
Fixes rubysherpas#335 Fixes rubysherpas#329
- Loading branch information
Showing
4 changed files
with
64 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
5 changes: 5 additions & 0 deletions
5
spec/lib/generators/forem/dummy/templates/app/models/refunery/yooser.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
module Refunery | ||
class Yooser < ActiveRecord::Base | ||
|
||
end | ||
end |
8 changes: 8 additions & 0 deletions
8
spec/lib/generators/forem/dummy/templates/db/migrate/3_create_refunery_yoosers.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
class CreateRefuneryYoosers < ActiveRecord::Migration | ||
create_table :refunery_yoosers, :force => true do |t| | ||
t.string :name, :default => "", :null => false | ||
t.string :email, :default => "", :null => false | ||
end | ||
|
||
add_index :refunery_yoosers, :email, :unique => true | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
require 'spec_helper' | ||
|
||
# There is no User class within Forem; this is testing the dummy application's class | ||
# More specifically, it is testing the methods provided by Forem::DefaultPermissions | ||
# | ||
# Regression test for #329 and #335 | ||
|
||
describe Refunery::Yooser do | ||
|
||
before(:each) do | ||
@original_class_name = Forem.user_class | ||
Forem.user_class = "Refunery::Yooser" | ||
end | ||
|
||
after(:each) do | ||
Forem.user_class = @original_class_name.to_s | ||
end | ||
|
||
context "Without top level reference" do | ||
before(:each) do | ||
Forem.user_class = "Refunery::Yooser" | ||
end | ||
|
||
it "return class constant" do | ||
assert_equal Refunery::Yooser, Forem.user_class | ||
end | ||
|
||
it "it return class as string" do | ||
assert_equal "Refunery::Yooser", Forem.user_class.to_s | ||
end | ||
end | ||
|
||
context "With top level reference" do | ||
before(:each) do | ||
Forem.user_class = "Refunery::Yooser" | ||
end | ||
|
||
it "return class constant" do | ||
assert_equal Refunery::Yooser, Forem.user_class | ||
end | ||
|
||
it "it return class as string" do | ||
assert_equal "Refunery::Yooser", Forem.user_class.to_s | ||
end | ||
end | ||
end |