jenkins-bot has submitted this change and it was merged.

Change subject: Helper for user label
......................................................................


Helper for user label

Change-Id: I674759e550eed1d0c23963915c742a62336ae53e
---
M lib/mediawiki_selenium/environment.rb
M spec/environment_spec.rb
2 files changed, 55 insertions(+), 0 deletions(-)

Approvals:
  Hashar: Looks good to me, approved
  jenkins-bot: Verified



diff --git a/lib/mediawiki_selenium/environment.rb 
b/lib/mediawiki_selenium/environment.rb
index f5bb0a6..24a3485 100644
--- a/lib/mediawiki_selenium/environment.rb
+++ b/lib/mediawiki_selenium/environment.rb
@@ -280,6 +280,17 @@
       lookup(:mediawiki_user, id)
     end
 
+    # Returns the current user, or the one for the given alternative, with all
+    # "_" replaced with " ".
+    #
+    # @param id [Symbol] Alternative user ID.
+    #
+    # @return [String]
+    #
+    def user_label(id = nil)
+      user(id).gsub("_", " ")
+    end
+
     # Navigates the current browser to the given wiki.
     #
     # @param id [Symbol] Alternative wiki ID.
diff --git a/spec/environment_spec.rb b/spec/environment_spec.rb
index 7e98ad6..054ec3b 100644
--- a/spec/environment_spec.rb
+++ b/spec/environment_spec.rb
@@ -282,6 +282,50 @@
       end
     end
 
+    describe "#user" do
+      subject { env.user(id) }
+
+      let(:config) { { mediawiki_user: "mw_user", mediawiki_user_b: 
"mw_user_b" } }
+
+      context "given no alternative ID" do
+        let(:id) { nil }
+
+        it "returns the configured :mediawiki_user" do
+          expect(subject).to eq("mw_user")
+        end
+      end
+
+      context "given an alternative ID" do
+        let(:id) { :b }
+
+        it "returns the configured alternative :mediawiki_user" do
+          expect(subject).to eq("mw_user_b")
+        end
+      end
+    end
+
+    describe "#user_label" do
+      subject { env.user_label(id) }
+
+      let(:config) { { mediawiki_user: "mw_user", mediawiki_user_b: 
"mw_user_b" } }
+
+      context "given no alternative ID" do
+        let(:id) { nil }
+
+        it "returns the configured :mediawiki_user with underscores replaced" 
do
+          expect(subject).to eq("mw user")
+        end
+      end
+
+      context "given an alternative ID" do
+        let(:id) { :b }
+
+        it "returns the configured alternative :mediawiki_user with 
underscores replaced" do
+          expect(subject).to eq("mw user b")
+        end
+      end
+    end
+
     describe "#wiki_url" do
       subject { env.wiki_url(url) }
 

-- 
To view, visit https://gerrit.wikimedia.org/r/172009
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: merged
Gerrit-Change-Id: I674759e550eed1d0c23963915c742a62336ae53e
Gerrit-PatchSet: 2
Gerrit-Project: mediawiki/selenium
Gerrit-Branch: env-abstraction-layer
Gerrit-Owner: Dduvall <[email protected]>
Gerrit-Reviewer: Cmcmahon <[email protected]>
Gerrit-Reviewer: Dduvall <[email protected]>
Gerrit-Reviewer: Hashar <[email protected]>
Gerrit-Reviewer: Zfilipin <[email protected]>
Gerrit-Reviewer: jenkins-bot <>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to