-
Notifications
You must be signed in to change notification settings - Fork 0
UX: show complete URL path if website domain is same as instance domain #6
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: url-handling-pre
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -66,11 +66,28 @@ | |
|
|
||
| context "with filled out website" do | ||
| before do | ||
| user.user_profile.website = 'http://example.com' | ||
| user.user_profile.website = 'http://example.com/user' | ||
| end | ||
|
|
||
| it "has a website" do | ||
| expect(json[:website]).to eq 'http://example.com' | ||
| expect(json[:website]).to eq 'http://example.com/user' | ||
| end | ||
|
|
||
| context "has a website name" do | ||
| it "returns website host name when instance domain is not same as website domain" do | ||
| Discourse.stubs(:current_hostname).returns('discourse.org') | ||
| expect(json[:website_name]).to eq 'example.com' | ||
| end | ||
|
|
||
| it "returns complete website path when instance domain is same as website domain" do | ||
| Discourse.stubs(:current_hostname).returns('example.com') | ||
| expect(json[:website_name]).to eq 'example.com/user' | ||
| end | ||
|
|
||
| it "returns complete website path when website domain is parent of instance domain" do | ||
| Discourse.stubs(:current_hostname).returns('forums.example.com') | ||
| expect(json[:website_name]).to eq 'example.com/user' | ||
| end | ||
| end | ||
|
Comment on lines
+76
to
91
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Tests may not work as expected due to The Consider using 🐛 Proposed fix context "has a website name" do
it "returns website host name when instance domain is not same as website domain" do
Discourse.stubs(:current_hostname).returns('discourse.org')
- expect(json[:website_name]).to eq 'example.com'
+ serialized = UserSerializer.new(user, scope: Guardian.new, root: false).as_json
+ expect(serialized[:website_name]).to eq 'example.com'
end
it "returns complete website path when instance domain is same as website domain" do
Discourse.stubs(:current_hostname).returns('example.com')
- expect(json[:website_name]).to eq 'example.com/user'
+ serialized = UserSerializer.new(user, scope: Guardian.new, root: false).as_json
+ expect(serialized[:website_name]).to eq 'example.com/user'
end
it "returns complete website path when website domain is parent of instance domain" do
Discourse.stubs(:current_hostname).returns('forums.example.com')
- expect(json[:website_name]).to eq 'example.com/user'
+ serialized = UserSerializer.new(user, scope: Guardian.new, root: false).as_json
+ expect(serialized[:website_name]).to eq 'example.com/user'
end
end |
||
| end | ||
|
|
||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Missing
?suffix on include method.ActiveModelSerializers expects the method to be named
include_website_name?with a trailing?for the conditional inclusion to work. Without this, the attribute will always be serialized regardless of whetherwebsiteis present.🐛 Proposed fix
🤖 Prompt for AI Agents